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

Unified Diff: pkg/analyzer/lib/source/analysis_options_provider.dart

Issue 1918923003: Remove unnecessary casts and general code clean-up (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: clean-up Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/cache.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/source/analysis_options_provider.dart
diff --git a/pkg/analyzer/lib/source/analysis_options_provider.dart b/pkg/analyzer/lib/source/analysis_options_provider.dart
index 3e15c647c794d89a395e6460d58f0f40fad2d61c..600dffcbbbc89c1b167dab0769a1ef99c6302318 100644
--- a/pkg/analyzer/lib/source/analysis_options_provider.dart
+++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
@@ -38,19 +38,21 @@ class AnalysisOptionsProvider {
/// Provide the options found in [optionsSource].
/// Return an empty options map if the source is null.
Map<String, YamlNode> getOptionsFromString(String optionsSource) {
- var options = <String, YamlNode>{};
+ Map<String, YamlNode> options = <String, YamlNode>{};
if (optionsSource == null) {
return options;
}
- YamlNode doc;
- try {
- doc = loadYamlNode(optionsSource);
- } on YamlException catch (e) {
- throw new OptionsFormatException(e.message, e.span);
- } catch (e) {
- throw new OptionsFormatException('Unable to parse YAML document.');
+ YamlNode safelyLoadYamlNode() {
+ try {
+ return loadYamlNode(optionsSource);
+ } on YamlException catch (e) {
+ throw new OptionsFormatException(e.message, e.span);
+ } catch (e) {
+ throw new OptionsFormatException('Unable to parse YAML document.');
+ }
}
+ YamlNode doc = safelyLoadYamlNode();
// Empty options.
if (doc is YamlScalar && doc.value == null) {
@@ -62,7 +64,7 @@ class AnalysisOptionsProvider {
doc.span);
}
if (doc is YamlMap) {
- (doc as YamlMap).nodes.forEach((k, v) {
+ doc.nodes.forEach((k, YamlNode v) {
var key;
if (k is YamlScalar) {
key = k.value;
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/context/cache.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698