| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // prepare elements | 157 // prepare elements |
| 158 Element mainElement = findElement("main"); | 158 Element mainElement = findElement("main"); |
| 159 VariableElement variableElement = findElement("v"); | 159 VariableElement variableElement = findElement("v"); |
| 160 // verify | 160 // verify |
| 161 _assertNoRecordedRelation( | 161 _assertNoRecordedRelation( |
| 162 variableElement, | 162 variableElement, |
| 163 IndexConstants.IS_READ_BY, | 163 IndexConstants.IS_READ_BY, |
| 164 _expectedLocation(mainElement, 'v in []')); | 164 _expectedLocation(mainElement, 'v in []')); |
| 165 } | 165 } |
| 166 | 166 |
| 167 void test_isDefinedBy_ConstructorElement() { | |
| 168 _indexTestUnit(''' | |
| 169 class A { | |
| 170 A() {} | |
| 171 A.foo() {} | |
| 172 }'''); | |
| 173 // prepare elements | |
| 174 ClassElement classA = findElement("A"); | |
| 175 ConstructorElement consA = | |
| 176 findNodeElementAtString("A()", (node) => node is ConstructorDeclaration)
; | |
| 177 ConstructorElement consA_foo = | |
| 178 findNodeElementAtString("A.foo()", (node) => node is ConstructorDeclarat
ion); | |
| 179 // verify | |
| 180 _assertRecordedRelation( | |
| 181 consA, | |
| 182 IndexConstants.NAME_IS_DEFINED_BY, | |
| 183 _expectedLocation(classA, '() {}')); | |
| 184 _assertRecordedRelation( | |
| 185 consA_foo, | |
| 186 IndexConstants.NAME_IS_DEFINED_BY, | |
| 187 _expectedLocation(classA, '.foo() {}', length: 4)); | |
| 188 } | |
| 189 | |
| 190 void test_isDefinedBy_NameElement_method() { | 167 void test_isDefinedBy_NameElement_method() { |
| 191 _indexTestUnit(''' | 168 _indexTestUnit(''' |
| 192 class A { | 169 class A { |
| 193 m() {} | 170 m() {} |
| 194 }'''); | 171 }'''); |
| 195 // prepare elements | 172 // prepare elements |
| 196 Element methodElement = findElement("m"); | 173 Element methodElement = findElement("m"); |
| 197 Element nameElement = new NameElement("m"); | 174 Element nameElement = new NameElement("m"); |
| 198 // verify | 175 // verify |
| 199 _assertRecordedRelation( | 176 _assertRecordedRelation( |
| (...skipping 1581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 | 1758 |
| 1782 RecordedRelation(this.element, this.relationship, this.location); | 1759 RecordedRelation(this.element, this.relationship, this.location); |
| 1783 | 1760 |
| 1784 @override | 1761 @override |
| 1785 String toString() { | 1762 String toString() { |
| 1786 return 'RecordedRelation(element=$element; relationship=$relationship; ' | 1763 return 'RecordedRelation(element=$element; relationship=$relationship; ' |
| 1787 'location=$location; flags=' '${location.isQualified ? "Q" : ""}' | 1764 'location=$location; flags=' '${location.isQualified ? "Q" : ""}' |
| 1788 '${location.isResolved ? "R" : ""})'; | 1765 '${location.isResolved ? "R" : ""})'; |
| 1789 } | 1766 } |
| 1790 } | 1767 } |
| OLD | NEW |