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

Unified Diff: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java

Issue 223323002: Version 1.3.0-dev.7.10 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 9 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: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java
===================================================================
--- dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java (revision 34682)
+++ dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java (working copy)
@@ -13,8 +13,15 @@
*/
package com.google.dart.engine.internal.task;
+import com.google.dart.engine.ast.CompilationUnit;
+import com.google.dart.engine.ast.Directive;
+import com.google.dart.engine.ast.ExportDirective;
+import com.google.dart.engine.ast.ImportDirective;
+import com.google.dart.engine.ast.PartDirective;
+import com.google.dart.engine.context.AnalysisContext;
import com.google.dart.engine.context.AnalysisException;
import com.google.dart.engine.error.AnalysisError;
+import com.google.dart.engine.error.AnalysisErrorListener;
import com.google.dart.engine.html.ast.HtmlScriptTagNode;
import com.google.dart.engine.html.ast.HtmlUnit;
import com.google.dart.engine.html.ast.XmlAttributeNode;
@@ -174,8 +181,15 @@
scanner.setPassThroughElements(new String[] {TAG_SCRIPT});
Token token = scanner.tokenize();
lineInfo = new LineInfo(scanner.getLineStarts());
- RecordingErrorListener errorListener = new RecordingErrorListener();
+ final RecordingErrorListener errorListener = new RecordingErrorListener();
unit = new HtmlParser(source, errorListener).parse(token, lineInfo);
+ unit.accept(new RecursiveXmlVisitor<Void>() {
+ @Override
+ public Void visitHtmlScriptTagNode(HtmlScriptTagNode node) {
+ resolveScriptDirectives(node.getScript(), errorListener);
+ return null;
+ }
+ });
errors = errorListener.getErrorsForSource(source);
referencedLibraries = getLibrarySources();
} catch (Exception exception) {
@@ -219,4 +233,35 @@
}
return libraries.toArray(new Source[libraries.size()]);
}
+
+ /**
+ * Resolves directives in the given {@link CompilationUnit}.
+ */
+ private void resolveScriptDirectives(CompilationUnit script, AnalysisErrorListener errorListener) {
+ if (script == null) {
+ return;
+ }
+ AnalysisContext analysisContext = getContext();
+ for (Directive directive : script.getDirectives()) {
+ if (directive instanceof ExportDirective) {
+ ParseDartTask.resolveSource(
+ analysisContext,
+ source,
+ (ExportDirective) directive,
+ errorListener);
+ } else if (directive instanceof ImportDirective) {
+ ParseDartTask.resolveSource(
+ analysisContext,
+ source,
+ (ImportDirective) directive,
+ errorListener);
+ } else if (directive instanceof PartDirective) {
+ ParseDartTask.resolveSource(
+ analysisContext,
+ source,
+ (PartDirective) directive,
+ errorListener);
+ }
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698