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

Unified Diff: pkg/analysis_server/test/services/index/dart_index_contributor_test.dart

Issue 1371463002: Record HAS_ANCESTOR relations into index. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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: pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart b/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
index 4cfd8cdcf3a3f54b076a8efefed418b53f768ef4..a23f0ef9f6a2bf709b0face2cad39b531e345926 100644
--- a/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
+++ b/pkg/analysis_server/test/services/index/dart_index_contributor_test.dart
@@ -161,6 +161,84 @@ main() {
IndexConstants.IS_READ_BY, _expectedLocation(mainElement, 'v in []'));
}
+ void test_hasAncestor_ClassDeclaration() {
+ _indexTestUnit('''
+class A {}
+class B1 extends A {}
+class B2 implements A {}
+class C1 extends B1 {}
+class C2 extends B2 {}
+class C3 implements B1 {}
+class C4 implements B2 {}
+class M extends Object with A {}
+''');
+ // prepare elements
+ ClassElement classElementA = findElement("A");
+ ClassElement classElementB1 = findElement("B1");
+ ClassElement classElementB2 = findElement("B2");
+ ClassElement classElementC1 = findElement("C1");
+ ClassElement classElementC2 = findElement("C2");
+ ClassElement classElementC3 = findElement("C3");
+ ClassElement classElementC4 = findElement("C4");
+ ClassElement classElementM = findElement("M");
+ // verify
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementB1, 'B1 extends A'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementB2, 'B2 implements A'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC1, 'C1 extends B1'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC2, 'C2 extends B2'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC3, 'C3 implements B1'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC4, 'C4 implements B2'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementM, 'M extends Object with A'));
+ }
+
+ void test_hasAncestor_ClassTypeAlias() {
+ _indexTestUnit('''
+class A {}
+class B extends A {}
+class C1 = Object with A;
+class C2 = Object with B;
+''');
+ // prepare elements
+ ClassElement classElementA = findElement("A");
+ ClassElement classElementB = findElement("B");
+ ClassElement classElementC1 = findElement("C1");
+ ClassElement classElementC2 = findElement("C2");
+ // verify
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC1, 'C1 = Object with A'));
+ _assertRecordedRelationForElement(
+ classElementA,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC2, 'C2 = Object with B'));
+ _assertRecordedRelationForElement(
+ classElementB,
+ IndexConstants.HAS_ANCESTOR,
+ _expectedLocation(classElementC2, 'C2 = Object with B'));
+ }
+
void test_IndexableName_field() {
_indexTestUnit('''
class A {

Powered by Google App Engine
This is Rietveld 408576698