| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library test.services.src.index.dart_index_contributor; | 5 library test.services.src.index.dart_index_contributor; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/services/index/index.dart'; | 7 import 'package:analysis_server/src/services/index/index.dart'; |
| 8 import 'package:analysis_server/src/services/index/index_contributor.dart'; | 8 import 'package:analysis_server/src/services/index/index_contributor.dart'; |
| 9 import 'package:analysis_server/src/services/index/index_store.dart'; | 9 import 'package:analysis_server/src/services/index/index_store.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // prepare elements | 287 // prepare elements |
| 288 ClassElement classElementB = findElement("B"); | 288 ClassElement classElementB = findElement("B"); |
| 289 ClassElement classElementC = findElement("C"); | 289 ClassElement classElementC = findElement("C"); |
| 290 // verify | 290 // verify |
| 291 _assertRecordedRelation( | 291 _assertRecordedRelation( |
| 292 classElementB, | 292 classElementB, |
| 293 IndexConstants.IS_IMPLEMENTED_BY, | 293 IndexConstants.IS_IMPLEMENTED_BY, |
| 294 _expectedLocation(classElementC, 'B; // 3')); | 294 _expectedLocation(classElementC, 'B; // 3')); |
| 295 } | 295 } |
| 296 | 296 |
| 297 | |
| 298 void test_isInvokedBy_FieldElement() { | 297 void test_isInvokedBy_FieldElement() { |
| 299 _indexTestUnit(''' | 298 _indexTestUnit(''' |
| 300 class A { | 299 class A { |
| 301 var field; | 300 var field; |
| 302 main() { | 301 main() { |
| 303 this.field(); // q | 302 this.field(); // q |
| 304 field(); // nq | 303 field(); // nq |
| 305 } | 304 } |
| 306 }'''); | 305 }'''); |
| 307 // prepare elements | 306 // prepare elements |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 _assertRecordedRelation( | 780 _assertRecordedRelation( |
| 782 consA, | 781 consA, |
| 783 IndexConstants.IS_REFERENCED_BY, | 782 IndexConstants.IS_REFERENCED_BY, |
| 784 _expectedLocation(mainElement, '(); // marker-main-1', length: 0)); | 783 _expectedLocation(mainElement, '(); // marker-main-1', length: 0)); |
| 785 _assertRecordedRelation( | 784 _assertRecordedRelation( |
| 786 consA_named, | 785 consA_named, |
| 787 IndexConstants.IS_REFERENCED_BY, | 786 IndexConstants.IS_REFERENCED_BY, |
| 788 _expectedLocation(mainElement, '.named(); // marker-main-2', length: 6))
; | 787 _expectedLocation(mainElement, '.named(); // marker-main-2', length: 6))
; |
| 789 } | 788 } |
| 790 | 789 |
| 790 void test_isReferencedBy_ConstructorElement_redirection() { |
| 791 _indexTestUnit(''' |
| 792 class A { |
| 793 A() : this.bar(); |
| 794 A.foo() : this(); // marker |
| 795 A.bar(); |
| 796 } |
| 797 '''); |
| 798 // prepare elements |
| 799 var isConstructor = (node) => node is ConstructorDeclaration; |
| 800 ConstructorElement constructorA = |
| 801 findNodeElementAtString("A()", isConstructor); |
| 802 ConstructorElement constructorA_foo = |
| 803 findNodeElementAtString("A.foo()", isConstructor); |
| 804 ConstructorElement constructorA_bar = |
| 805 findNodeElementAtString("A.bar()", isConstructor); |
| 806 // A() |
| 807 _assertRecordedRelation( |
| 808 constructorA, |
| 809 IndexConstants.IS_REFERENCED_BY, |
| 810 _expectedLocation(constructorA_foo, '(); // marker', length: 0)); |
| 811 // A.foo() |
| 812 _assertRecordedRelation( |
| 813 constructorA_bar, |
| 814 IndexConstants.IS_REFERENCED_BY, |
| 815 _expectedLocation(constructorA, '.bar();', length: 4)); |
| 816 } |
| 817 |
| 791 void test_isReferencedBy_ConstructorFieldInitializer() { | 818 void test_isReferencedBy_ConstructorFieldInitializer() { |
| 792 _indexTestUnit(''' | 819 _indexTestUnit(''' |
| 793 class A { | 820 class A { |
| 794 int field; | 821 int field; |
| 795 A() : field = 5; | 822 A() : field = 5; |
| 796 } | 823 } |
| 797 '''); | 824 '''); |
| 798 // prepare elements | 825 // prepare elements |
| 799 ConstructorElement constructorElement = | 826 ConstructorElement constructorElement = |
| 800 findNodeElementAtString("A()", (node) => node is ConstructorDeclaration)
; | 827 findNodeElementAtString("A()", (node) => node is ConstructorDeclaration)
; |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 | 1781 |
| 1755 RecordedRelation(this.element, this.relationship, this.location); | 1782 RecordedRelation(this.element, this.relationship, this.location); |
| 1756 | 1783 |
| 1757 @override | 1784 @override |
| 1758 String toString() { | 1785 String toString() { |
| 1759 return 'RecordedRelation(element=$element; relationship=$relationship; ' | 1786 return 'RecordedRelation(element=$element; relationship=$relationship; ' |
| 1760 'location=$location; flags=' '${location.isQualified ? "Q" : ""}' | 1787 'location=$location; flags=' '${location.isQualified ? "Q" : ""}' |
| 1761 '${location.isResolved ? "R" : ""})'; | 1788 '${location.isResolved ? "R" : ""})'; |
| 1762 } | 1789 } |
| 1763 } | 1790 } |
| OLD | NEW |