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