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

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

Issue 1127403004: Return empty contents for not existing sources. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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/context/context.dart ('k') | pkg/analyzer/lib/src/task/general.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 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].
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/task/general.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698