| 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.domain.completion; | 5 library test.domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/channel/channel.dart'; | 11 import 'package:analysis_server/src/channel/channel.dart'; |
| 12 import 'package:analysis_server/src/constants.dart'; | 12 import 'package:analysis_server/src/constants.dart'; |
| 13 import 'package:analysis_server/src/context_manager.dart'; | 13 import 'package:analysis_server/src/context_manager.dart'; |
| 14 import 'package:analysis_server/src/domain_analysis.dart'; | 14 import 'package:analysis_server/src/domain_analysis.dart'; |
| 15 import 'package:analysis_server/src/domain_completion.dart'; | 15 import 'package:analysis_server/src/domain_completion.dart'; |
| 16 import 'package:analysis_server/src/plugin/server_plugin.dart'; | 16 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 17 import 'package:analysis_server/src/provisional/completion/completion_core.dart' | 17 import 'package:analysis_server/src/provisional/completion/completion_core.dart' |
| 18 show CompletionRequest, CompletionResult; | 18 show AnalysisRequest, CompletionRequest, CompletionResult; |
| 19 import 'package:analysis_server/src/provisional/completion/completion_dart.dart' | 19 import 'package:analysis_server/src/provisional/completion/completion_dart.dart' |
| 20 as newApi; | 20 as newApi; |
| 21 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 21 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 22 import 'package:analysis_server/src/services/completion/contribution_sorter.dart
'; | 22 import 'package:analysis_server/src/services/completion/contribution_sorter.dart
'; |
| 23 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 23 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 24 import 'package:analysis_server/src/services/index/index.dart' show Index; | 24 import 'package:analysis_server/src/services/index/index.dart' show Index; |
| 25 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 25 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 26 import 'package:analysis_server/src/services/search/search_engine.dart'; | 26 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 27 import 'package:analyzer/file_system/file_system.dart'; | 27 import 'package:analyzer/file_system/file_system.dart'; |
| 28 import 'package:analyzer/instrumentation/instrumentation.dart'; | 28 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 return source.contents; | 719 return source.contents; |
| 720 } | 720 } |
| 721 | 721 |
| 722 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 722 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 723 } | 723 } |
| 724 | 724 |
| 725 class MockRelevancySorter implements ContributionSorter { | 725 class MockRelevancySorter implements ContributionSorter { |
| 726 bool enabled = true; | 726 bool enabled = true; |
| 727 | 727 |
| 728 @override | 728 @override |
| 729 void sort(newApi.DartCompletionRequest request, | 729 AnalysisRequest sort(CompletionRequest request, |
| 730 List<CompletionSuggestion> suggestions) { | 730 Iterable<CompletionSuggestion> suggestions) { |
| 731 if (!enabled) { | 731 if (!enabled) { |
| 732 throw 'unexpected sort'; | 732 throw 'unexpected sort'; |
| 733 } | 733 } |
| 734 return null; |
| 734 } | 735 } |
| 735 } | 736 } |
| 736 | 737 |
| 737 /** | 738 /** |
| 738 * Mock stream for tracking calls to listen and subscription.cancel. | 739 * Mock stream for tracking calls to listen and subscription.cancel. |
| 739 */ | 740 */ |
| 740 class MockStream<E> implements Stream<E> { | 741 class MockStream<E> implements Stream<E> { |
| 741 MockSubscription<E> mockSubscription = new MockSubscription<E>(); | 742 MockSubscription<E> mockSubscription = new MockSubscription<E>(); |
| 742 int listenCount = 0; | 743 int listenCount = 0; |
| 743 | 744 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 } | 846 } |
| 846 '''); | 847 '''); |
| 847 await waitForTasksFinished(); | 848 await waitForTasksFinished(); |
| 848 Request request = | 849 Request request = |
| 849 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 850 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
| 850 Response response = handler.handleRequest(request); | 851 Response response = handler.handleRequest(request); |
| 851 expect(response.error, isNotNull); | 852 expect(response.error, isNotNull); |
| 852 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 853 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
| 853 } | 854 } |
| 854 } | 855 } |
| OLD | NEW |