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

Unified Diff: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java

Issue 11312081: Issue 6251. Resolve and rename [id] references in documentation comments (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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: compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
diff --git a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
index 163772111f24531a20948f848a0ad9121bbffb2f..dd9060d16aa84730a51028df929ebf038d062aff 100644
--- a/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
+++ b/compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java
@@ -44,6 +44,7 @@ import com.google.dart.compiler.resolver.MethodElement;
import com.google.dart.compiler.resolver.NodeElement;
import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;
+import com.google.dart.compiler.resolver.VariableElement;
import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
import static com.google.dart.compiler.common.ErrorExpectation.errEx;
@@ -5464,4 +5465,82 @@ public class TypeAnalyzerCompilerTest extends CompilerTestCase {
"");
assertErrors(result.getErrors());
}
+
+ public void test_resolveIdentifierInComment_ofClass() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "/** This class [A] has method [foo]. */",
+ "class A {",
+ " foo() {}",
+ "}",
+ "");
+ assertErrors(result.getErrors());
+ // [A]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "A]");
+ ClassElement element = (ClassElement) identifier.getElement();
+ assertEquals("A", element.getName());
+ }
+ // [foo]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "foo]");
+ MethodElement element = (MethodElement) identifier.getElement();
+ assertEquals("foo", element.getName());
+ }
+ }
+
+ public void test_resolveIdentifierInComment_ofFunction() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {}",
+ "/** This function has parameter [aaa] of type [A] ans also [bbb]. */",
+ "foo(A aaa, bbb) {}",
+ "");
+ assertErrors(result.getErrors());
+ // [aaa]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "aaa]");
+ VariableElement element = (VariableElement) identifier.getElement();
+ assertSame(ElementKind.PARAMETER, ElementKind.of(element));
+ assertEquals("aaa", element.getName());
+ }
+ // [A]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "A]");
+ ClassElement element = (ClassElement) identifier.getElement();
+ assertEquals("A", element.getName());
+ }
+ // [bbb]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "bbb]");
+ VariableElement element = (VariableElement) identifier.getElement();
+ assertSame(ElementKind.PARAMETER, ElementKind.of(element));
+ assertEquals("bbb", element.getName());
+ }
+ }
+
+ public void test_resolveIdentifierInComment_ofMethod() throws Exception {
+ AnalyzeLibraryResult result = analyzeLibrary(
+ "// filler filler filler filler filler filler filler filler filler filler",
+ "class A {",
+ " var fff;",
+ " /** Initializes [fff] and then calls [bar]. */",
+ " foo() {}",
+ " bar() {}",
+ "}",
+ "");
+ assertErrors(result.getErrors());
+ // [fff]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "fff]");
+ FieldElement element = (FieldElement) identifier.getElement();
+ assertEquals("fff", element.getName());
+ }
+ // [bbb]
+ {
+ DartIdentifier identifier = findNode(DartIdentifier.class, "bar]");
+ MethodElement element = (MethodElement) identifier.getElement();
+ assertEquals("bar", element.getName());
+ }
+ }
}

Powered by Google App Engine
This is Rietveld 408576698