| 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 var length = 'math.'.length; | 454 var length = 'math.'.length; |
| 455 var expected = [ | 455 var expected = [ |
| 456 _expectId(mainElement, kind, 'math.PI);', length: length), | 456 _expectId(mainElement, kind, 'math.PI);', length: length), |
| 457 _expectId(mainElement, kind, 'math.Random()', length: length), | 457 _expectId(mainElement, kind, 'math.Random()', length: length), |
| 458 _expectId(mainElement, kind, 'math.max(', length: length), | 458 _expectId(mainElement, kind, 'math.max(', length: length), |
| 459 _expectId(barElement, kind, 'math.Random bar()', length: length), | 459 _expectId(barElement, kind, 'math.Random bar()', length: length), |
| 460 ]; | 460 ]; |
| 461 await _verifyReferences(element, expected); | 461 await _verifyReferences(element, expected); |
| 462 } | 462 } |
| 463 | 463 |
| 464 test_searchReferences_ImportElement_withPrefix_forMultipleImports() async { |
| 465 _indexTestUnit(''' |
| 466 import 'dart:async' as p; |
| 467 import 'dart:math' as p; |
| 468 main() { |
| 469 p.Random; |
| 470 p.Future; |
| 471 } |
| 472 '''); |
| 473 Element mainElement = findElement('main'); |
| 474 var kind = MatchKind.REFERENCE; |
| 475 var length = 'p.'.length; |
| 476 { |
| 477 ImportElement element = testLibraryElement.imports[0]; |
| 478 var expected = [ |
| 479 _expectId(mainElement, kind, 'p.Future;', length: length), |
| 480 ]; |
| 481 await _verifyReferences(element, expected); |
| 482 } |
| 483 { |
| 484 ImportElement element = testLibraryElement.imports[1]; |
| 485 var expected = [ |
| 486 _expectId(mainElement, kind, 'p.Random', length: length), |
| 487 ]; |
| 488 await _verifyReferences(element, expected); |
| 489 } |
| 490 } |
| 491 |
| 464 test_searchReferences_LabelElement() async { | 492 test_searchReferences_LabelElement() async { |
| 465 _indexTestUnit(''' | 493 _indexTestUnit(''' |
| 466 main() { | 494 main() { |
| 467 label: | 495 label: |
| 468 while (true) { | 496 while (true) { |
| 469 if (true) { | 497 if (true) { |
| 470 break label; // 1 | 498 break label; // 1 |
| 471 } | 499 } |
| 472 break label; // 2 | 500 break label; // 2 |
| 473 } | 501 } |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 List<SearchMatch> matches = await searchEngine.searchReferences(element); | 928 List<SearchMatch> matches = await searchEngine.searchReferences(element); |
| 901 _assertMatches(matches, expectedMatches); | 929 _assertMatches(matches, expectedMatches); |
| 902 expect(matches, hasLength(expectedMatches.length)); | 930 expect(matches, hasLength(expectedMatches.length)); |
| 903 } | 931 } |
| 904 | 932 |
| 905 static void _assertMatches( | 933 static void _assertMatches( |
| 906 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { | 934 List<SearchMatch> matches, List<ExpectedMatch> expectedMatches) { |
| 907 expect(matches, unorderedEquals(expectedMatches)); | 935 expect(matches, unorderedEquals(expectedMatches)); |
| 908 } | 936 } |
| 909 } | 937 } |
| OLD | NEW |