| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.source.analysis_options_provider; | 5 library analyzer.source.analysis_options_provider; |
| 6 | 6 |
| 7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/src/generated/engine.dart'; | 10 import 'package:analyzer/src/generated/engine.dart'; |
| 11 import 'package:analyzer/src/util/yaml.dart'; | 11 import 'package:analyzer/src/util/yaml.dart'; |
| 12 import 'package:source_span/source_span.dart'; | 12 import 'package:source_span/source_span.dart'; |
| 13 import 'package:yaml/yaml.dart'; | 13 import 'package:yaml/yaml.dart'; |
| 14 | 14 |
| 15 /// Provide the options found in the analysis options file. | 15 /// Provide the options found in the analysis options file. |
| 16 class AnalysisOptionsProvider { | 16 class AnalysisOptionsProvider { |
| 17 /// Provide the options found in either [root]/[ANALYSIS_OPTIONS_FILE] or | 17 /// Provide the options found in either |
| 18 /// [root]/[ANALYSIS_OPTIONS_YAML_FILE]. | 18 /// [root]/[AnalysisEngine.ANALYSIS_OPTIONS_FILE] or |
| 19 /// [root]/[AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE]. |
| 19 /// Return an empty options map if the file does not exist. | 20 /// Return an empty options map if the file does not exist. |
| 20 Map<String, YamlNode> getOptions(Folder root, {bool crawlUp: false}) { | 21 Map<String, YamlNode> getOptions(Folder root, {bool crawlUp: false}) { |
| 21 Resource resource; | 22 Resource resource; |
| 22 for (Folder folder = root; folder != null; folder = folder.parent) { | 23 for (Folder folder = root; folder != null; folder = folder.parent) { |
| 23 resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE); | 24 resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE); |
| 24 if (resource.exists) { | 25 if (resource.exists) { |
| 25 break; | 26 break; |
| 26 } | 27 } |
| 27 resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); | 28 resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE); |
| 28 if (resource.exists || !crawlUp) { | 29 if (resource.exists || !crawlUp) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 /// Thrown on options format exceptions. | 124 /// Thrown on options format exceptions. |
| 124 class OptionsFormatException implements Exception { | 125 class OptionsFormatException implements Exception { |
| 125 final String message; | 126 final String message; |
| 126 final SourceSpan span; | 127 final SourceSpan span; |
| 127 OptionsFormatException(this.message, [this.span]); | 128 OptionsFormatException(this.message, [this.span]); |
| 128 | 129 |
| 129 @override | 130 @override |
| 130 String toString() => | 131 String toString() => |
| 131 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}'; | 132 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}'; |
| 132 } | 133 } |
| OLD | NEW |