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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java

Issue 15741017: Issue 8365. Report error when user library imports an internal SDK library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java
index a22145d2d4759b8fa691f4641e4d4222137d0bbe..650127227d0e407070dcf1353717f0572ac58589 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/Library.java
@@ -21,6 +21,7 @@ import com.google.dart.engine.ast.ImportDirective;
import com.google.dart.engine.ast.SimpleStringLiteral;
import com.google.dart.engine.ast.StringInterpolation;
import com.google.dart.engine.ast.StringLiteral;
+import com.google.dart.engine.ast.UriBasedDirective;
import com.google.dart.engine.context.AnalysisException;
import com.google.dart.engine.error.AnalysisError;
import com.google.dart.engine.error.AnalysisErrorListener;
@@ -75,6 +76,11 @@ public class Library {
private HashMap<ImportDirective, Library> importedLibraries = new HashMap<ImportDirective, Library>();
/**
+ * A table mapping URI-based directive to the actual URI value.
+ */
+ private HashMap<UriBasedDirective, String> directiveUris = new HashMap<UriBasedDirective, String>();
+
+ /**
* A flag indicating whether this library explicitly imports core.
*/
private boolean explicitlyImportsCore = false;
@@ -282,13 +288,14 @@ public class Library {
}
/**
- * Return the result of resolving the given URI against the URI of the library, or {@code null} if
- * the URI is not valid. If the URI is not valid, report the error.
+ * Return the result of resolving the URI of the given URI-based directive against the URI of the
+ * library, or {@code null} if the URI is not valid. If the URI is not valid, report the error.
*
- * @param uriLiteral the string literal specifying the URI to be resolved
- * @return the result of resolving the given URI against the URI of the library
+ * @param directive the directive which URI should be resolved
+ * @return the result of resolving the URI against the URI of the library
*/
- public Source getSource(StringLiteral uriLiteral) {
+ public Source getSource(UriBasedDirective directive) {
+ StringLiteral uriLiteral = directive.getUri();
if (uriLiteral instanceof StringInterpolation) {
errorListener.onError(new AnalysisError(
librarySource,
@@ -298,6 +305,7 @@ public class Library {
return null;
}
String uriContent = getStringValue(uriLiteral);
+ directiveUris.put(directive, uriContent);
try {
new URI(uriContent);
Source source = getSource(uriContent);
@@ -322,6 +330,13 @@ public class Library {
}
/**
+ * Returns the URI value of the given directive.
+ */
+ public String getUri(UriBasedDirective directive) {
+ return directiveUris.get(directive);
+ }
+
+ /**
* Set the AST structure associated with the defining compilation unit for this library to the
* given AST structure.
*

Powered by Google App Engine
This is Rietveld 408576698