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

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

Issue 1541453002: Error code validation updates. (Closed) Base URL: git@github.com:dart-lang/sdk.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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/options.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.error_processor; 5 library analyzer.source.error_processor;
6 6
7 import 'package:analyzer/src/generated/engine.dart'; 7 import 'package:analyzer/src/generated/engine.dart';
8 import 'package:analyzer/src/generated/error.dart'; 8 import 'package:analyzer/src/generated/error.dart';
9 import 'package:analyzer/src/generated/utilities_general.dart'; 9 import 'package:analyzer/src/generated/utilities_general.dart';
10 import 'package:analyzer/src/task/options.dart'; 10 import 'package:analyzer/src/task/options.dart';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 }); 47 });
48 } else if (codes is Map) { 48 } else if (codes is Map) {
49 codes.forEach((k, v) { 49 codes.forEach((k, v) {
50 if (k is String) { 50 if (k is String) {
51 _process(k, v); 51 _process(k, v);
52 } 52 }
53 }); 53 });
54 } 54 }
55 } 55 }
56 56
57 ErrorSeverity _toSeverity(String severity) { 57 ErrorSeverity _toSeverity(String severity) => severityMap[severity];
58 switch (severity) { 58 }
59 case 'error':
60 return ErrorSeverity.ERROR;
61 case 'info':
62 return ErrorSeverity.INFO;
63 case 'warning':
64 return ErrorSeverity.WARNING;
65 }
66 return null;
67 }
68 59
69 } 60 /// String identifiers mapped to associated severities.
61 const Map<String, ErrorSeverity> severityMap = const {
62 'error': ErrorSeverity.ERROR,
63 'info': ErrorSeverity.INFO,
64 'warning': ErrorSeverity.WARNING
65 };
70 66
71 /// Process errors by filtering or changing associated [ErrorSeverity]. 67 /// Process errors by filtering or changing associated [ErrorSeverity].
72 class ErrorProcessor { 68 class ErrorProcessor {
73 /// The code name of the associated error. 69 /// The code name of the associated error.
74 final String code; 70 final String code;
75 71
76 /// The desired severity of the processed error. 72 /// The desired severity of the processed error.
77 /// 73 ///
78 /// If `null`, this processor will "filter" the associated error code. 74 /// If `null`, this processor will "filter" the associated error code.
79 final ErrorSeverity severity; 75 final ErrorSeverity severity;
(...skipping 16 matching lines...) Expand all
96 AnalysisContext context, AnalysisError error) { 92 AnalysisContext context, AnalysisError error) {
97 if (context == null) { 93 if (context == null) {
98 return null; 94 return null;
99 } 95 }
100 List<ErrorProcessor> processors = 96 List<ErrorProcessor> processors =
101 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); 97 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS);
102 return processors.firstWhere((ErrorProcessor p) => p.appliesTo(error), 98 return processors.firstWhere((ErrorProcessor p) => p.appliesTo(error),
103 orElse: () => null); 99 orElse: () => null);
104 } 100 }
105 } 101 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/options.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698