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

Side by Side Diff: pkg/analyzer/lib/src/context/builder.dart

Issue 2350143004: More clean-up in server (Closed)
Patch Set: Created 4 years, 3 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.context.context_builder; 5 library analyzer.src.context.context_builder;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:core'; 8 import 'dart:core';
9 9
10 import 'package:analyzer/context/declared_variables.dart'; 10 import 'package:analyzer/context/declared_variables.dart';
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 context.contentCache = contentCache; 129 context.contentCache = contentCache;
130 context.sourceFactory = createSourceFactory(path, options); 130 context.sourceFactory = createSourceFactory(path, options);
131 context.analysisOptions = options; 131 context.analysisOptions = options;
132 context.name = path; 132 context.name = path;
133 //_processAnalysisOptions(context, optionMap); 133 //_processAnalysisOptions(context, optionMap);
134 declareVariables(context); 134 declareVariables(context);
135 return context; 135 return context;
136 } 136 }
137 137
138 Map<String, List<Folder>> convertPackagesToMap(Packages packages) { 138 Map<String, List<Folder>> convertPackagesToMap(Packages packages) {
139 if (packages == null || packages == Packages.noPackages) { 139 Map<String, List<Folder>> folderMap = new HashMap<String, List<Folder>>();
140 return null; 140 if (packages != null && packages != Packages.noPackages) {
141 packages.asMap().forEach((String packagePath, Uri uri) {
scheglov 2016/09/20 15:29:14 Packages.map() says that it "Returns a map from pa
Brian Wilkerson 2016/09/20 15:39:16 Done
142 String path = resourceProvider.pathContext.fromUri(uri);
143 folderMap[packagePath] = [resourceProvider.getFolder(path)];
144 });
141 } 145 }
142 Map<String, List<Folder>> folderMap = new HashMap<String, List<Folder>>();
143 packages.asMap().forEach((String packagePath, Uri uri) {
144 String path = resourceProvider.pathContext.fromUri(uri);
145 folderMap[packagePath] = [resourceProvider.getFolder(path)];
146 });
147 return folderMap; 146 return folderMap;
148 } 147 }
149 148
150 // void _processAnalysisOptions( 149 // void _processAnalysisOptions(
151 // AnalysisContext context, Map<String, YamlNode> optionMap) { 150 // AnalysisContext context, Map<String, YamlNode> optionMap) {
152 // List<OptionsProcessor> optionsProcessors = 151 // List<OptionsProcessor> optionsProcessors =
153 // AnalysisEngine.instance.optionsPlugin.optionsProcessors; 152 // AnalysisEngine.instance.optionsPlugin.optionsProcessors;
154 // try { 153 // try {
155 // optionsProcessors.forEach( 154 // optionsProcessors.forEach(
156 // (OptionsProcessor p) => p.optionsProcessed(context, optionMap)); 155 // (OptionsProcessor p) => p.optionsProcessed(context, optionMap));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 List<UriResolver> resolvers = <UriResolver>[ 214 List<UriResolver> resolvers = <UriResolver>[
216 new DartUriResolver(findSdk(null, options)), 215 new DartUriResolver(findSdk(null, options)),
217 packageResolver, 216 packageResolver,
218 fileResolver 217 fileResolver
219 ]; 218 ];
220 return new SourceFactory(resolvers, null, resourceProvider); 219 return new SourceFactory(resolvers, null, resourceProvider);
221 } 220 }
222 } 221 }
223 Packages packages = createPackageMap(rootDirectoryPath); 222 Packages packages = createPackageMap(rootDirectoryPath);
224 Map<String, List<Folder>> packageMap = convertPackagesToMap(packages); 223 Map<String, List<Folder>> packageMap = convertPackagesToMap(packages);
225 List<UriResolver> resolvers = <UriResolver>[]; 224 List<UriResolver> resolvers = <UriResolver>[
226 resolvers.add(new DartUriResolver(findSdk(packageMap, options))); 225 new DartUriResolver(findSdk(packageMap, options)),
227 if (packageMap != null) { 226 new PackageMapUriResolver(resourceProvider, packageMap),
228 // TODO(brianwilkerson) I think that we don't need a PackageUriResolver 227 fileResolver
229 // when we can pass the packages object to the source factory directly. 228 ];
230 // Actually, I think we're using it to restoreUri, which could lead to
231 // inconsistencies.
232 resolvers.add(new PackageMapUriResolver(resourceProvider, packageMap));
233 }
234 resolvers.add(fileResolver);
235 return new SourceFactory(resolvers, packages, resourceProvider); 229 return new SourceFactory(resolvers, packages, resourceProvider);
236 } 230 }
237 231
238 /** 232 /**
239 * Add any [declaredVariables] to the list of declared variables used by the 233 * Add any [declaredVariables] to the list of declared variables used by the
240 * given [context]. 234 * given [context].
241 */ 235 */
242 void declareVariables(InternalAnalysisContext context) { 236 void declareVariables(InternalAnalysisContext context) {
243 if (declaredVariables != null && declaredVariables.isNotEmpty) { 237 if (declaredVariables != null && declaredVariables.isNotEmpty) {
244 DeclaredVariables contextVariables = context.declaredVariables; 238 DeclaredVariables contextVariables = context.declaredVariables;
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 String _readEmbedderYaml(Folder libDir) { 564 String _readEmbedderYaml(Folder libDir) {
571 File file = libDir.getChild(EMBEDDER_FILE_NAME); 565 File file = libDir.getChild(EMBEDDER_FILE_NAME);
572 try { 566 try {
573 return file.readAsStringSync(); 567 return file.readAsStringSync();
574 } on FileSystemException { 568 } on FileSystemException {
575 // File can't be read. 569 // File can't be read.
576 return null; 570 return null;
577 } 571 }
578 } 572 }
579 } 573 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698