| 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 Element mainElement = findElement('main'); | 518 Element mainElement = findElement('main'); |
| 519 var expected = [ | 519 var expected = [ |
| 520 _expectId(mainElement, MatchKind.WRITE, 'v = 1;'), | 520 _expectId(mainElement, MatchKind.WRITE, 'v = 1;'), |
| 521 _expectId(mainElement, MatchKind.READ_WRITE, 'v += 2;'), | 521 _expectId(mainElement, MatchKind.READ_WRITE, 'v += 2;'), |
| 522 _expectId(mainElement, MatchKind.READ, 'v);'), | 522 _expectId(mainElement, MatchKind.READ, 'v);'), |
| 523 _expectId(mainElement, MatchKind.INVOCATION, 'v();') | 523 _expectId(mainElement, MatchKind.INVOCATION, 'v();') |
| 524 ]; | 524 ]; |
| 525 await _verifyReferences(element, expected); | 525 await _verifyReferences(element, expected); |
| 526 } | 526 } |
| 527 | 527 |
| 528 test_searchReferences_LocalVariableElement_inForEachLoop() async { |
| 529 _indexTestUnit(''' |
| 530 main() { |
| 531 for (var v in []) { |
| 532 v = 1; |
| 533 v += 2; |
| 534 print(v); |
| 535 v(); |
| 536 } |
| 537 } |
| 538 '''); |
| 539 LocalVariableElement element = findElement('v'); |
| 540 Element mainElement = findElement('main'); |
| 541 var expected = [ |
| 542 _expectId(mainElement, MatchKind.WRITE, 'v = 1;'), |
| 543 _expectId(mainElement, MatchKind.READ_WRITE, 'v += 2;'), |
| 544 _expectId(mainElement, MatchKind.READ, 'v);'), |
| 545 _expectId(mainElement, MatchKind.INVOCATION, 'v();') |
| 546 ]; |
| 547 await _verifyReferences(element, expected); |
| 548 } |
| 549 |
| 528 test_searchReferences_MethodElement() async { | 550 test_searchReferences_MethodElement() async { |
| 529 _indexTestUnit(''' | 551 _indexTestUnit(''' |
| 530 class A { | 552 class A { |
| 531 m() {} | 553 m() {} |
| 532 main() { | 554 main() { |
| 533 m(); // 1 | 555 m(); // 1 |
| 534 this.m(); // 2 | 556 this.m(); // 2 |
| 535 print(m); // 3 | 557 print(m); // 3 |
| 536 print(this.m); // 4 | 558 print(this.m); // 4 |
| 537 } | 559 } |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 List<SearchMatch> matches = await searchEngine.searchReferences(element); | 898 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
| 877 _assertMatches(matches, expectedMatches); | 899 _assertMatches(matches, expectedMatches); |
| 878 expect(matches, hasLength(expectedMatches.length)); | 900 expect(matches, hasLength(expectedMatches.length)); |
| 879 } | 901 } |
| 880 | 902 |
| 881 static void _assertMatches( | 903 static void _assertMatches( |
| 882 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { | 904 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { |
| 883 expect(matches, unorderedEquals(expectedMatches)); | 905 expect(matches, unorderedEquals(expectedMatches)); |
| 884 } | 906 } |
| 885 } | 907 } |
| OLD | NEW |