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 38ecc4634bbfce4f74c2eed9d7836e776a5b0ba7..332366dadc0105210b5c6f716e810d80707b4ae7 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 |
@@ -4,9 +4,11 @@ |
library test.services.src.index.dart_index_contributor; |
+import 'package:analysis_server/analysis/index/index_core.dart'; |
import 'package:analysis_server/src/services/index/index.dart'; |
import 'package:analysis_server/src/services/index/index_contributor.dart'; |
import 'package:analysis_server/src/services/index/index_store.dart'; |
+import 'package:analysis_server/src/services/index/indexable_element.dart'; |
import 'package:analyzer/src/generated/ast.dart'; |
import 'package:analyzer/src/generated/element.dart'; |
import 'package:analyzer/src/generated/source.dart'; |
@@ -42,9 +44,9 @@ bool _equalsLocationProperties(LocationImpl actual, Element expectedElement, |
} |
bool _equalsRecordedRelation(RecordedRelation recordedRelation, |
- Element expectedElement, RelationshipImpl expectedRelationship, |
+ IndexableObject expectedIndexable, RelationshipImpl expectedRelationship, |
ExpectedLocation expectedLocation) { |
- return expectedElement == recordedRelation.element && |
+ return expectedIndexable == recordedRelation.indexable && |
(expectedRelationship == null || |
expectedRelationship == recordedRelation.relationship) && |
(expectedLocation == null || |
@@ -66,10 +68,10 @@ class DartUnitContributorTest extends AbstractSingleUnitTest { |
super.setUp(); |
when(store.aboutToIndexDart(context, anyObject)).thenReturn(true); |
when(store.recordRelationship(anyObject, anyObject, anyObject)) |
- .thenInvoke((Element element, RelationshipImpl relationship, |
+ .thenInvoke((IndexableObject indexable, RelationshipImpl relationship, |
LocationImpl location) { |
recordedRelations |
- .add(new RecordedRelation(element, relationship, location)); |
+ .add(new RecordedRelation(indexable, relationship, location)); |
}); |
when(store.recordTopLevelDeclaration(anyObject)) |
.thenInvoke((Element element) { |
@@ -137,8 +139,8 @@ main() { |
Element mainElement = findElement("main"); |
VariableElement variableElement = findElement("v"); |
// verify |
- _assertNoRecordedRelation(variableElement, IndexConstants.IS_READ_BY, |
- _expectedLocation(mainElement, 'v in []')); |
+ _assertNoRecordedRelation(new IndexableElement(variableElement), |
scheglov
2015/05/25 18:29:33
Ouch...
Doing new IndexableElement(element) everyw
Brian Wilkerson
2015/06/01 13:20:08
Done.
|
+ IndexConstants.IS_READ_BY, _expectedLocation(mainElement, 'v in []')); |
} |
void test_isDefinedBy_NameElement_method() { |
@@ -150,7 +152,8 @@ class A { |
Element methodElement = findElement("m"); |
Element nameElement = new NameElement("m"); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.NAME_IS_DEFINED_BY, |
+ _assertRecordedRelation(new IndexableElement(nameElement), |
+ IndexConstants.NAME_IS_DEFINED_BY, |
_expectedLocation(methodElement, 'm() {}')); |
} |
@@ -163,7 +166,8 @@ class A { |
Element methodElement = findElement("+"); |
Element nameElement = new NameElement("+"); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.NAME_IS_DEFINED_BY, |
+ _assertRecordedRelation(new IndexableElement(nameElement), |
+ IndexConstants.NAME_IS_DEFINED_BY, |
_expectedLocation(methodElement, '+(o) {}', length: 1)); |
} |
@@ -176,7 +180,8 @@ class B extends A {} // 2 |
ClassElement classElementA = findElement("A"); |
ClassElement classElementB = findElement("B"); |
// verify |
- _assertRecordedRelation(classElementA, IndexConstants.IS_EXTENDED_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementA), |
+ IndexConstants.IS_EXTENDED_BY, |
_expectedLocation(classElementB, 'A {} // 2')); |
} |
@@ -188,7 +193,8 @@ class A {} // 1 |
ClassElement classElementA = findElement("A"); |
ClassElement classElementObject = classElementA.supertype.element; |
// verify |
- _assertRecordedRelation(classElementObject, IndexConstants.IS_EXTENDED_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementObject), |
+ IndexConstants.IS_EXTENDED_BY, |
_expectedLocation(classElementA, 'A {}', length: 0)); |
} |
@@ -202,7 +208,8 @@ class C = A with B; // 3 |
ClassElement classElementA = findElement("A"); |
ClassElement classElementC = findElement("C"); |
// verify |
- _assertRecordedRelation(classElementA, IndexConstants.IS_EXTENDED_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementA), |
+ IndexConstants.IS_EXTENDED_BY, |
_expectedLocation(classElementC, 'A with')); |
} |
@@ -215,7 +222,8 @@ class B implements A {} // 2 |
ClassElement classElementA = findElement("A"); |
ClassElement classElementB = findElement("B"); |
// verify |
- _assertRecordedRelation(classElementA, IndexConstants.IS_IMPLEMENTED_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementA), |
+ IndexConstants.IS_IMPLEMENTED_BY, |
_expectedLocation(classElementB, 'A {} // 2')); |
} |
@@ -229,7 +237,8 @@ class C = Object with A implements B; // 3 |
ClassElement classElementB = findElement("B"); |
ClassElement classElementC = findElement("C"); |
// verify |
- _assertRecordedRelation(classElementB, IndexConstants.IS_IMPLEMENTED_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementB), |
+ IndexConstants.IS_IMPLEMENTED_BY, |
_expectedLocation(classElementC, 'B; // 3')); |
} |
@@ -246,10 +255,11 @@ class A { |
Element mainElement = findElement("main"); |
FieldElement fieldElement = findElement("field"); |
PropertyAccessorElement getterElement = fieldElement.getter; |
+ IndexableElement indexable = new IndexableElement(getterElement); |
// verify |
- _assertRecordedRelation(getterElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, 'field(); // q')); |
- _assertRecordedRelation(getterElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocation(mainElement, 'field(); // nq')); |
} |
@@ -268,10 +278,11 @@ main() { |
// prepare elements |
Element mainElement = findElement("main"); |
FunctionElement functionElement = importedUnit().functions[0]; |
+ IndexableElement indexable = new IndexableElement(functionElement); |
// verify |
- _assertRecordedRelation(functionElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocation(mainElement, 'foo(); // q')); |
- _assertRecordedRelation(functionElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocation(mainElement, 'foo(); // nq')); |
} |
@@ -285,8 +296,8 @@ main() { |
Element mainElement = findElement("main"); |
Element element = findElement("v"); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
- _expectedLocation(mainElement, 'v();')); |
+ _assertRecordedRelation(new IndexableElement(element), |
+ IndexConstants.IS_INVOKED_BY, _expectedLocation(mainElement, 'v();')); |
} |
void test_isInvokedBy_MethodElement() { |
@@ -301,10 +312,11 @@ class A { |
// prepare elements |
Element mainElement = findElement("main"); |
Element methodElement = findElement("foo"); |
+ IndexableElement indexable = new IndexableElement(methodElement); |
// verify |
- _assertRecordedRelation(methodElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, 'foo(); // q')); |
- _assertRecordedRelation(methodElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocation(mainElement, 'foo(); // nq')); |
} |
@@ -322,7 +334,8 @@ main() { |
Element mainElement = findElement("main"); |
Element methodElement = findElement("foo"); |
// verify |
- _assertRecordedRelation(methodElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(methodElement), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, 'foo();')); |
} |
@@ -341,14 +354,15 @@ main(A a) { |
// prepare elements |
MethodElement element = findElement('+'); |
Element mainElement = findElement('main'); |
+ IndexableElement indexable = new IndexableElement(element); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '+ 1', length: 1)); |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '+= 2', length: 2)); |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '++a;', length: 2)); |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '++;', length: 2)); |
} |
@@ -368,9 +382,11 @@ main(A a) { |
MethodElement writeElement = findElement("[]="); |
Element mainElement = findElement('main'); |
// verify |
- _assertRecordedRelation(readElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(readElement), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '[0]', length: 1)); |
- _assertRecordedRelation(writeElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(writeElement), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '[1] =', length: 1)); |
} |
@@ -387,7 +403,8 @@ main(A a) { |
MethodElement element = findElement("~"); |
Element mainElement = findElement('main'); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(element), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '~a', length: 1)); |
} |
@@ -400,8 +417,8 @@ main(p()) { |
Element mainElement = findElement("main"); |
Element element = findElement("p"); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
- _expectedLocation(mainElement, 'p();')); |
+ _assertRecordedRelation(new IndexableElement(element), |
+ IndexConstants.IS_INVOKED_BY, _expectedLocation(mainElement, 'p();')); |
} |
void test_isMixedInBy_ClassDeclaration() { |
@@ -413,7 +430,8 @@ class B extends Object with A {} // 2 |
ClassElement classElementA = findElement("A"); |
ClassElement classElementB = findElement("B"); |
// verify |
- _assertRecordedRelation(classElementA, IndexConstants.IS_MIXED_IN_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementA), |
+ IndexConstants.IS_MIXED_IN_BY, |
_expectedLocation(classElementB, 'A {} // 2')); |
} |
@@ -426,7 +444,8 @@ class B = Object with A; // 2 |
ClassElement classElementA = findElement("A"); |
ClassElement classElementB = findElement("B"); |
// verify |
- _assertRecordedRelation(classElementA, IndexConstants.IS_MIXED_IN_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementA), |
+ IndexConstants.IS_MIXED_IN_BY, |
_expectedLocation(classElementB, 'A; // 2')); |
} |
@@ -440,8 +459,8 @@ main(var p) { |
Element mainElement = findElement("main"); |
Element parameterElement = findElement("p"); |
// verify |
- _assertRecordedRelation(parameterElement, IndexConstants.IS_READ_BY, |
- _expectedLocation(mainElement, 'p);')); |
+ _assertRecordedRelation(new IndexableElement(parameterElement), |
+ IndexConstants.IS_READ_BY, _expectedLocation(mainElement, 'p);')); |
} |
void test_isReadBy_VariableElement() { |
@@ -455,8 +474,8 @@ main() { |
Element mainElement = findElement("main"); |
Element variableElement = findElement("v"); |
// verify |
- _assertRecordedRelation(variableElement, IndexConstants.IS_READ_BY, |
- _expectedLocation(mainElement, 'v);')); |
+ _assertRecordedRelation(new IndexableElement(variableElement), |
+ IndexConstants.IS_READ_BY, _expectedLocation(mainElement, 'v);')); |
} |
void test_isReadWrittenBy_ParameterElement() { |
@@ -469,7 +488,8 @@ main(int p) { |
Element mainElement = findElement("main"); |
Element parameterElement = findElement("p"); |
// verify |
- _assertRecordedRelation(parameterElement, IndexConstants.IS_READ_WRITTEN_BY, |
+ _assertRecordedRelation(new IndexableElement(parameterElement), |
+ IndexConstants.IS_READ_WRITTEN_BY, |
_expectedLocation(mainElement, 'p += 1')); |
} |
@@ -484,7 +504,8 @@ main() { |
Element mainElement = findElement("main"); |
Element variableElement = findElement("v"); |
// verify |
- _assertRecordedRelation(variableElement, IndexConstants.IS_READ_WRITTEN_BY, |
+ _assertRecordedRelation(new IndexableElement(variableElement), |
+ IndexConstants.IS_READ_WRITTEN_BY, |
_expectedLocation(mainElement, 'v += 1')); |
} |
@@ -505,16 +526,17 @@ main(A p) { |
Element mainElement = findElement("main"); |
ParameterElement pElement = findElement("p"); |
VariableElement vElement = findElement("v"); |
+ IndexableElement indexable = new IndexableElement(aElement); |
// verify |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(pElement, 'A p) {')); |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(vElement, 'A v;')); |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'A(); // 2')); |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'A.field = 1;')); |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'A.field); // 3')); |
} |
@@ -530,10 +552,11 @@ main(B p) { |
ClassElement bElement = findElement("B"); |
ParameterElement pElement = findElement("p"); |
VariableElement vElement = findElement("v"); |
+ IndexableElement indexable = new IndexableElement(bElement); |
// verify |
- _assertRecordedRelation(bElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(pElement, 'B p) {')); |
- _assertRecordedRelation(bElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(vElement, 'B v;')); |
} |
@@ -548,7 +571,8 @@ export 'lib.dart'; |
LibraryElement libElement = testLibraryElement.exportedLibraries[0]; |
CompilationUnitElement libUnitElement = libElement.definingCompilationUnit; |
// verify |
- _assertRecordedRelation(libUnitElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(libUnitElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, "'lib.dart'", length: 10)); |
} |
@@ -563,7 +587,8 @@ import 'lib.dart'; |
LibraryElement libElement = testLibraryElement.imports[0].importedLibrary; |
CompilationUnitElement libUnitElement = libElement.definingCompilationUnit; |
// verify |
- _assertRecordedRelation(libUnitElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(libUnitElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, "'lib.dart'", length: 10)); |
} |
@@ -576,7 +601,8 @@ part 'my_unit.dart'; |
// prepare elements |
CompilationUnitElement myUnitElement = testLibraryElement.parts[0]; |
// verify |
- _assertRecordedRelation(myUnitElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(myUnitElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, "'my_unit.dart';", length: 14)); |
} |
@@ -607,17 +633,19 @@ main() { |
findNodeElementAtString("B.foo()", isConstructor); |
ConstructorElement consB_bar = |
findNodeElementAtString("B.bar()", isConstructor); |
+ IndexableElement indexableA = new IndexableElement(consA); |
+ IndexableElement indexableA_foo = new IndexableElement(consA_foo); |
// A() |
- _assertRecordedRelation(consA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableA, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(consB, '(); // marker-1', length: 0)); |
- _assertRecordedRelation(consA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableA, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, '(); // marker-main-1', length: 0)); |
// A.foo() |
- _assertRecordedRelation(consA_foo, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableA_foo, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(consB_foo, '.foo(); // marker-2', length: 4)); |
- _assertRecordedRelation(consA_foo, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableA_foo, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(consB_bar, '.foo; // marker-3', length: 4)); |
- _assertRecordedRelation(consA_foo, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableA_foo, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, '.foo(); // marker-main-2', length: 4)); |
} |
@@ -641,11 +669,12 @@ main() { |
ConstructorElement consA_named = |
findNodeElementAtString("A.named()", isConstructor); |
// verify |
- _assertRecordedRelation(consA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(consA), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, '(); // marker-main-1', length: 0)); |
- _assertRecordedRelation(consA_named, IndexConstants.IS_REFERENCED_BY, |
- _expectedLocation(mainElement, '.named(); // marker-main-2', |
- length: 6)); |
+ _assertRecordedRelation(new IndexableElement(consA_named), |
+ IndexConstants.IS_REFERENCED_BY, _expectedLocation( |
+ mainElement, '.named(); // marker-main-2', length: 6)); |
} |
void test_isReferencedBy_ConstructorElement_redirection() { |
@@ -665,10 +694,12 @@ class A { |
ConstructorElement constructorA_bar = |
findNodeElementAtString("A.bar()", isConstructor); |
// A() |
- _assertRecordedRelation(constructorA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(constructorA), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(constructorA_foo, '(); // marker', length: 0)); |
// A.foo() |
- _assertRecordedRelation(constructorA_bar, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(constructorA_bar), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(constructorA, '.bar();', length: 4)); |
} |
@@ -694,17 +725,20 @@ main(A a) { |
FieldElement fieldElement = findElement("field"); |
PropertyAccessorElement getter = fieldElement.getter; |
PropertyAccessorElement setter = fieldElement.setter; |
+ IndexableElement indexableGetter = new IndexableElement(getter); |
+ IndexableElement indexableSetter = new IndexableElement(setter); |
// m() |
- _assertRecordedRelation(setter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableSetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mElement, 'field = 1; // nq')); |
- _assertRecordedRelation(getter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableGetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mElement, 'field); // nq')); |
// main() |
- _assertRecordedRelation(setter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableSetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocationQ(mainElement, 'field = 2; // q')); |
- _assertRecordedRelation(getter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableGetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocationQ(mainElement, 'field); // q')); |
- _assertRecordedRelation(fieldElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(fieldElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'field: 3')); |
} |
@@ -719,14 +753,15 @@ main() { |
// prepare elements |
FunctionElement element = findElement("foo"); |
Element mainElement = findElement("main"); |
+ IndexableElement indexable = new IndexableElement(element); |
// "referenced" here |
- _assertRecordedRelation(element, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'foo);')); |
// only "invoked", but not "referenced" |
{ |
- _assertRecordedRelation(element, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocation(mainElement, 'foo());')); |
- _assertNoRecordedRelation(element, IndexConstants.IS_REFERENCED_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'foo());')); |
} |
} |
@@ -741,8 +776,8 @@ main(A p) { |
Element aElement = findElement('A'); |
Element pElement = findElement('p'); |
// verify |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
- _expectedLocation(pElement, 'A p) {')); |
+ _assertRecordedRelation(new IndexableElement(aElement), |
+ IndexConstants.IS_REFERENCED_BY, _expectedLocation(pElement, 'A p) {')); |
} |
/** |
@@ -761,10 +796,11 @@ var myVariable = null; |
// prepare elements |
Element aElement = findElement('A'); |
Element variableElement = findElement('myVariable'); |
+ IndexableElement indexable = new IndexableElement(aElement); |
// verify |
- _assertRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, 'A] text')); |
- _assertNoRecordedRelation(aElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(variableElement, 'A] text')); |
} |
@@ -786,19 +822,20 @@ main() { |
// prepare elements |
ImportElement importElement = testLibraryElement.imports[0]; |
Element mainElement = findElement('main'); |
+ IndexableElement indexable = new IndexableElement(importElement); |
// verify |
- _assertRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'myVar = 1;', length: 0)); |
- _assertRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'myFunction();', length: 0)); |
- _assertNoRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'print(0);', length: 0)); |
// no references from import combinators |
- _assertNoRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, 'myVar, ', length: 0)); |
- _assertNoRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, 'myFunction hide', length: 0)); |
- _assertNoRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, 'myToHide;', length: 0)); |
} |
@@ -824,9 +861,11 @@ main() { |
ImportElement importElementB = testLibraryElement.imports[1]; |
Element mainElement = findElement('main'); |
// verify |
- _assertRecordedRelation(importElementA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(importElementA), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'pref.myVar = 1;', length: 5)); |
- _assertRecordedRelation(importElementB, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(importElementB), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'pref.MyClass();', length: 5)); |
} |
@@ -851,9 +890,11 @@ main() { |
ImportElement importElementB = testLibraryElement.imports[1]; |
Element mainElement = findElement('main'); |
// verify |
- _assertRecordedRelation(importElementA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(importElementA), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'pref.A();', length: 5)); |
- _assertRecordedRelation(importElementB, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(importElementB), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'pref.B();', length: 5)); |
} |
@@ -872,7 +913,8 @@ main() { |
ImportElement importElement = testLibraryElement.imports[0]; |
Element mainElement = findElement('main'); |
// verify |
- _assertRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(importElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'pref.myFunc();', length: 5)); |
} |
@@ -892,7 +934,8 @@ main() { |
ImportElement importElement = testLibraryElement.imports[0]; |
Element mainElement = findElement('main'); |
// verify |
- _assertRecordedRelation(importElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(importElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'pref.A();', length: 5)); |
} |
@@ -940,8 +983,8 @@ main() { |
Element mainElement = findElement('main'); |
Element element = findElement('L'); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_REFERENCED_BY, |
- _expectedLocation(mainElement, 'L;')); |
+ _assertRecordedRelation(new IndexableElement(element), |
+ IndexConstants.IS_REFERENCED_BY, _expectedLocation(mainElement, 'L;')); |
} |
void test_isReferencedBy_libraryName() { |
@@ -956,7 +999,8 @@ part 'test.dart'; |
testLibraryElement = testUnitElement.library; |
indexDartUnit(store, context, testUnit); |
// verify |
- _assertRecordedRelation(testLibraryElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(testLibraryElement), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, "lib;")); |
} |
@@ -972,10 +1016,11 @@ class A { |
// prepare elements |
Element mainElement = findElement("main"); |
MethodElement methodElement = findElement("method"); |
+ IndexableElement indexable = new IndexableElement(methodElement); |
// verify |
- _assertRecordedRelation(methodElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocationQ(mainElement, 'method); // q')); |
- _assertRecordedRelation(methodElement, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'method); // nq')); |
} |
@@ -990,7 +1035,8 @@ main() { |
Element mainElement = findElement('main'); |
Element element = findElement('p'); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(element), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'p: 1')); |
} |
@@ -1006,12 +1052,13 @@ main() { |
PrefixElement element = findNodeElementAtString('ppp;'); |
Element elementA = findElement('a'); |
Element elementB = findElement('b'); |
+ IndexableElement indexable = new IndexableElement(element); |
// verify |
- _assertRecordedRelation(element, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(elementA, 'ppp.Future')); |
- _assertRecordedRelation(element, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(elementB, 'ppp.Stream')); |
- _assertNoRecordedRelation(element, null, _expectedLocation(null, 'ppp;')); |
+ _assertNoRecordedRelation(indexable, null, _expectedLocation(null, 'ppp;')); |
} |
void test_isReferencedBy_TopLevelVariableElement() { |
@@ -1031,16 +1078,19 @@ main() { |
// prepare elements |
TopLevelVariableElement variable = importedUnit().topLevelVariables[0]; |
Element mainElement = findElement("main"); |
+ IndexableElement indexableGetter = new IndexableElement(variable.getter); |
+ IndexableElement indexableSetter = new IndexableElement(variable.setter); |
// verify |
- _assertRecordedRelation(variable, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(variable), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(testUnitElement, 'V; // imp')); |
- _assertRecordedRelation(variable.setter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableSetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'V = 5; // q')); |
- _assertRecordedRelation(variable.getter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableGetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'V); // q')); |
- _assertRecordedRelation(variable.setter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableSetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'V = 5; // nq')); |
- _assertRecordedRelation(variable.getter, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexableGetter, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(mainElement, 'V); // nq')); |
} |
@@ -1053,7 +1103,8 @@ A myVariable = null; |
Element classElementA = findElement('A'); |
Element variableElement = findElement('myVariable'); |
// verify |
- _assertRecordedRelation(classElementA, IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(new IndexableElement(classElementA), |
+ IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(variableElement, 'A myVariable')); |
} |
@@ -1071,15 +1122,13 @@ class A<T> { |
Element fieldElement = findElement('f'); |
Element parameterElement = findElement('p'); |
Element variableElement = findElement('v'); |
+ IndexableElement indexable = new IndexableElement(typeParameterElement); |
// verify |
- _assertRecordedRelation(typeParameterElement, |
- IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(fieldElement, 'T f')); |
- _assertRecordedRelation(typeParameterElement, |
- IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(parameterElement, 'T p')); |
- _assertRecordedRelation(typeParameterElement, |
- IndexConstants.IS_REFERENCED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_REFERENCED_BY, |
_expectedLocation(variableElement, 'T v')); |
} |
@@ -1095,7 +1144,8 @@ class A { |
ConstructorElement constructorElement = classElement.constructors[0]; |
FieldElement fieldElement = findElement("field"); |
// verify |
- _assertRecordedRelation(fieldElement, IndexConstants.IS_WRITTEN_BY, |
+ _assertRecordedRelation(new IndexableElement(fieldElement), |
+ IndexConstants.IS_WRITTEN_BY, |
_expectedLocation(constructorElement, 'field = 5')); |
} |
@@ -1110,7 +1160,8 @@ class A { |
FieldElement fieldElement = findElement("field"); |
Element fieldParameterElement = findNodeElementAtString("field);"); |
// verify |
- _assertRecordedRelation(fieldElement, IndexConstants.IS_WRITTEN_BY, |
+ _assertRecordedRelation(new IndexableElement(fieldElement), |
+ IndexConstants.IS_WRITTEN_BY, |
_expectedLocation(fieldParameterElement, 'field);')); |
} |
@@ -1123,8 +1174,8 @@ main(var p) { |
Element mainElement = findElement("main"); |
ParameterElement pElement = findElement("p"); |
// verify |
- _assertRecordedRelation(pElement, IndexConstants.IS_WRITTEN_BY, |
- _expectedLocation(mainElement, 'p = 1')); |
+ _assertRecordedRelation(new IndexableElement(pElement), |
+ IndexConstants.IS_WRITTEN_BY, _expectedLocation(mainElement, 'p = 1')); |
} |
void test_isWrittenBy_VariableElement() { |
@@ -1137,8 +1188,8 @@ main() { |
Element mainElement = findElement("main"); |
LocalVariableElement vElement = findElement("v"); |
// verify |
- _assertRecordedRelation(vElement, IndexConstants.IS_WRITTEN_BY, |
- _expectedLocation(mainElement, 'v = 1')); |
+ _assertRecordedRelation(new IndexableElement(vElement), |
+ IndexConstants.IS_WRITTEN_BY, _expectedLocation(mainElement, 'v = 1')); |
} |
void test_NameElement_field() { |
@@ -1158,15 +1209,15 @@ main(A a, p) { |
// prepare elements |
Element mainElement = findElement('main'); |
FieldElement fieldElement = findElement('field'); |
- Element nameElement = new NameElement('field'); |
+ IndexableElement indexable = new IndexableElement(new NameElement('field')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.NAME_IS_DEFINED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.NAME_IS_DEFINED_BY, |
_expectedLocation(fieldElement, 'field;')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_READ_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_READ_BY, |
_expectedLocationQ(mainElement, 'field); // r')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_READ_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_READ_BY, |
_expectedLocationQU(mainElement, 'field); // ur')); |
- _assertNoRecordedRelation(nameElement, IndexConstants.IS_READ_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_READ_BY, |
_expectedLocation(mainElement, 'field); // not a member')); |
} |
@@ -1181,9 +1232,9 @@ class A { |
'''); |
// prepare elements |
LocalVariableElement testElement = findElement('test'); |
- Element nameElement = new NameElement('test'); |
+ IndexableElement indexable = new IndexableElement(new NameElement('test')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.NAME_IS_DEFINED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.NAME_IS_DEFINED_BY, |
_expectedLocation(testElement, 'test in []')); |
} |
@@ -1200,13 +1251,14 @@ main(A a, p) { |
// prepare elements |
Element mainElement = findElement('main'); |
MethodElement methodElement = findElement('method'); |
- Element nameElement = new NameElement('method'); |
+ IndexableElement indexable = |
+ new IndexableElement(new NameElement('method')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.NAME_IS_DEFINED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.NAME_IS_DEFINED_BY, |
_expectedLocation(methodElement, 'method() {}')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, 'method(); // r')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, 'method(); // ur')); |
} |
@@ -1232,23 +1284,31 @@ main(A a) { |
// prepare elements |
Element mainElement = findElement('main'); |
// binary |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '+ 5', length: 1)); |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '+= 5', length: 2)); |
- _assertRecordedRelation(new NameElement('=='), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('==')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '== 5', length: 2)); |
// prefix |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '++a', length: 2)); |
- _assertRecordedRelation(new NameElement('-'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('-')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '--a', length: 2)); |
- _assertRecordedRelation(new NameElement('~'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('~')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '~a', length: 1)); |
// postfix |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '++;', length: 2)); |
- _assertRecordedRelation(new NameElement('-'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('-')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, '--;', length: 2)); |
} |
@@ -1274,23 +1334,31 @@ main(a) { |
// prepare elements |
Element mainElement = findElement('main'); |
// binary |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '+ 5', length: 1)); |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '+= 5', length: 2)); |
- _assertRecordedRelation(new NameElement('=='), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('==')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '== 5', length: 2)); |
// prefix |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '++a', length: 2)); |
- _assertRecordedRelation(new NameElement('-'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('-')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '--a', length: 2)); |
- _assertRecordedRelation(new NameElement('~'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('~')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '~a', length: 1)); |
// postfix |
- _assertRecordedRelation(new NameElement('+'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('+')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '++;', length: 2)); |
- _assertRecordedRelation(new NameElement('-'), IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(new IndexableElement(new NameElement('-')), |
+ IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, '--;', length: 2)); |
} |
@@ -1305,13 +1373,13 @@ main(A a, p) { |
}'''); |
// prepare elements |
Element mainElement = findElement("main"); |
- Element nameElement = new NameElement('test'); |
+ IndexableElement indexable = new IndexableElement(new NameElement('test')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQ(mainElement, 'test(1)')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_INVOKED_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_INVOKED_BY, |
_expectedLocationQU(mainElement, 'test(2)')); |
- _assertNoRecordedRelation(nameElement, IndexConstants.IS_READ_BY, |
+ _assertNoRecordedRelation(indexable, IndexConstants.IS_READ_BY, |
_expectedLocationQU(mainElement, 'test(2)')); |
} |
@@ -1326,11 +1394,11 @@ main(A a, p) { |
}'''); |
// prepare elements |
Element mainElement = findElement("main"); |
- Element nameElement = new NameElement('test'); |
+ IndexableElement indexable = new IndexableElement(new NameElement('test')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.IS_READ_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_READ_BY, |
_expectedLocationQ(mainElement, 'test); // a')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_READ_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_READ_BY, |
_expectedLocationQU(mainElement, 'test); // p')); |
} |
@@ -1345,11 +1413,11 @@ main(A a, p) { |
}'''); |
// prepare elements |
Element mainElement = findElement("main"); |
- Element nameElement = new NameElement('test'); |
+ IndexableElement indexable = new IndexableElement(new NameElement('test')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.IS_READ_WRITTEN_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_READ_WRITTEN_BY, |
_expectedLocationQ(mainElement, 'test += 1')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_READ_WRITTEN_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_READ_WRITTEN_BY, |
_expectedLocationQU(mainElement, 'test += 2')); |
} |
@@ -1364,11 +1432,11 @@ main(A a, p) { |
}'''); |
// prepare elements |
Element mainElement = findElement("main"); |
- Element nameElement = new NameElement('test'); |
+ IndexableElement indexable = new IndexableElement(new NameElement('test')); |
// verify |
- _assertRecordedRelation(nameElement, IndexConstants.IS_WRITTEN_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_WRITTEN_BY, |
_expectedLocationQ(mainElement, 'test = 1')); |
- _assertRecordedRelation(nameElement, IndexConstants.IS_WRITTEN_BY, |
+ _assertRecordedRelation(indexable, IndexConstants.IS_WRITTEN_BY, |
_expectedLocationQU(mainElement, 'test = 2')); |
} |
@@ -1384,19 +1452,19 @@ main(A a, p) { |
void _assertDefinesTopLevelElement(Element element) { |
ExpectedLocation location = new ExpectedLocation( |
element, element.nameOffset, element.name.length, false, true); |
- _assertRecordedRelation( |
- testLibraryElement, IndexConstants.DEFINES, location); |
+ _assertRecordedRelation(new IndexableElement(testLibraryElement), |
+ IndexConstants.DEFINES, location); |
expect(recordedTopElements, contains(element)); |
} |
/** |
* Asserts that [recordedRelations] has no item with the specified properties. |
*/ |
- void _assertNoRecordedRelation(Element element, RelationshipImpl relationship, |
- ExpectedLocation location) { |
+ void _assertNoRecordedRelation(IndexableObject expectedIndexable, |
+ RelationshipImpl relationship, ExpectedLocation location) { |
for (RecordedRelation recordedRelation in recordedRelations) { |
if (_equalsRecordedRelation( |
- recordedRelation, element, relationship, location)) { |
+ recordedRelation, expectedIndexable, relationship, location)) { |
fail('not expected: ${recordedRelation} in\n' + |
recordedRelations.join('\n')); |
} |
@@ -1406,17 +1474,17 @@ main(A a, p) { |
/** |
* Asserts that [recordedRelations] has an item with the expected properties. |
*/ |
- LocationImpl _assertRecordedRelation(Element expectedElement, |
+ LocationImpl _assertRecordedRelation(IndexableObject expectedIndexable, |
RelationshipImpl expectedRelationship, |
ExpectedLocation expectedLocation) { |
for (RecordedRelation recordedRelation in recordedRelations) { |
- if (_equalsRecordedRelation(recordedRelation, expectedElement, |
+ if (_equalsRecordedRelation(recordedRelation, expectedIndexable, |
expectedRelationship, expectedLocation)) { |
return recordedRelation.location; |
} |
} |
fail( |
- "not found\n$expectedElement $expectedRelationship " "in $expectedLocation in\n" + |
+ "not found\n$expectedIndexable $expectedRelationship " "in $expectedLocation in\n" + |
recordedRelations.join('\n')); |
return null; |
} |
@@ -1474,15 +1542,15 @@ class MockIndexStore extends TypedMock implements InternalIndexStore { |
* Information about a relation recorded into {@link IndexStore}. |
*/ |
class RecordedRelation { |
- final Element element; |
+ final IndexableObject indexable; |
final RelationshipImpl relationship; |
final LocationImpl location; |
- RecordedRelation(this.element, this.relationship, this.location); |
+ RecordedRelation(this.indexable, this.relationship, this.location); |
@override |
String toString() { |
- return 'RecordedRelation(element=$element; relationship=$relationship; ' |
+ return 'RecordedRelation(indexable=$indexable; relationship=$relationship; ' |
'location=$location; flags=' '${location.isQualified ? "Q" : ""}' |
'${location.isResolved ? "R" : ""})'; |
} |