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

Unified Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 2048713002: Compute IGNORE_INFO and filter DART_ERRORS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/incremental_analyzer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/task/dart.dart
diff --git a/pkg/analyzer/lib/src/task/dart.dart b/pkg/analyzer/lib/src/task/dart.dart
index 5eb259081e105c00890ee26bd60fcbca9d4d0561..ea97f7984a29ead1944bee6662bf382c3b6356af 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -2597,15 +2597,7 @@ class DartErrorsTask extends SourceBasedAnalysisTask {
LineInfo lineInfo = getRequiredInput(LINE_INFO_INPUT);
- bool isIgnored(AnalysisError error) {
- int errorLine = lineInfo.getLocation(error.offset).lineNumber;
- String errorCode = error.errorCode.name.toLowerCase();
- // Ignores can be on the line or just preceding the error.
- return ignoreInfo.ignoredAt(errorCode, errorLine) ||
- ignoreInfo.ignoredAt(errorCode, errorLine - 1);
- }
-
- return errors.where((AnalysisError e) => !isIgnored(e)).toList();
+ return filterIgnored(errors, ignoreInfo, lineInfo);
}
/**
@@ -2650,6 +2642,27 @@ class DartErrorsTask extends SourceBasedAnalysisTask {
AnalysisContext context, AnalysisTarget target) {
return new DartErrorsTask(context, target);
}
+
+ /**
+ * Return a new list with items from [errors] which are not filtered out by
+ * the [ignoreInfo].
+ */
+ static List<AnalysisError> filterIgnored(
+ List<AnalysisError> errors, IgnoreInfo ignoreInfo, LineInfo lineInfo) {
+ if (errors.isEmpty || !ignoreInfo.hasIgnores) {
+ return errors;
+ }
+
+ bool isIgnored(AnalysisError error) {
+ int errorLine = lineInfo.getLocation(error.offset).lineNumber;
+ String errorCode = error.errorCode.name.toLowerCase();
+ // Ignores can be on the line or just preceding the error.
+ return ignoreInfo.ignoredAt(errorCode, errorLine) ||
+ ignoreInfo.ignoredAt(errorCode, errorLine - 1);
+ }
+
+ return errors.where((AnalysisError e) => !isIgnored(e)).toList();
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/incremental_analyzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698