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

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

Issue 2863013002: Fix an issue with configuring the severity of lints. (Closed)
Patch Set: update dartdoc Created 3 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
« no previous file with comments | « no previous file | pkg/analyzer/test/source/error_processor_test.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/error/error.dart'; 7 import 'package:analyzer/error/error.dart';
8 import 'package:analyzer/src/error/codes.dart'; 8 import 'package:analyzer/src/error/codes.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/utilities_general.dart'; 10 import 'package:analyzer/src/generated/utilities_general.dart';
(...skipping 15 matching lines...) Expand all
26 /// Create an error config for the given error code map. 26 /// Create an error config for the given error code map.
27 /// For example: 27 /// For example:
28 /// new ErrorConfig({'missing_return' : 'error'}); 28 /// new ErrorConfig({'missing_return' : 'error'});
29 /// will create a processor config that turns `missing_return` hints into 29 /// will create a processor config that turns `missing_return` hints into
30 /// errors. 30 /// errors.
31 ErrorConfig(Object codeMap) { 31 ErrorConfig(Object codeMap) {
32 _processMap(codeMap); 32 _processMap(codeMap);
33 } 33 }
34 34
35 void _process(String code, Object action) { 35 void _process(String code, Object action) {
36 code = toUpperCase(code);
36 action = toLowerCase(action); 37 action = toLowerCase(action);
37 code = toUpperCase(code);
38 if (AnalyzerOptions.ignoreSynonyms.contains(action)) { 38 if (AnalyzerOptions.ignoreSynonyms.contains(action)) {
39 processors.add(new ErrorProcessor.ignore(code)); 39 processors.add(new ErrorProcessor.ignore(code));
40 } else { 40 } else {
41 ErrorSeverity severity = _toSeverity(action); 41 ErrorSeverity severity = _toSeverity(action);
42 if (severity != null) { 42 if (severity != null) {
43 processors.add(new ErrorProcessor(code, severity)); 43 processors.add(new ErrorProcessor(code, severity));
44 } 44 }
45 } 45 }
46 } 46 }
47 47
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 /// If [severity] is `null`, matching errors will be filtered. 81 /// If [severity] is `null`, matching errors will be filtered.
82 ErrorProcessor(this.code, [this.severity]); 82 ErrorProcessor(this.code, [this.severity]);
83 83
84 /// Create an error processor that ignores the given error by [code]. 84 /// Create an error processor that ignores the given error by [code].
85 factory ErrorProcessor.ignore(String code) => new ErrorProcessor(code); 85 factory ErrorProcessor.ignore(String code) => new ErrorProcessor(code);
86 86
87 /// The string that unique describes the processor. 87 /// The string that unique describes the processor.
88 String get description => '$code -> ${severity?.name}'; 88 String get description => '$code -> ${severity?.name}';
89 89
90 /// Check if this processor applies to the given [error]. 90 /// Check if this processor applies to the given [error].
91 bool appliesTo(AnalysisError error) => code == error.errorCode.name; 91 ///
92 /// Note: [code] is normalized to uppercase; `errorCode.name` for regular
93 /// analysis issues uses uppercase; `errorCode.name` for lints uses lowercase.
94 bool appliesTo(AnalysisError error) =>
95 code == error.errorCode.name ||
96 code == error.errorCode.name.toUpperCase();
92 97
93 /// Return an error processor associated in the [analysisOptions] for the 98 /// Return an error processor associated in the [analysisOptions] for the
94 /// given [error], or `null` if none is found. 99 /// given [error], or `null` if none is found.
95 static ErrorProcessor getProcessor( 100 static ErrorProcessor getProcessor(
96 AnalysisOptions analysisOptions, AnalysisError error) { 101 AnalysisOptions analysisOptions, AnalysisError error) {
97 if (analysisOptions == null) { 102 if (analysisOptions == null) {
98 return null; 103 return null;
99 } 104 }
100 105
101 // Let the user configure how specific errors are processed. 106 // Let the user configure how specific errors are processed.
(...skipping 29 matching lines...) Expand all
131 ErrorCode errorCode = error.errorCode; 136 ErrorCode errorCode = error.errorCode;
132 if (errorCode is StaticTypeWarningCode) { 137 if (errorCode is StaticTypeWarningCode) {
133 return true; 138 return true;
134 } 139 }
135 if (errorCode is StaticWarningCode) { 140 if (errorCode is StaticWarningCode) {
136 return errorCode.isStrongModeError; 141 return errorCode.isStrongModeError;
137 } 142 }
138 return false; 143 return false;
139 } 144 }
140 } 145 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/source/error_processor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698