| 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/analysis/index_core.dart'; | 7 import 'package:analysis_server/analysis/index_core.dart'; |
| 8 import 'package:analysis_server/src/services/index/index.dart'; | 8 import 'package:analysis_server/src/services/index/index.dart'; |
| 9 import 'package:analysis_server/src/services/index/index_contributor.dart'; | 9 import 'package:analysis_server/src/services/index/index_contributor.dart'; |
| 10 import 'package:analysis_server/src/services/index/index_store.dart'; | 10 import 'package:analysis_server/src/services/index/index_store.dart'; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 154 } |
| 155 }'''); | 155 }'''); |
| 156 // prepare elements | 156 // prepare elements |
| 157 Element mainElement = findElement("main"); | 157 Element mainElement = findElement("main"); |
| 158 VariableElement variableElement = findElement("v"); | 158 VariableElement variableElement = findElement("v"); |
| 159 // verify | 159 // verify |
| 160 _assertNoRecordedRelationForElement(variableElement, | 160 _assertNoRecordedRelationForElement(variableElement, |
| 161 IndexConstants.IS_READ_BY, _expectedLocation(mainElement, 'v in []')); | 161 IndexConstants.IS_READ_BY, _expectedLocation(mainElement, 'v in []')); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void test_hasAncestor_ClassDeclaration() { |
| 165 _indexTestUnit(''' |
| 166 class A {} |
| 167 class B1 extends A {} |
| 168 class B2 implements A {} |
| 169 class C1 extends B1 {} |
| 170 class C2 extends B2 {} |
| 171 class C3 implements B1 {} |
| 172 class C4 implements B2 {} |
| 173 class M extends Object with A {} |
| 174 '''); |
| 175 // prepare elements |
| 176 ClassElement classElementA = findElement("A"); |
| 177 ClassElement classElementB1 = findElement("B1"); |
| 178 ClassElement classElementB2 = findElement("B2"); |
| 179 ClassElement classElementC1 = findElement("C1"); |
| 180 ClassElement classElementC2 = findElement("C2"); |
| 181 ClassElement classElementC3 = findElement("C3"); |
| 182 ClassElement classElementC4 = findElement("C4"); |
| 183 ClassElement classElementM = findElement("M"); |
| 184 // verify |
| 185 _assertRecordedRelationForElement( |
| 186 classElementA, |
| 187 IndexConstants.HAS_ANCESTOR, |
| 188 _expectedLocation(classElementB1, 'B1 extends A')); |
| 189 _assertRecordedRelationForElement( |
| 190 classElementA, |
| 191 IndexConstants.HAS_ANCESTOR, |
| 192 _expectedLocation(classElementB2, 'B2 implements A')); |
| 193 _assertRecordedRelationForElement( |
| 194 classElementA, |
| 195 IndexConstants.HAS_ANCESTOR, |
| 196 _expectedLocation(classElementC1, 'C1 extends B1')); |
| 197 _assertRecordedRelationForElement( |
| 198 classElementA, |
| 199 IndexConstants.HAS_ANCESTOR, |
| 200 _expectedLocation(classElementC2, 'C2 extends B2')); |
| 201 _assertRecordedRelationForElement( |
| 202 classElementA, |
| 203 IndexConstants.HAS_ANCESTOR, |
| 204 _expectedLocation(classElementC3, 'C3 implements B1')); |
| 205 _assertRecordedRelationForElement( |
| 206 classElementA, |
| 207 IndexConstants.HAS_ANCESTOR, |
| 208 _expectedLocation(classElementC4, 'C4 implements B2')); |
| 209 _assertRecordedRelationForElement( |
| 210 classElementA, |
| 211 IndexConstants.HAS_ANCESTOR, |
| 212 _expectedLocation(classElementM, 'M extends Object with A')); |
| 213 } |
| 214 |
| 215 void test_hasAncestor_ClassTypeAlias() { |
| 216 _indexTestUnit(''' |
| 217 class A {} |
| 218 class B extends A {} |
| 219 class C1 = Object with A; |
| 220 class C2 = Object with B; |
| 221 '''); |
| 222 // prepare elements |
| 223 ClassElement classElementA = findElement("A"); |
| 224 ClassElement classElementB = findElement("B"); |
| 225 ClassElement classElementC1 = findElement("C1"); |
| 226 ClassElement classElementC2 = findElement("C2"); |
| 227 // verify |
| 228 _assertRecordedRelationForElement( |
| 229 classElementA, |
| 230 IndexConstants.HAS_ANCESTOR, |
| 231 _expectedLocation(classElementC1, 'C1 = Object with A')); |
| 232 _assertRecordedRelationForElement( |
| 233 classElementA, |
| 234 IndexConstants.HAS_ANCESTOR, |
| 235 _expectedLocation(classElementC2, 'C2 = Object with B')); |
| 236 _assertRecordedRelationForElement( |
| 237 classElementB, |
| 238 IndexConstants.HAS_ANCESTOR, |
| 239 _expectedLocation(classElementC2, 'C2 = Object with B')); |
| 240 } |
| 241 |
| 164 void test_IndexableName_field() { | 242 void test_IndexableName_field() { |
| 165 _indexTestUnit(''' | 243 _indexTestUnit(''' |
| 166 class A { | 244 class A { |
| 167 int field; | 245 int field; |
| 168 } | 246 } |
| 169 main(A a, p) { | 247 main(A a, p) { |
| 170 print(a.field); // r | 248 print(a.field); // r |
| 171 print(p.field); // ur | 249 print(p.field); // ur |
| 172 { | 250 { |
| 173 var field = 42; | 251 var field = 42; |
| (...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 RecordedRelation(this.indexable, this.relationship, this.location); | 1723 RecordedRelation(this.indexable, this.relationship, this.location); |
| 1646 | 1724 |
| 1647 @override | 1725 @override |
| 1648 String toString() { | 1726 String toString() { |
| 1649 return 'RecordedRelation(indexable=$indexable; relationship=$relationship; ' | 1727 return 'RecordedRelation(indexable=$indexable; relationship=$relationship; ' |
| 1650 'location=$location; flags=' | 1728 'location=$location; flags=' |
| 1651 '${location.isQualified ? "Q" : ""}' | 1729 '${location.isQualified ? "Q" : ""}' |
| 1652 '${location.isResolved ? "R" : ""})'; | 1730 '${location.isResolved ? "R" : ""})'; |
| 1653 } | 1731 } |
| 1654 } | 1732 } |
| OLD | NEW |