OLD | NEW |
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 /** | 329 /** |
330 * Return the analysis options that should be used when the given [context] is | 330 * Return the analysis options that should be used when the given [context] is |
331 * used to analyze code in the directory with the given [path]. | 331 * used to analyze code in the directory with the given [path]. |
332 */ | 332 */ |
333 AnalysisOptions getAnalysisOptions(AnalysisContext context, String path) { | 333 AnalysisOptions getAnalysisOptions(AnalysisContext context, String path) { |
334 AnalysisOptionsImpl options = createDefaultOptions(); | 334 AnalysisOptionsImpl options = createDefaultOptions(); |
335 File optionsFile = getOptionsFile(path); | 335 File optionsFile = getOptionsFile(path); |
336 if (optionsFile != null) { | 336 if (optionsFile != null) { |
337 List<OptionsProcessor> optionsProcessors = | 337 List<OptionsProcessor> optionsProcessors = |
338 AnalysisEngine.instance.optionsPlugin.optionsProcessors; | 338 AnalysisEngine.instance.optionsPlugin.optionsProcessors; |
| 339 // TODO(danrubel) restructure so that we don't recalculate the package map |
| 340 // more than once per path. |
| 341 Packages packages = createPackageMap(path); |
| 342 Map<String, List<Folder>> packageMap = convertPackagesToMap(packages); |
| 343 List<UriResolver> resolvers = <UriResolver>[ |
| 344 new ResourceUriResolver(resourceProvider), |
| 345 new PackageMapUriResolver(resourceProvider, packageMap), |
| 346 ]; |
| 347 SourceFactory sourceFactory = |
| 348 new SourceFactory(resolvers, packages, resourceProvider); |
339 try { | 349 try { |
340 Map<String, YamlNode> optionMap = | 350 Map<String, YamlNode> optionMap = |
341 new AnalysisOptionsProvider().getOptionsFromFile(optionsFile); | 351 new AnalysisOptionsProvider(sourceFactory) |
| 352 .getOptionsFromFile(optionsFile); |
342 optionsProcessors.forEach( | 353 optionsProcessors.forEach( |
343 (OptionsProcessor p) => p.optionsProcessed(context, optionMap)); | 354 (OptionsProcessor p) => p.optionsProcessed(context, optionMap)); |
344 applyToAnalysisOptions(options, optionMap); | 355 applyToAnalysisOptions(options, optionMap); |
345 } on Exception catch (exception) { | 356 } on Exception catch (exception) { |
346 optionsProcessors.forEach((OptionsProcessor p) => p.onError(exception)); | 357 optionsProcessors.forEach((OptionsProcessor p) => p.onError(exception)); |
347 } | 358 } |
348 } | 359 } |
349 return options; | 360 return options; |
350 } | 361 } |
351 | 362 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 String _readEmbedderYaml(Folder libDir) { | 626 String _readEmbedderYaml(Folder libDir) { |
616 File file = libDir.getChild(EMBEDDER_FILE_NAME); | 627 File file = libDir.getChild(EMBEDDER_FILE_NAME); |
617 try { | 628 try { |
618 return file.readAsStringSync(); | 629 return file.readAsStringSync(); |
619 } on FileSystemException { | 630 } on FileSystemException { |
620 // File can't be read. | 631 // File can't be read. |
621 return null; | 632 return null; |
622 } | 633 } |
623 } | 634 } |
624 } | 635 } |
OLD | NEW |