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

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

Issue 1933763002: Use null-aware operators to clean up the code (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Additional clean-up Created 4 years, 7 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; 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';
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (doc is YamlMap) { 66 if (doc is YamlMap) {
67 doc.nodes.forEach((k, YamlNode v) { 67 doc.nodes.forEach((k, YamlNode v) {
68 var key; 68 var key;
69 if (k is YamlScalar) { 69 if (k is YamlScalar) {
70 key = k.value; 70 key = k.value;
71 } 71 }
72 if (key is! String) { 72 if (key is! String) {
73 throw new OptionsFormatException( 73 throw new OptionsFormatException(
74 'Bad options file format (expected String scope key, ' 74 'Bad options file format (expected String scope key, '
75 'got ${k.runtimeType})', 75 'got ${k.runtimeType})',
76 k != null ? k.span : doc.span); 76 (k ?? doc).span);
77 } 77 }
78 if (v != null && v is! YamlNode) { 78 if (v != null && v is! YamlNode) {
79 throw new OptionsFormatException( 79 throw new OptionsFormatException(
80 'Bad options file format (expected Node value, ' 80 'Bad options file format (expected Node value, '
81 'got ${v.runtimeType}: `${v.toString()}`)', 81 'got ${v.runtimeType}: `${v.toString()}`)',
82 doc.span); 82 doc.span);
83 } 83 }
84 options[key] = v; 84 options[key] = v;
85 }); 85 });
86 } 86 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 /// Thrown on options format exceptions. 118 /// Thrown on options format exceptions.
119 class OptionsFormatException implements Exception { 119 class OptionsFormatException implements Exception {
120 final String message; 120 final String message;
121 final SourceSpan span; 121 final SourceSpan span;
122 OptionsFormatException(this.message, [this.span]); 122 OptionsFormatException(this.message, [this.span]);
123 123
124 @override 124 @override
125 String toString() => 125 String toString() =>
126 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}'; 126 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}';
127 } 127 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/file_system/memory_file_system.dart ('k') | pkg/analyzer/lib/source/path_filter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698