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

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

Issue 1477553002: Issue 25034. Record only the target source's errors. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
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 23878b1a69656ededd8be12fffe6112a780bf253..e0d8155afa08f6519739f633e500e49bf50ff5d9 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -677,10 +677,20 @@ final ListResultDescriptor<AnalysisError> VERIFY_ERRORS =
'VERIFY_ERRORS', AnalysisError.NO_ERRORS);
/**
+ * Return a list of unique errors for the [Source] of the given [target].
+ */
+List<AnalysisError> getTargetSourceErrors(
+ RecordingErrorListener listener, AnalysisTarget target) {
+ Source source = target.source;
+ List<AnalysisError> errors = listener.getErrorsForSource(source);
+ return getUniqueErrors(errors);
+}
+
+/**
* Return a list of errors containing the errors from the given [errors] list
* but with duplications removed.
*/
-List<AnalysisError> removeDuplicateErrors(List<AnalysisError> errors) {
+List<AnalysisError> getUniqueErrors(List<AnalysisError> errors) {
if (errors.isEmpty) {
return errors;
}
@@ -3476,8 +3486,7 @@ class ParseDartTask extends SourceBasedAnalysisTask {
List<Source> exportedSources = exportedSourceSet.toList();
List<Source> importedSources = importedSourceSet.toList();
List<Source> includedSources = includedSourceSet.toList();
- List<AnalysisError> parseErrors =
- removeDuplicateErrors(errorListener.errors);
+ List<AnalysisError> parseErrors = getUniqueErrors(errorListener.errors);
List<Source> unitSources = <Source>[source]..addAll(includedSourceSet);
List<LibrarySpecificUnit> librarySpecificUnits =
unitSources.map((s) => new LibrarySpecificUnit(source, s)).toList();
@@ -4650,7 +4659,7 @@ class ResolveUnitTask extends SourceBasedAnalysisTask {
// AST's for constructor initializers into it) but does not produce an
// updated version of the element model.
//
- outputs[RESOLVE_UNIT_ERRORS] = errorListener.errors;
+ outputs[RESOLVE_UNIT_ERRORS] = getTargetSourceErrors(errorListener, target);
outputs[RESOLVED_UNIT10] = unit;
}
@@ -4741,7 +4750,7 @@ class ResolveUnitTypeNamesTask extends SourceBasedAnalysisTask {
// Record outputs.
//
outputs[RESOLVE_TYPE_NAMES_ERRORS] =
- removeDuplicateErrors(errorListener.errors);
+ getTargetSourceErrors(errorListener, target);
outputs[RESOLVED_UNIT3] = unit;
}
@@ -4832,7 +4841,7 @@ class ResolveVariableReferencesTask extends SourceBasedAnalysisTask {
//
outputs[RESOLVED_UNIT4] = unit;
outputs[VARIABLE_REFERENCE_ERRORS] =
- removeDuplicateErrors(errorListener.errors);
+ getTargetSourceErrors(errorListener, target);
}
/**
@@ -4929,7 +4938,7 @@ class ScanDartTask extends SourceBasedAnalysisTask {
outputs[TOKEN_STREAM] = scanner.tokenize();
outputs[LINE_INFO] = new LineInfo(scanner.lineStarts);
- outputs[SCAN_ERRORS] = removeDuplicateErrors(errorListener.errors);
+ outputs[SCAN_ERRORS] = getUniqueErrors(errorListener.errors);
} else if (target is Source) {
String content = getRequiredInput(CONTENT_INPUT_NAME);
@@ -4940,7 +4949,7 @@ class ScanDartTask extends SourceBasedAnalysisTask {
outputs[TOKEN_STREAM] = scanner.tokenize();
outputs[LINE_INFO] = new LineInfo(scanner.lineStarts);
- outputs[SCAN_ERRORS] = removeDuplicateErrors(errorListener.errors);
+ outputs[SCAN_ERRORS] = getUniqueErrors(errorListener.errors);
} else {
throw new AnalysisException(
'Cannot scan Dart code from a ${target.runtimeType}');
@@ -5020,7 +5029,7 @@ class StrongModeVerifyUnitTask extends SourceBasedAnalysisTask {
//
// Record outputs.
//
- outputs[STRONG_MODE_ERRORS] = removeDuplicateErrors(errorListener.errors);
+ outputs[STRONG_MODE_ERRORS] = getUniqueErrors(errorListener.errors);
outputs[RESOLVED_UNIT] = unit;
}
@@ -5115,7 +5124,7 @@ class VerifyUnitTask extends SourceBasedAnalysisTask {
//
// Record outputs.
//
- outputs[VERIFY_ERRORS] = removeDuplicateErrors(errorListener.errors);
+ outputs[VERIFY_ERRORS] = getUniqueErrors(errorListener.errors);
}
/**
« no previous file with comments | « pkg/analysis_server/test/analysis/get_errors_test.dart ('k') | pkg/analyzer/test/generated/compile_time_error_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698