| 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 aeac0531ecd0900f04baa9823592b8be49697002..2c5dfdcc49a9fe7b4f2533e0b45cb32ae899a2e9 100644
|
| --- a/pkg/analyzer/lib/source/analysis_options_provider.dart
|
| +++ b/pkg/analyzer/lib/source/analysis_options_provider.dart
|
| @@ -6,6 +6,7 @@ library source.analysis_options_provider;
|
|
|
| import 'package:analyzer/file_system/file_system.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| +import 'package:source_span/source_span.dart';
|
| import 'package:yaml/yaml.dart';
|
|
|
| /// Provide the options found in the `.analysis_options` file.
|
| @@ -34,17 +35,19 @@ class AnalysisOptionsProvider {
|
| }
|
| var doc = loadYaml(optionsSource);
|
| if ((doc != null) && (doc is! YamlMap)) {
|
| - throw new Exception(
|
| + throw new OptionsFormatException(
|
| 'Bad options file format (expected map, got ${doc.runtimeType})\n'
|
| 'contents of options file:\n'
|
| - '$optionsSource\n');
|
| + '$optionsSource\n',
|
| + doc.span);
|
| }
|
| if (doc is YamlMap) {
|
| doc.forEach((k, v) {
|
| if (k is! String) {
|
| - throw new Exception(
|
| + throw new OptionsFormatException(
|
| 'Bad options file format (expected String scope key, '
|
| - 'got ${k.runtimeType})');
|
| + 'got ${k.runtimeType})',
|
| + k != null ? k.span : doc.span);
|
| }
|
| options[k] = v;
|
| });
|
| @@ -63,3 +66,14 @@ class AnalysisOptionsProvider {
|
| }
|
| }
|
| }
|
| +
|
| +/// Thrown on options format exceptions.
|
| +class OptionsFormatException implements Exception {
|
| + final String message;
|
| + final SourceSpan span;
|
| + OptionsFormatException(this.message, [this.span]);
|
| +
|
| + @override
|
| + String toString() =>
|
| + 'OptionsFormatException: ${message?.toString()}, ${span?.toString()}';
|
| +}
|
|
|