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

Unified Diff: editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java

Issue 10660028: Issue 3789. Resolve library prefix for LibraryElement for field and function references. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java
diff --git a/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java b/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java
index b4bfafc3d25b8d6ca0e8bbb6586c83235516e467..b00267437e98af6135d25502c9d1dcad03be0888 100644
--- a/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java
+++ b/editor/tools/plugins/com.google.dart.tools.core_test/src/com/google/dart/tools/core/utilities/ast/DartElementLocatorTest.java
@@ -208,6 +208,90 @@ public class DartElementLocatorTest extends TestCase {
}
}
+ /**
+ * Test for {@link DartImport}.
+ */
+ public void test_DartImport_onPrefixUsage_inFieldReference() throws Exception {
+ TestProject testProject = new TestProject("Test");
+ try {
+ IResource libResourceA = testProject.setUnitContent(
+ "LibA.dart",
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "#library('libA');",
+ "var field;",
+ "")).getResource();
+ IResource resourceTest = testProject.setUnitContent(
+ "TestC.dart",
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "#library('Test');",
+ "#import('LibA.dart', prefix: 'aaa');",
+ "f() {",
+ " aaa.field = 0;",
+ "}",
+ "")).getResource();
+ TestProject.waitForAutoBuild();
+ DartLibrary libraryA = testProject.getDartProject().getDartLibrary(libResourceA);
+ DartLibrary libraryTest = testProject.getDartProject().getDartLibrary(resourceTest);
+ // usage of "aaa" = "libraryA"
+ {
+ DartImport imprt = assertLocation(
+ libraryTest.getDefiningCompilationUnit(),
+ "aaa.field",
+ DartImport.class,
+ "'aaa');",
+ 5);
+ assertEquals(libraryA, imprt.getLibrary());
+ assertEquals("aaa", imprt.getPrefix());
+ }
+ } finally {
+ testProject.dispose();
+ }
+ }
+
+ /**
+ * Test for {@link DartImport}.
+ */
+ public void test_DartImport_onPrefixUsage_inFunctionReference() throws Exception {
+ TestProject testProject = new TestProject("Test");
+ try {
+ IResource libResourceA = testProject.setUnitContent(
+ "LibA.dart",
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "#library('libA');",
+ "f() {}",
+ "")).getResource();
+ IResource resourceTest = testProject.setUnitContent(
+ "TestC.dart",
+ Joiner.on("\n").join(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "#library('Test');",
+ "#import('LibA.dart', prefix: 'aaa');",
+ "f() {",
+ " aaa.f();",
+ "}",
+ "")).getResource();
+ TestProject.waitForAutoBuild();
+ DartLibrary libraryA = testProject.getDartProject().getDartLibrary(libResourceA);
+ DartLibrary libraryTest = testProject.getDartProject().getDartLibrary(resourceTest);
+ // usage of "aaa" = "libraryA"
+ {
+ DartImport imprt = assertLocation(
+ libraryTest.getDefiningCompilationUnit(),
+ "aaa.f();",
+ DartImport.class,
+ "'aaa');",
+ 5);
+ assertEquals(libraryA, imprt.getLibrary());
+ assertEquals("aaa", imprt.getPrefix());
+ }
+ } finally {
+ testProject.dispose();
+ }
+ }
+
public void test_DartImport_onURI() throws Exception {
TestProject testProject = new TestProject("Test");
try {

Powered by Google App Engine
This is Rietveld 408576698