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

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

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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 source.analysis_options_provider; 5 library source.analysis_options_provider;
6 6
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:yaml/yaml.dart'; 9 import 'package:yaml/yaml.dart';
9 10
10 /// Provide the options found in the `.analysis_options` file. 11 /// Provide the options found in the `.analysis_options` file.
11 class AnalysisOptionsProvider { 12 class AnalysisOptionsProvider {
12 /// The name of the analysis options source file. 13 /// Provide the options found in [root]/[ANALYSIS_OPTIONS_FILE].
13 static const String ANALYSIS_OPTIONS_NAME = '.analysis_options';
14
15 /// Provide the options found in [root]/[ANALYSIS_OPTIONS_NAME].
16 /// Return an empty options map if the file does not exist. 14 /// Return an empty options map if the file does not exist.
17 Map<String, YamlNode> getOptions(Folder root) { 15 Map<String, YamlNode> getOptions(Folder root) {
18 var optionsSource = 16 var optionsSource = _readAnalysisOptionsFile(
19 _readAnalysisOptionsFile(root.getChild(ANALYSIS_OPTIONS_NAME)); 17 root.getChild(AnalysisEngine.ANALYSIS_OPTIONS_FILE));
20 return getOptionsFromString(optionsSource); 18 return getOptionsFromString(optionsSource);
21 } 19 }
22 20
23 /// Provide the options found in [file]. 21 /// Provide the options found in [file].
24 /// Return an empty options map if the file does not exist. 22 /// Return an empty options map if the file does not exist.
25 Map<String, YamlNode> getOptionsFromFile(File file) { 23 Map<String, YamlNode> getOptionsFromFile(File file) {
26 var optionsSource = _readAnalysisOptionsFile(file); 24 var optionsSource = _readAnalysisOptionsFile(file);
27 return getOptionsFromString(optionsSource); 25 return getOptionsFromString(optionsSource);
28 } 26 }
29 27
(...skipping 28 matching lines...) Expand all
58 /// Returns null if file does not exist. 56 /// Returns null if file does not exist.
59 String _readAnalysisOptionsFile(File file) { 57 String _readAnalysisOptionsFile(File file) {
60 try { 58 try {
61 return file.readAsStringSync(); 59 return file.readAsStringSync();
62 } on FileSystemException { 60 } on FileSystemException {
63 // File can't be read. 61 // File can't be read.
64 return null; 62 return null;
65 } 63 }
66 } 64 }
67 } 65 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/file_system/memory_file_system.dart ('k') | packages/analyzer/lib/src/context/context.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698