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

Side by Side Diff: pkg/analyzer/lib/source/analysis_options_provider.dart

Issue 1832643002: Allow Analysis Server crawl up the folders to search .analysis_options file. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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) 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;
8
7 import 'package:analyzer/file_system/file_system.dart'; 9 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/util/yaml.dart'; 11 import 'package:analyzer/src/util/yaml.dart';
10 import 'package:source_span/source_span.dart'; 12 import 'package:source_span/source_span.dart';
11 import 'package:yaml/yaml.dart'; 13 import 'package:yaml/yaml.dart';
12 14
13 /// Provide the options found in the `.analysis_options` file. 15 /// Provide the options found in the `.analysis_options` file.
14 class AnalysisOptionsProvider { 16 class AnalysisOptionsProvider {
15 /// Provide the options found in [root]/[ANALYSIS_OPTIONS_FILE]. 17 /// Provide the options found in [root]/[ANALYSIS_OPTIONS_FILE].
16 /// Return an empty options map if the file does not exist. 18 /// Return an empty options map if the file does not exist.
17 Map<String, YamlNode> getOptions(Folder root) { 19 Map<String, YamlNode> getOptions(Folder root, {bool crawlUp: false}) {
18 var optionsSource = _readAnalysisOptionsFile( 20 Resource resource;
19 root.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE)); 21 for (Folder folder = root; folder != null; folder = folder.parent) {
22 resource = folder.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE);
23 if (resource.exists || !crawlUp) {
24 break;
25 }
26 }
27 var optionsSource = _readAnalysisOptionsFile(resource);
Brian Wilkerson 2016/03/23 22:16:57 type?
20 return getOptionsFromString(optionsSource); 28 return getOptionsFromString(optionsSource);
21 } 29 }
22 30
23 /// Provide the options found in [file]. 31 /// Provide the options found in [file].
24 /// Return an empty options map if the file does not exist. 32 /// Return an empty options map if the file does not exist.
25 Map<String, YamlNode> getOptionsFromFile(File file) { 33 Map<String, YamlNode> getOptionsFromFile(File file) {
26 var optionsSource = _readAnalysisOptionsFile(file); 34 var optionsSource = _readAnalysisOptionsFile(file);
27 return getOptionsFromString(optionsSource); 35 return getOptionsFromString(optionsSource);
28 } 36 }
29 37
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 /// Thrown on options format exceptions. 116 /// Thrown on options format exceptions.
109 class OptionsFormatException implements Exception { 117 class OptionsFormatException implements Exception {
110 final String message; 118 final String message;
111 final SourceSpan span; 119 final SourceSpan span;
112 OptionsFormatException(this.message, [this.span]); 120 OptionsFormatException(this.message, [this.span]);
113 121
114 @override 122 @override
115 String toString() => 123 String toString() =>
116 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}'; 124 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}';
117 } 125 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/context_manager.dart ('k') | pkg/analyzer/test/source/analysis_options_provider_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698