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

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

Issue 2651513002: Issue 28466. Include ErrorProcessor(s) into the AnalysisOptions signature. (Closed)
Patch Set: Created 3 years, 11 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/lib/src/generated/engine.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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 /// Create an error processor that assigns errors with this [code] the 78 /// Create an error processor that assigns errors with this [code] the
79 /// given [severity]. 79 /// given [severity].
80 /// 80 ///
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.
88 String get description => '$code -> ${severity?.name}';
89
87 /// Check if this processor applies to the given [error]. 90 /// Check if this processor applies to the given [error].
88 bool appliesTo(AnalysisError error) => code == error.errorCode.name; 91 bool appliesTo(AnalysisError error) => code == error.errorCode.name;
89 92
90 /// Return an error processor associated in the [analysisOptions] for the 93 /// Return an error processor associated in the [analysisOptions] for the
91 /// given [error], or `null` if none is found. 94 /// given [error], or `null` if none is found.
92 static ErrorProcessor getProcessor( 95 static ErrorProcessor getProcessor(
93 AnalysisOptions analysisOptions, AnalysisError error) { 96 AnalysisOptions analysisOptions, AnalysisError error) {
94 if (analysisOptions == null) { 97 if (analysisOptions == null) {
95 return null; 98 return null;
96 } 99 }
(...skipping 13 matching lines...) Expand all
110 113
111 /// In strong mode, this upgrades static type warnings to errors. 114 /// In strong mode, this upgrades static type warnings to errors.
112 class _StrongModeTypeErrorProcessor implements ErrorProcessor { 115 class _StrongModeTypeErrorProcessor implements ErrorProcessor {
113 static final instance = new _StrongModeTypeErrorProcessor(); 116 static final instance = new _StrongModeTypeErrorProcessor();
114 117
115 // TODO(rnystrom): As far as I know, this is only used to implement 118 // TODO(rnystrom): As far as I know, this is only used to implement
116 // appliesTo(). Consider making it private in ErrorProcessor if possible. 119 // appliesTo(). Consider making it private in ErrorProcessor if possible.
117 String get code => throw new UnsupportedError( 120 String get code => throw new UnsupportedError(
118 "_StrongModeTypeErrorProcessor is not specific to an error code."); 121 "_StrongModeTypeErrorProcessor is not specific to an error code.");
119 122
123 @override
124 String get description => 'allStrongWarnings -> ERROR';
125
120 /// In strong mode, type warnings are upgraded to errors. 126 /// In strong mode, type warnings are upgraded to errors.
121 ErrorSeverity get severity => ErrorSeverity.ERROR; 127 ErrorSeverity get severity => ErrorSeverity.ERROR;
122 128
123 /// Check if this processor applies to the given [error]. 129 /// Check if this processor applies to the given [error].
124 bool appliesTo(AnalysisError error) { 130 bool appliesTo(AnalysisError error) {
125 ErrorCode errorCode = error.errorCode; 131 ErrorCode errorCode = error.errorCode;
126 if (errorCode is StaticTypeWarningCode) { 132 if (errorCode is StaticTypeWarningCode) {
127 return true; 133 return true;
128 } 134 }
129 if (errorCode is StaticWarningCode) { 135 if (errorCode is StaticWarningCode) {
130 return errorCode.isStrongModeError; 136 return errorCode.isStrongModeError;
131 } 137 }
132 return false; 138 return false;
133 } 139 }
134 } 140 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698