| 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.completion.dart.util; | 5 library test.services.completion.dart.util; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' as protocol |
| 10 show Element, ElementKind; | 10 show Element, ElementKind; |
| 11 import 'package:analysis_server/plugin/protocol/protocol.dart' | 11 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 12 hide Element, ElementKind; | 12 hide Element, ElementKind; |
| 13 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 13 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 14 import 'package:analysis_server/src/provisional/completion/completion_dart.dart'
; | 14 import 'package:analysis_server/src/analysis_server.dart'; |
| 15 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 15 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 16 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
| 16 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart' | 17 import 'package:analysis_server/src/services/completion/dart/completion_manager.
dart' |
| 17 show DartCompletionRequestImpl; | 18 show DartCompletionRequestImpl; |
| 18 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart' | 19 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart' |
| 19 show DART_RELEVANCE_DEFAULT, DART_RELEVANCE_LOW; | 20 show DART_RELEVANCE_DEFAULT, DART_RELEVANCE_LOW; |
| 20 import 'package:analysis_server/src/services/index/index.dart'; | 21 import 'package:analysis_server/src/services/index/index.dart'; |
| 21 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 22 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 22 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 23 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 23 import 'package:analyzer/src/generated/source.dart'; | 24 import 'package:analyzer/src/generated/source.dart'; |
| 24 import 'package:unittest/unittest.dart'; | 25 import 'package:unittest/unittest.dart'; |
| 25 | 26 |
| 26 import '../../../abstract_context.dart'; | 27 import '../../../abstract_context.dart'; |
| 28 import '../../../operation/operation_queue_test.dart'; |
| 27 | 29 |
| 28 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { | 30 int suggestionComparator(CompletionSuggestion s1, CompletionSuggestion s2) { |
| 29 String c1 = s1.completion.toLowerCase(); | 31 String c1 = s1.completion.toLowerCase(); |
| 30 String c2 = s2.completion.toLowerCase(); | 32 String c2 = s2.completion.toLowerCase(); |
| 31 return c1.compareTo(c2); | 33 return c1.compareTo(c2); |
| 32 } | 34 } |
| 33 | 35 |
| 34 abstract class DartCompletionContributorTest extends AbstractContextTest { | 36 abstract class DartCompletionContributorTest extends AbstractContextTest { |
| 35 Index index; | 37 Index index; |
| 36 SearchEngineImpl searchEngine; | 38 SearchEngineImpl searchEngine; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 context.performAnalysisTask(); | 126 context.performAnalysisTask(); |
| 125 // We use a delayed future to allow microtask events to finish. The | 127 // We use a delayed future to allow microtask events to finish. The |
| 126 // Future.value or Future() constructors use scheduleMicrotask themselves an
d | 128 // Future.value or Future() constructors use scheduleMicrotask themselves an
d |
| 127 // would therefore not wait for microtask callbacks that are scheduled after | 129 // would therefore not wait for microtask callbacks that are scheduled after |
| 128 // invoking this method. | 130 // invoking this method. |
| 129 return new Future.delayed( | 131 return new Future.delayed( |
| 130 Duration.ZERO, () => computeLibrariesContaining(times - 1)); | 132 Duration.ZERO, () => computeLibrariesContaining(times - 1)); |
| 131 } | 133 } |
| 132 | 134 |
| 133 Future computeSuggestions([int times = 200]) async { | 135 Future computeSuggestions([int times = 200]) async { |
| 136 AnalysisServer server = new AnalysisServerMock( |
| 137 searchEngine: searchEngine, resourceProvider: provider); |
| 134 CompletionRequestImpl baseRequest = new CompletionRequestImpl( | 138 CompletionRequestImpl baseRequest = new CompletionRequestImpl( |
| 135 context, provider, testSource, completionOffset); | 139 server, context, provider, testSource, completionOffset); |
| 136 request = new DartCompletionRequestImpl.forRequest(baseRequest); | 140 request = new DartCompletionRequestImpl.forRequest(baseRequest); |
| 137 Completer<List<CompletionSuggestion>> completer = | 141 Completer<List<CompletionSuggestion>> completer = |
| 138 new Completer<List<CompletionSuggestion>>(); | 142 new Completer<List<CompletionSuggestion>>(); |
| 139 | 143 |
| 140 // Request completions | 144 // Request completions |
| 141 contributor | 145 contributor |
| 142 .computeSuggestions(request) | 146 .computeSuggestions(request) |
| 143 .then((List<CompletionSuggestion> computedSuggestions) { | 147 .then((List<CompletionSuggestion> computedSuggestions) { |
| 144 completer.complete(computedSuggestions); | 148 completer.complete(computedSuggestions); |
| 145 }); | 149 }); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } | 213 } |
| 210 | 214 |
| 211 @override | 215 @override |
| 212 void setUp() { | 216 void setUp() { |
| 213 super.setUp(); | 217 super.setUp(); |
| 214 index = createLocalMemoryIndex(); | 218 index = createLocalMemoryIndex(); |
| 215 searchEngine = new SearchEngineImpl(index); | 219 searchEngine = new SearchEngineImpl(index); |
| 216 contributor = createContributor(); | 220 contributor = createContributor(); |
| 217 } | 221 } |
| 218 } | 222 } |
| OLD | NEW |