Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: pkg/analyzer/lib/src/generated/gn.dart

Issue 2660173002: implement default analysis options in bazel (Closed)
Patch Set: merge Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.generated.gn; 5 library analyzer.src.generated.gn;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:core'; 8 import 'dart:core';
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
11 import 'package:analyzer/src/generated/sdk.dart';
11 import 'package:analyzer/src/generated/source.dart'; 12 import 'package:analyzer/src/generated/source.dart';
12 import 'package:analyzer/src/generated/source_io.dart'; 13 import 'package:analyzer/src/generated/source_io.dart';
14 import 'package:analyzer/src/generated/workspace.dart';
13 import 'package:analyzer/src/util/fast_uri.dart'; 15 import 'package:analyzer/src/util/fast_uri.dart';
14 import 'package:path/path.dart'; 16 import 'package:path/path.dart';
15 17
16 /** 18 /**
17 * The [UriResolver] used to resolve `file` URIs in a [GnWorkspace]. 19 * The [UriResolver] used to resolve `file` URIs in a [GnWorkspace].
18 */ 20 */
19 class GnFileUriResolver extends ResourceUriResolver { 21 class GnFileUriResolver extends ResourceUriResolver {
20 /** 22 /**
21 * The workspace associated with this resolver. 23 * The workspace associated with this resolver.
22 */ 24 */
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 127
126 String sourcePath = context.relative(path, from: _packages[package]); 128 String sourcePath = context.relative(path, from: _packages[package]);
127 129
128 return FastUri.parse('package:$package/$sourcePath'); 130 return FastUri.parse('package:$package/$sourcePath');
129 } 131 }
130 } 132 }
131 133
132 /** 134 /**
133 * Information about a Gn workspace. 135 * Information about a Gn workspace.
134 */ 136 */
135 class GnWorkspace { 137 class GnWorkspace extends Workspace {
136 /** 138 /**
137 * The name of the directory that identifies the root of the workspace. 139 * The name of the directory that identifies the root of the workspace.
138 */ 140 */
139 static const String _jiriRootName = '.jiri_root'; 141 static const String _jiriRootName = '.jiri_root';
140 142
141 /** 143 /**
142 * The resource provider used to access the file system. 144 * The resource provider used to access the file system.
143 */ 145 */
144 final ResourceProvider provider; 146 final ResourceProvider provider;
145 147
146 /** 148 /**
147 * The absolute workspace root path (the directory containing the `.jiri_root` 149 * The absolute workspace root path (the directory containing the `.jiri_root`
148 * directory). 150 * directory).
149 */ 151 */
150 final String root; 152 final String root;
151 153
152 /** 154 /**
153 * The map of package sources indexed by package name. 155 * The map of package sources indexed by package name.
154 */ 156 */
155 final Map<String, String> packages; 157 final Map<String, String> packages;
156 158
157 GnWorkspace._(this.provider, this.root, this.packages); 159 GnWorkspace._(this.provider, this.root, this.packages);
158 160
159 /** 161 @override
160 * Return a map of package sources.
161 */
162 Map<String, List<Folder>> get packageMap { 162 Map<String, List<Folder>> get packageMap {
163 Map<String, List<Folder>> result = new HashMap<String, List<Folder>>(); 163 Map<String, List<Folder>> result = new HashMap<String, List<Folder>>();
164 packages.forEach((package, sourceDir) { 164 packages.forEach((package, sourceDir) {
165 result[package] = [provider.getFolder(sourceDir)]; 165 result[package] = [provider.getFolder(sourceDir)];
166 }); 166 });
167 return result; 167 return result;
168 } 168 }
169 169
170 @override
171 UriResolver get packageUriResolver => new GnPackageUriResolver(this);
172
173 @override
174 SourceFactory createSourceFactory(DartSdk sdk) {
175 List<UriResolver> resolvers = <UriResolver>[];
176 if (sdk != null) {
177 resolvers.add(new DartUriResolver(sdk));
178 }
179 resolvers.add(packageUriResolver);
180 resolvers.add(new GnFileUriResolver(this));
181 return new SourceFactory(resolvers, null, provider);
182 }
183
170 /** 184 /**
171 * Return the file with the given [absolutePath]. 185 * Return the file with the given [absolutePath].
172 * 186 *
173 * Return `null` if the given [absolutePath] is not in the workspace [root]. 187 * Return `null` if the given [absolutePath] is not in the workspace [root].
174 */ 188 */
175 File findFile(String absolutePath) { 189 File findFile(String absolutePath) {
176 try { 190 try {
177 File writableFile = provider.getFile(absolutePath); 191 File writableFile = provider.getFile(absolutePath);
178 return writableFile; 192 return writableFile;
179 } catch (_) { 193 } catch (_) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 String outDirectory = _getOutDirectory(provider, root); 260 String outDirectory = _getOutDirectory(provider, root);
247 Map<String, String> packages = _getPackages(provider, outDirectory); 261 Map<String, String> packages = _getPackages(provider, outDirectory);
248 return new GnWorkspace._(provider, root, packages); 262 return new GnWorkspace._(provider, root, packages);
249 } 263 }
250 264
251 // Go up the folder. 265 // Go up the folder.
252 folder = parent; 266 folder = parent;
253 } 267 }
254 } 268 }
255 } 269 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/bazel.dart ('k') | pkg/analyzer/lib/src/generated/workspace.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698