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:analysis_server/src/services/index/index.dart'; | |
10 import 'package:test/test.dart'; | 9 import 'package:test/test.dart'; |
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 10 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
12 | 11 |
13 import 'abstract_search_domain.dart'; | 12 import 'abstract_search_domain.dart'; |
14 | 13 |
15 main() { | 14 main() { |
16 defineReflectiveSuite(() { | 15 defineReflectiveSuite(() { |
17 defineReflectiveTests(ElementReferencesTest); | 16 defineReflectiveTests(ElementReferencesTest); |
18 defineReflectiveTests(_NoSearchEngine); | |
19 }); | 17 }); |
20 } | 18 } |
21 | 19 |
22 @reflectiveTest | 20 @reflectiveTest |
23 class ElementReferencesTest extends AbstractSearchDomainTest { | 21 class ElementReferencesTest extends AbstractSearchDomainTest { |
24 Element searchElement; | 22 Element searchElement; |
25 | 23 |
26 void assertHasRef(SearchResultKind kind, String search, bool isPotential) { | 24 void assertHasRef(SearchResultKind kind, String search, bool isPotential) { |
27 assertHasResult(kind, search); | 25 assertHasResult(kind, search); |
28 expect(result.isPotential, isPotential); | 26 expect(result.isPotential, isPotential); |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 T m() => null; | 663 T m() => null; |
666 } | 664 } |
667 '''); | 665 '''); |
668 await findElementReferences('T> {', false); | 666 await findElementReferences('T> {', false); |
669 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); | 667 expect(searchElement.kind, ElementKind.TYPE_PARAMETER); |
670 expect(results, hasLength(2)); | 668 expect(results, hasLength(2)); |
671 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); | 669 assertHasResult(SearchResultKind.REFERENCE, 'T f;'); |
672 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); | 670 assertHasResult(SearchResultKind.REFERENCE, 'T m()'); |
673 } | 671 } |
674 } | 672 } |
675 | |
676 @reflectiveTest | |
677 class _NoSearchEngine extends AbstractSearchDomainTest { | |
678 @override | |
679 Index createIndex() { | |
680 return null; | |
681 } | |
682 | |
683 test_requestError_noSearchEngine() async { | |
684 addTestFile(''' | |
685 main() { | |
686 var vvv = 1; | |
687 print(vvv); | |
688 } | |
689 '''); | |
690 Request request = new SearchFindElementReferencesParams(testFile, 0, false) | |
691 .toRequest('0'); | |
692 Response response = await waitResponse(request); | |
693 expect(response.error, isNotNull); | |
694 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | |
695 } | |
696 } | |
OLD | NEW |