| 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.suggestion; | 5 library test.services.completion.suggestion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 10 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 // would therefore not wait for microtask callbacks that are scheduled after | 37 // would therefore not wait for microtask callbacks that are scheduled after |
| 38 // invoking this method. | 38 // invoking this method. |
| 39 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); | 39 return new Future.delayed(Duration.ZERO, () => pumpEventQueue(times - 1)); |
| 40 } | 40 } |
| 41 | 41 |
| 42 @ReflectiveTestCase() | 42 @ReflectiveTestCase() |
| 43 class DartCompletionManagerTest extends AbstractSingleUnitTest { | 43 class DartCompletionManagerTest extends AbstractSingleUnitTest { |
| 44 Index index; | 44 Index index; |
| 45 SearchEngineImpl searchEngine; | 45 SearchEngineImpl searchEngine; |
| 46 Source source; | 46 Source source; |
| 47 CompletionCache cache; | |
| 48 CompletionPerformance perf; | 47 CompletionPerformance perf; |
| 49 DartCompletionManager manager; | 48 DartCompletionManager manager; |
| 50 MockCompletionComputer computer1; | 49 MockCompletionComputer computer1; |
| 51 MockCompletionComputer computer2; | 50 MockCompletionComputer computer2; |
| 52 CompletionSuggestion suggestion1; | 51 CompletionSuggestion suggestion1; |
| 53 CompletionSuggestion suggestion2; | 52 CompletionSuggestion suggestion2; |
| 54 | 53 |
| 55 void resolveLibrary() { | 54 void resolveLibrary() { |
| 56 context.resolveCompilationUnit( | 55 context.resolveCompilationUnit( |
| 57 source, | 56 source, |
| 58 context.computeLibraryElement(source)); | 57 context.computeLibraryElement(source)); |
| 59 } | 58 } |
| 60 | 59 |
| 61 @override | 60 @override |
| 62 void setUp() { | 61 void setUp() { |
| 63 super.setUp(); | 62 super.setUp(); |
| 64 index = createLocalMemoryIndex(); | 63 index = createLocalMemoryIndex(); |
| 65 searchEngine = new SearchEngineImpl(index); | 64 searchEngine = new SearchEngineImpl(index); |
| 66 source = addSource('/does/not/exist.dart', ''); | 65 source = addSource('/does/not/exist.dart', ''); |
| 67 cache = null; | |
| 68 perf = new CompletionPerformance(); | 66 perf = new CompletionPerformance(); |
| 69 manager = | 67 manager = new DartCompletionManager.create(context, searchEngine, source); |
| 70 new DartCompletionManager.create(context, searchEngine, source, cache); | |
| 71 suggestion1 = new CompletionSuggestion( | 68 suggestion1 = new CompletionSuggestion( |
| 72 CompletionSuggestionKind.INVOCATION, | 69 CompletionSuggestionKind.INVOCATION, |
| 73 CompletionRelevance.DEFAULT, | 70 CompletionRelevance.DEFAULT, |
| 74 "suggestion1", | 71 "suggestion1", |
| 75 1, | 72 1, |
| 76 1, | 73 1, |
| 77 false, | 74 false, |
| 78 false); | 75 false); |
| 79 suggestion2 = new CompletionSuggestion( | 76 suggestion2 = new CompletionSuggestion( |
| 80 CompletionSuggestionKind.IDENTIFIER, | 77 CompletionSuggestionKind.IDENTIFIER, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 @override | 187 @override |
| 191 Future<bool> computeFull(DartCompletionRequest request) { | 188 Future<bool> computeFull(DartCompletionRequest request) { |
| 192 this.request = request; | 189 this.request = request; |
| 193 fullCount++; | 190 fullCount++; |
| 194 if (fullSuggestion != null) { | 191 if (fullSuggestion != null) { |
| 195 request.suggestions.add(fullSuggestion); | 192 request.suggestions.add(fullSuggestion); |
| 196 } | 193 } |
| 197 return new Future.value(fullSuggestion != null); | 194 return new Future.value(fullSuggestion != null); |
| 198 } | 195 } |
| 199 } | 196 } |
| OLD | NEW |