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

Unified Diff: pkg/analyzer/test/src/summary/index_unit_test.dart

Issue 1779233002: Fix for indexing synthetic elements. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/summary/index_unit_test.dart
diff --git a/pkg/analyzer/test/src/summary/index_unit_test.dart b/pkg/analyzer/test/src/summary/index_unit_test.dart
index 83da4c2169327853d8f95806a198e797e81ecaeb..1aedae8c7219dca5efedc349f2770706ccfa871d 100644
--- a/pkg/analyzer/test/src/summary/index_unit_test.dart
+++ b/pkg/analyzer/test/src/summary/index_unit_test.dart
@@ -392,6 +392,21 @@ main(A a) {
assertThat(element).isInvokedAt('~a', true, length: 1);
}
+ void test_isInvokedBy_PropertyAccessorElement_getter() {
+ _indexTestUnit('''
+class A {
+ get ggg => null;
+ main() {
+ this.ggg(); // q
+ ggg(); // nq
+ }
+}''');
+ PropertyAccessorElement element = findElement('ggg', ElementKind.GETTER);
+ assertThat(element)
+ ..isInvokedAt('ggg(); // q', true)
+ ..isInvokedAt('ggg(); // nq', false);
+ }
+
void test_isMixedInBy_ClassDeclaration() {
_indexTestUnit('''
class A {} // 1
@@ -625,6 +640,19 @@ class A {
assertThat(constA_bar).isReferencedAt('.bar(); // 1', true, length: 4);
}
+ void test_isReferencedBy_ConstructorElement_synthetic() {
+ _indexTestUnit('''
+class A {}
+main() {
+ new A(); // 1
+}
+''');
+ ClassElement classA = findElement('A');
+ ConstructorElement constA = classA.constructors[0];
+ // A()
+ assertThat(constA)..isReferencedAt('(); // 1', true, length: 0);
+ }
+
void test_isReferencedBy_ConstructorFieldInitializer() {
_indexTestUnit('''
class A {
@@ -884,18 +912,13 @@ main(C c) {
*/
int _findElementId(Element element) {
int unitId = _getUnitId(element);
- int offset = element.nameOffset;
- if (element is LibraryElement || element is CompilationUnitElement) {
- offset = 0;
- }
- IndexSyntheticElementKind kind =
- PackageIndexAssembler.getIndexElementKind(element);
+ ElementInfo info = PackageIndexAssembler.newElementInfo(unitId, element);
for (int elementId = 0;
elementId < packageIndex.elementUnits.length;
elementId++) {
if (packageIndex.elementUnits[elementId] == unitId &&
- packageIndex.elementOffsets[elementId] == offset &&
- packageIndex.elementKinds[elementId] == kind) {
+ packageIndex.elementOffsets[elementId] == info.offset &&
+ packageIndex.elementKinds[elementId] == info.kind) {
return elementId;
}
}
« no previous file with comments | « pkg/analyzer/lib/src/summary/index_unit.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698