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

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

Issue 2232863004: Create new error message for missing generated files (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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 | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/dart_test.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 c8b108bdf2c8dfbd742d35d681eacce96080422c..4dcc1c97df683b6bfc4e32033a2e952efe204382 100644
--- a/pkg/analyzer/lib/src/task/dart.dart
+++ b/pkg/analyzer/lib/src/task/dart.dart
@@ -6443,8 +6443,38 @@ class VerifyUnitTask extends SourceBasedAnalysisTask {
}
}
StringLiteral uriLiteral = directive.uri;
- errorReporter.reportErrorForNode(CompileTimeErrorCode.URI_DOES_NOT_EXIST,
- uriLiteral, [directive.uriContent]);
+ CompileTimeErrorCode errorCode = CompileTimeErrorCode.URI_DOES_NOT_EXIST;
+ if (_isGenerated(source)) {
+ errorCode = CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED;
+ }
+ errorReporter
+ .reportErrorForNode(errorCode, uriLiteral, [directive.uriContent]);
+ }
+
+ /**
+ * Return `true` if the given [source] refers to a file that is assumed to be
+ * generated.
+ */
+ bool _isGenerated(Source source) {
+ if (source == null) {
+ return false;
+ }
+ // TODO(brianwilkerson) Generalize this mechanism.
+ List<String> suffixes = <String>[
scheglov 2016/08/10 19:12:15 const const
Brian Wilkerson 2016/08/10 19:42:02 Done
+ '.g.dart',
+ '.pb.dart',
+ '.pbenum.dart',
+ '.pbserver.dart',
+ '.pbjson.dart',
+ '.template.dart'
+ ];
+ String fullName = source.fullName;
+ for (String suffix in suffixes) {
+ if (fullName.endsWith(suffix)) {
+ return true;
+ }
+ }
+ return false;
}
/**
« no previous file with comments | « pkg/analyzer/lib/src/generated/error.dart ('k') | pkg/analyzer/test/src/task/dart_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698