| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 context.directory.manager; | 5 library context.directory.manager; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:core' hide Resource; | 10 import 'dart:core' hide Resource; |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 } | 532 } |
| 533 // no | 533 // no |
| 534 return false; | 534 return false; |
| 535 } | 535 } |
| 536 | 536 |
| 537 /** | 537 /** |
| 538 * Process [options] for the given context [info]. | 538 * Process [options] for the given context [info]. |
| 539 */ | 539 */ |
| 540 void processOptionsForContext(ContextInfo info, Folder folder, | 540 void processOptionsForContext(ContextInfo info, Folder folder, |
| 541 {bool optionsRemoved: false}) { | 541 {bool optionsRemoved: false}) { |
| 542 Map<String, YamlNode> options; | 542 Map<String, Object> options; |
| 543 try { | 543 try { |
| 544 options = analysisOptionsProvider.getOptions(folder); | 544 options = analysisOptionsProvider.getOptions(folder); |
| 545 } catch (_) { | 545 } catch (_) { |
| 546 // Parse errors are reported by GenerateOptionsErrorsTask. | 546 // Parse errors are reported by GenerateOptionsErrorsTask. |
| 547 } | 547 } |
| 548 | 548 |
| 549 if (options == null && !optionsRemoved) { | 549 if (options == null && !optionsRemoved) { |
| 550 return; | 550 return; |
| 551 } | 551 } |
| 552 | 552 |
| 553 // In case options files are removed, revert to defaults. |
| 554 if (optionsRemoved) { |
| 555 // Start with defaults. |
| 556 info.context.analysisOptions = new AnalysisOptionsImpl(); |
| 557 |
| 558 // Apply inherited options. |
| 559 options = _getEmbeddedOptions(info.context); |
| 560 if (options != null) { |
| 561 configureContextOptions(info.context, options); |
| 562 } |
| 563 } else { |
| 564 // Check for embedded options. |
| 565 YamlMap embeddedOptions = _getEmbeddedOptions(info.context); |
| 566 if (embeddedOptions != null) { |
| 567 options = new Merger().merge(embeddedOptions, options); |
| 568 } |
| 569 } |
| 570 |
| 553 // Notify options processors. | 571 // Notify options processors. |
| 554 AnalysisEngine.instance.optionsPlugin.optionsProcessors | 572 AnalysisEngine.instance.optionsPlugin.optionsProcessors |
| 555 .forEach((OptionsProcessor p) { | 573 .forEach((OptionsProcessor p) { |
| 556 try { | 574 try { |
| 557 p.optionsProcessed(info.context, options); | 575 p.optionsProcessed(info.context, options); |
| 558 } catch (e, stacktrace) { | 576 } catch (e, stacktrace) { |
| 559 AnalysisEngine.instance.logger.logError( | 577 AnalysisEngine.instance.logger.logError( |
| 560 'Error processing .analysis_options', | 578 'Error processing .analysis_options', |
| 561 new CaughtException(e, stacktrace)); | 579 new CaughtException(e, stacktrace)); |
| 562 } | 580 } |
| 563 }); | 581 }); |
| 564 | 582 |
| 565 // In case options files are removed, revert to defaults. | 583 configureContextOptions(info.context, options); |
| 566 if (optionsRemoved) { | |
| 567 // Start with defaults. | |
| 568 info.context.analysisOptions = new AnalysisOptionsImpl(); | |
| 569 | 584 |
| 570 // Apply inherited options. | 585 // Nothing more to do. |
| 571 YamlMap embeddedOptions = _getEmbeddedOptions(info.context); | 586 if (options == null) { |
| 572 if (embeddedOptions != null) { | |
| 573 configureContextOptions(info.context, embeddedOptions); | |
| 574 } | |
| 575 return; | 587 return; |
| 576 } | 588 } |
| 577 | 589 |
| 578 // Check for embedded options. | |
| 579 YamlMap embeddedOptions = _getEmbeddedOptions(info.context); | |
| 580 if (embeddedOptions != null) { | |
| 581 options = new Merger().merge(embeddedOptions, options); | |
| 582 } | |
| 583 | |
| 584 // Analysis options are processed 'in-line'. | |
| 585 var analyzer = options[AnalyzerOptions.analyzer]; | 590 var analyzer = options[AnalyzerOptions.analyzer]; |
| 586 if (analyzer is! Map) { | 591 if (analyzer is! Map) { |
| 587 // No options for analyzer. | 592 // Done. |
| 588 return; | 593 return; |
| 589 } | 594 } |
| 590 | 595 |
| 591 configureContextOptions(info.context, options); | |
| 592 | |
| 593 // Set ignore patterns. | 596 // Set ignore patterns. |
| 594 YamlList exclude = analyzer[AnalyzerOptions.exclude]; | 597 YamlList exclude = analyzer[AnalyzerOptions.exclude]; |
| 595 if (exclude != null) { | 598 if (exclude != null) { |
| 596 setIgnorePatternsForContext(info, exclude); | 599 setIgnorePatternsForContext(info, exclude); |
| 597 } | 600 } |
| 598 } | 601 } |
| 599 | 602 |
| 600 @override | 603 @override |
| 601 void refresh(List<Resource> roots) { | 604 void refresh(List<Resource> roots) { |
| 602 // Destroy old contexts | 605 // Destroy old contexts |
| (...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 ResourceProvider resourceProvider) { | 1590 ResourceProvider resourceProvider) { |
| 1588 if (packages != null) { | 1591 if (packages != null) { |
| 1589 // Construct package map for the SdkExtUriResolver. | 1592 // Construct package map for the SdkExtUriResolver. |
| 1590 Map<String, List<Folder>> packageMap = buildPackageMap(resourceProvider); | 1593 Map<String, List<Folder>> packageMap = buildPackageMap(resourceProvider); |
| 1591 return <UriResolver>[new SdkExtUriResolver(packageMap)]; | 1594 return <UriResolver>[new SdkExtUriResolver(packageMap)]; |
| 1592 } else { | 1595 } else { |
| 1593 return const <UriResolver>[]; | 1596 return const <UriResolver>[]; |
| 1594 } | 1597 } |
| 1595 } | 1598 } |
| 1596 } | 1599 } |
| OLD | NEW |