| 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.search.search_engine_internal; | 5 library test.services.src.search.search_engine_internal; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/services/index/index.dart'; | 9 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/search/search_engine.dart'; | 10 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| (...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 558 } |
| 559 '''); | 559 '''); |
| 560 MethodMember method = findNodeElementAtString('m(); // ref'); | 560 MethodMember method = findNodeElementAtString('m(); // ref'); |
| 561 Element mainElement = findElement('main'); | 561 Element mainElement = findElement('main'); |
| 562 var expected = [ | 562 var expected = [ |
| 563 _expectIdQ(mainElement, MatchKind.INVOCATION, 'm(); // ref') | 563 _expectIdQ(mainElement, MatchKind.INVOCATION, 'm(); // ref') |
| 564 ]; | 564 ]; |
| 565 await _verifyReferences(method, expected); | 565 await _verifyReferences(method, expected); |
| 566 } | 566 } |
| 567 | 567 |
| 568 test_searchReferences_ParameterElement_ofConstructor() async { |
| 569 _indexTestUnit(''' |
| 570 class C { |
| 571 var f; |
| 572 C({p}) : f = p + 1 { |
| 573 p = 2; |
| 574 p += 3; |
| 575 print(p); |
| 576 p(); |
| 577 } |
| 578 } |
| 579 main() { |
| 580 new C(p: 42); |
| 581 } |
| 582 '''); |
| 583 ParameterElement element = findElement('p'); |
| 584 ClassElement classC = findElement('C'); |
| 585 ConstructorElement constructorA = classC.unnamedConstructor; |
| 586 Element mainElement = findElement('main'); |
| 587 var expected = [ |
| 588 _expectId(constructorA, MatchKind.READ, 'p + 1 {'), |
| 589 _expectId(constructorA, MatchKind.WRITE, 'p = 2;'), |
| 590 _expectId(constructorA, MatchKind.READ_WRITE, 'p += 3;'), |
| 591 _expectId(constructorA, MatchKind.READ, 'p);'), |
| 592 _expectId(constructorA, MatchKind.INVOCATION, 'p();'), |
| 593 _expectIdQ(mainElement, MatchKind.REFERENCE, 'p: 42') |
| 594 ]; |
| 595 await _verifyReferences(element, expected); |
| 596 } |
| 597 |
| 568 test_searchReferences_ParameterElement_ofLocalFunction() async { | 598 test_searchReferences_ParameterElement_ofLocalFunction() async { |
| 569 _indexTestUnit(''' | 599 _indexTestUnit(''' |
| 570 main() { | 600 main() { |
| 571 foo({p}) { | 601 foo({p}) { |
| 572 p = 1; | 602 p = 1; |
| 573 p += 2; | 603 p += 2; |
| 574 print(p); | 604 print(p); |
| 575 p(); | 605 p(); |
| 576 } | 606 } |
| 577 foo(p: 42); | 607 foo(p: 42); |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 List<SearchMatch> matches = await searchEngine.searchReferences(element); | 876 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
| 847 _assertMatches(matches, expectedMatches); | 877 _assertMatches(matches, expectedMatches); |
| 848 expect(matches, hasLength(expectedMatches.length)); | 878 expect(matches, hasLength(expectedMatches.length)); |
| 849 } | 879 } |
| 850 | 880 |
| 851 static void _assertMatches( | 881 static void _assertMatches( |
| 852 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { | 882 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { |
| 853 expect(matches, unorderedEquals(expectedMatches)); | 883 expect(matches, unorderedEquals(expectedMatches)); |
| 854 } | 884 } |
| 855 } | 885 } |
| OLD | NEW |