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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2527423002: Filter out AnalysisErrors with null 'errorCode'. (Closed)
Patch Set: Throw an exception if cannot find ErrorCode by its uniqueName. Created 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/dart/analysis/driver.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 2b397795f932f23ae63b1ca7262ea0ef0ee01714..a655e73f6ebca964fd0c9b642074813894239ab8 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -716,15 +716,15 @@ class AnalysisDriver {
FileState libraryFile, FileState file, List<int> bytes,
{String content, CompilationUnit resolvedUnit}) {
var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes);
- List<AnalysisError> errors = unit.errors
- .map((error) => new AnalysisError.forValues(
- file.source,
- error.offset,
- error.length,
- errorCodeByUniqueName(error.uniqueName),
- error.message,
- error.correction))
- .toList();
+ List<AnalysisError> errors = unit.errors.map((error) {
+ String errorName = error.uniqueName;
+ ErrorCode errorCode = errorCodeByUniqueName(errorName);
+ if (errorCode == null) {
+ throw new StateError('No ErrorCode for $errorName in $file');
+ }
+ return new AnalysisError.forValues(file.source, error.offset,
+ error.length, errorCode, error.message, error.correction);
+ }).toList();
return new AnalysisResult(
libraryFile,
file,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698