Index: dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/context/AnalysisContextImplTest.java |
=================================================================== |
--- dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/context/AnalysisContextImplTest.java (revision 34682) |
+++ dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/context/AnalysisContextImplTest.java (working copy) |
@@ -15,6 +15,7 @@ |
import com.google.dart.engine.EngineTestCase; |
import com.google.dart.engine.ast.CompilationUnit; |
+import com.google.dart.engine.ast.ImportDirective; |
import com.google.dart.engine.ast.SimpleIdentifier; |
import com.google.dart.engine.ast.TopLevelVariableDeclaration; |
import com.google.dart.engine.context.AnalysisContextFactory; |
@@ -30,7 +31,9 @@ |
import com.google.dart.engine.element.LibraryElement; |
import com.google.dart.engine.element.PropertyAccessorElement; |
import com.google.dart.engine.error.AnalysisError; |
+import com.google.dart.engine.html.ast.HtmlScriptTagNode; |
import com.google.dart.engine.html.ast.HtmlUnit; |
+import com.google.dart.engine.html.ast.XmlTagNode; |
import com.google.dart.engine.internal.cache.DartEntry; |
import com.google.dart.engine.internal.scope.Namespace; |
import com.google.dart.engine.internal.task.ResolveDartLibraryTask; |
@@ -869,6 +872,32 @@ |
assertNotNull(unit); |
} |
+ public void test_parseHtmlUnit_resolveDirectives() throws Exception { |
+ Source libSource = addSource("/lib.dart", createSource(// |
+ "library lib;", |
+ "class ClassA {}")); |
+ Source source = addSource("/lib.html", createSource(// |
+ "<html>", |
+ "<head>", |
+ " <script type='application/dart'>", |
+ " import 'lib.dart';", |
+ " ClassA v = null;", |
+ " </script>", |
+ "</head>", |
+ "<body>", |
+ "</body>", |
+ "</html>")); |
+ HtmlUnit unit = context.parseHtmlUnit(source); |
+ // import directive should be resolved |
+ XmlTagNode htmlNode = unit.getTagNodes().get(0); |
+ XmlTagNode headNode = htmlNode.getTagNodes().get(0); |
+ HtmlScriptTagNode scriptNode = (HtmlScriptTagNode) headNode.getTagNodes().get(0); |
+ CompilationUnit script = scriptNode.getScript(); |
+ ImportDirective importNode = (ImportDirective) script.getDirectives().get(0); |
+ assertNotNull(importNode.getUriContent()); |
+ assertEquals(libSource, importNode.getSource()); |
+ } |
+ |
public void test_performAnalysisTask_changeLibraryContents() throws Exception { |
Source libSource = addSource("/test.dart", "library lib; part 'test-part.dart';"); |
Source partSource = addSource("/test-part.dart", "part of lib;"); |