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

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

Issue 214603014: Trunk CL for r=34540 (Closed) Base URL: https://dart.googlecode.com/svn/trunk/dart
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: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java
index 16cf1333c3b47505a8d7673a8c62783cfb8a963b..a33765d0e18cd92b59e5462dd35e1efce4263200 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/task/ParseHtmlTask.java
@@ -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 @@ public class ParseHtmlTask extends AnalysisTask {
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 @@ public class ParseHtmlTask extends AnalysisTask {
}
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