| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/protocol/protocol_generated.dart'; | 8 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 9 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 9 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 library my_lib; | 432 library my_lib; |
| 433 class A {} | 433 class A {} |
| 434 class B { | 434 class B { |
| 435 B.named() { | 435 B.named() { |
| 436 A a = null; | 436 A a = null; |
| 437 } | 437 } |
| 438 } | 438 } |
| 439 '''); | 439 '''); |
| 440 await findElementReferences('A {}', false); | 440 await findElementReferences('A {}', false); |
| 441 assertHasResult(SearchResultKind.REFERENCE, 'A a = null;'); | 441 assertHasResult(SearchResultKind.REFERENCE, 'A a = null;'); |
| 442 expect( | 442 expect(getPathString(result.path), ''' |
| 443 getPathString(result.path), | |
| 444 ''' | |
| 445 LOCAL_VARIABLE a | 443 LOCAL_VARIABLE a |
| 446 CONSTRUCTOR named | 444 CONSTRUCTOR named |
| 447 CLASS B | 445 CLASS B |
| 448 COMPILATION_UNIT test.dart | 446 COMPILATION_UNIT test.dart |
| 449 LIBRARY my_lib'''); | 447 LIBRARY my_lib'''); |
| 450 } | 448 } |
| 451 | 449 |
| 452 @failingTest | 450 @failingTest |
| 453 test_path_inConstructor_unnamed() async { | 451 test_path_inConstructor_unnamed() async { |
| 454 // The path does not contain the first expected element. | 452 // The path does not contain the first expected element. |
| 455 addTestFile(''' | 453 addTestFile(''' |
| 456 library my_lib; | 454 library my_lib; |
| 457 class A {} | 455 class A {} |
| 458 class B { | 456 class B { |
| 459 B() { | 457 B() { |
| 460 A a = null; | 458 A a = null; |
| 461 } | 459 } |
| 462 } | 460 } |
| 463 '''); | 461 '''); |
| 464 await findElementReferences('A {}', false); | 462 await findElementReferences('A {}', false); |
| 465 assertHasResult(SearchResultKind.REFERENCE, 'A a = null;'); | 463 assertHasResult(SearchResultKind.REFERENCE, 'A a = null;'); |
| 466 expect( | 464 expect(getPathString(result.path), ''' |
| 467 getPathString(result.path), | |
| 468 ''' | |
| 469 LOCAL_VARIABLE a | 465 LOCAL_VARIABLE a |
| 470 CONSTRUCTOR | 466 CONSTRUCTOR |
| 471 CLASS B | 467 CLASS B |
| 472 COMPILATION_UNIT test.dart | 468 COMPILATION_UNIT test.dart |
| 473 LIBRARY my_lib'''); | 469 LIBRARY my_lib'''); |
| 474 } | 470 } |
| 475 | 471 |
| 476 @failingTest | 472 @failingTest |
| 477 test_path_inFunction() async { | 473 test_path_inFunction() async { |
| 478 // The path does not contain the first expected element. | 474 // The path does not contain the first expected element. |
| 479 addTestFile(''' | 475 addTestFile(''' |
| 480 library my_lib; | 476 library my_lib; |
| 481 class A {} | 477 class A {} |
| 482 main() { | 478 main() { |
| 483 A a = null; | 479 A a = null; |
| 484 } | 480 } |
| 485 '''); | 481 '''); |
| 486 await findElementReferences('A {}', false); | 482 await findElementReferences('A {}', false); |
| 487 assertHasResult(SearchResultKind.REFERENCE, 'A a = null;'); | 483 assertHasResult(SearchResultKind.REFERENCE, 'A a = null;'); |
| 488 expect( | 484 expect(getPathString(result.path), ''' |
| 489 getPathString(result.path), | |
| 490 ''' | |
| 491 LOCAL_VARIABLE a | 485 LOCAL_VARIABLE a |
| 492 FUNCTION main | 486 FUNCTION main |
| 493 COMPILATION_UNIT test.dart | 487 COMPILATION_UNIT test.dart |
| 494 LIBRARY my_lib'''); | 488 LIBRARY my_lib'''); |
| 495 } | 489 } |
| 496 | 490 |
| 497 test_potential_disabled() async { | 491 test_potential_disabled() async { |
| 498 addTestFile(''' | 492 addTestFile(''' |
| 499 class A { | 493 class A { |
| 500 test(p) {} | 494 test(p) {} |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 T m() => null; | 665 T m() => null; |
| 672 } | 666 } |
| 673 '''); | 667 '''); |
| 674 await findElementReferences('T> {', false); | 668 await findElementReferences('T> {', false); |
| 675 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); | 669 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); |
| 676 expect(results, hasLength(2)); | 670 expect(results, hasLength(2)); |
| 677 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); | 671 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); |
| 678 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); | 672 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); |
| 679 } | 673 } |
| 680 } | 674 } |
| OLD | NEW |