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 62d68b5f7b590cab79ddc411fe8e16cfc3743046..a88072b8490669828919fef2d6fd840cf47fb961 100644 |
--- a/pkg/analyzer/lib/src/task/dart.dart |
+++ b/pkg/analyzer/lib/src/task/dart.dart |
@@ -3098,6 +3098,10 @@ class VerifyUnitTask extends SourceBasedAnalysisTask { |
CompilationUnitElement unitElement = unit.element; |
LibraryElement libraryElement = unitElement.library; |
// |
+ // Validate the directives. |
+ // |
+ validateDirectives(unit); |
+ // |
// Use the ErrorVerifier to compute errors. |
// |
ErrorVerifier errorVerifier = new ErrorVerifier(errorReporter, |
@@ -3110,6 +3114,39 @@ class VerifyUnitTask extends SourceBasedAnalysisTask { |
} |
/** |
+ * Check each directive in the given [unit] to see if the referenced source |
+ * exists and report an error if it does not. |
+ */ |
+ void validateDirectives(CompilationUnit unit) { |
+ for (Directive directive in unit.directives) { |
+ if (directive is UriBasedDirective) { |
+ validateReferencedSource(directive); |
+ } |
+ } |
+ } |
+ |
+ /** |
+ * Check the given [directive] to see if the referenced source exists and |
+ * report an error if it does not. |
+ */ |
+ void validateReferencedSource(UriBasedDirective directive) { |
+ Source source = directive.source; |
+ if (source != null) { |
+ if (context.exists(source)) { |
+ return; |
+ } |
+ } else { |
+ // Don't report errors already reported by ParseDartTask.resolveDirective |
+ if (directive.validate() != null) { |
+ return; |
+ } |
+ } |
+ StringLiteral uriLiteral = directive.uri; |
+ errorReporter.reportErrorForNode(CompileTimeErrorCode.URI_DOES_NOT_EXIST, |
+ uriLiteral, [directive.uriContent]); |
+ } |
+ |
+ /** |
* Return a map from the names of the inputs of this kind of task to the task |
* input descriptors describing those inputs for a task with the |
* given [target]. |