| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:convert'; | 5 import 'dart:convert'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
| 9 import 'package:analyzer/src/summary/format.dart'; | 9 import 'package:analyzer/src/summary/format.dart'; |
| 10 import 'package:analyzer/src/summary/idl.dart'; | 10 import 'package:analyzer/src/summary/idl.dart'; |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 } | 426 } |
| 427 | 427 |
| 428 void test_isReferencedBy_ConstructorElement_classTypeAlias() { | 428 void test_isReferencedBy_ConstructorElement_classTypeAlias() { |
| 429 _indexTestUnit(''' | 429 _indexTestUnit(''' |
| 430 class M {} | 430 class M {} |
| 431 class A implements B { | 431 class A implements B { |
| 432 A() {} | 432 A() {} |
| 433 A.named() {} | 433 A.named() {} |
| 434 } | 434 } |
| 435 class B = A with M; | 435 class B = A with M; |
| 436 class C = B with M; |
| 436 main() { | 437 main() { |
| 437 new B(); // 1 | 438 new B(); // B1 |
| 438 new B.named(); // 2 | 439 new B.named(); // B2 |
| 440 new C(); // C1 |
| 441 new C.named(); // C2 |
| 439 } | 442 } |
| 440 '''); | 443 '''); |
| 441 ClassElement classA = findElement('A'); | 444 ClassElement classA = findElement('A'); |
| 442 ConstructorElement constA = classA.constructors[0]; | 445 ConstructorElement constA = classA.constructors[0]; |
| 443 ConstructorElement constA_named = classA.constructors[1]; | 446 ConstructorElement constA_named = classA.constructors[1]; |
| 444 assertThat(constA).isReferencedAt('(); // 1', length: 0); | 447 assertThat(constA) |
| 445 assertThat(constA_named).isReferencedAt('.named(); // 2', length: 6); | 448 ..isReferencedAt('(); // B1', length: 0) |
| 449 ..isReferencedAt('(); // C1', length: 0); |
| 450 assertThat(constA_named) |
| 451 ..isReferencedAt('.named(); // B2', length: 6) |
| 452 ..isReferencedAt('.named(); // C2', length: 6); |
| 453 } |
| 454 |
| 455 void test_isReferencedBy_ConstructorElement_classTypeAlias_cycle() { |
| 456 _indexTestUnit(''' |
| 457 class M {} |
| 458 class A = B with M; |
| 459 class B = A with M; |
| 460 main() { |
| 461 new A(); |
| 462 new B(); |
| 463 } |
| 464 '''); |
| 465 // No additional validation, but it should not fail with stack overflow. |
| 446 } | 466 } |
| 447 | 467 |
| 448 void test_isReferencedBy_ConstructorElement_redirection() { | 468 void test_isReferencedBy_ConstructorElement_redirection() { |
| 449 _indexTestUnit(''' | 469 _indexTestUnit(''' |
| 450 class A { | 470 class A { |
| 451 A() : this.bar(); // 1 | 471 A() : this.bar(); // 1 |
| 452 A.foo() : this(); // 2 | 472 A.foo() : this(); // 2 |
| 453 A.bar(); | 473 A.bar(); |
| 454 } | 474 } |
| 455 '''); | 475 '''); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 test._expectedLocation(search, length: length)); | 784 test._expectedLocation(search, length: length)); |
| 765 } | 785 } |
| 766 | 786 |
| 767 void isReferencedQualifiedAt(String search, {int length}) { | 787 void isReferencedQualifiedAt(String search, {int length}) { |
| 768 test._assertHasRelation( | 788 test._assertHasRelation( |
| 769 element, | 789 element, |
| 770 IndexRelationKind.IS_REFERENCED_QUALIFIED_BY, | 790 IndexRelationKind.IS_REFERENCED_QUALIFIED_BY, |
| 771 test._expectedLocation(search, length: length)); | 791 test._expectedLocation(search, length: length)); |
| 772 } | 792 } |
| 773 } | 793 } |
| OLD | NEW |