| 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.toplevel; | 5 library test.services.completion.toplevel; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; | 8 import 'package:analysis_server/src/services/completion/completion_manager.dart'
; |
| 9 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; | 9 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; |
| 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 /* | 47 /* |
| 48 * Simulate a source change to flush the cached compilation unit | 48 * Simulate a source change to flush the cached compilation unit |
| 49 */ | 49 */ |
| 50 ChangeSet changes = new ChangeSet(); | 50 ChangeSet changes = new ChangeSet(); |
| 51 changes.addedSource(testSource); | 51 changes.addedSource(testSource); |
| 52 context.applyChanges(changes); | 52 context.applyChanges(changes); |
| 53 /* | 53 /* |
| 54 * Calculate a new completion at the same location | 54 * Calculate a new completion at the same location |
| 55 */ | 55 */ |
| 56 setUpComputer(); | 56 setUpComputer(); |
| 57 int replacementOffset = request.replacementOffset; |
| 58 int replacementLength = request.replacementLength; |
| 57 request = new DartCompletionRequest( | 59 request = new DartCompletionRequest( |
| 58 context, | 60 context, |
| 59 searchEngine, | 61 searchEngine, |
| 60 testSource, | 62 testSource, |
| 61 completionOffset, | 63 completionOffset, |
| 62 cache, | 64 cache, |
| 63 new CompletionPerformance()); | 65 new CompletionPerformance()); |
| 66 request.replacementOffset = replacementOffset; |
| 67 request.replacementLength = replacementLength; |
| 64 expect(computeFast(), isTrue); | 68 expect(computeFast(), isTrue); |
| 65 expect(request.unit.element, isNull); | 69 expect(request.unit.element, isNull); |
| 66 List<CompletionSuggestion> newSuggestions = request.suggestions; | 70 List<CompletionSuggestion> newSuggestions = request.suggestions; |
| 67 if (newSuggestions.length == oldSuggestions.length) { | 71 if (newSuggestions.length == oldSuggestions.length) { |
| 68 if (!oldSuggestions.any( | 72 if (!oldSuggestions.any( |
| 69 (CompletionSuggestion s) => !newSuggestions.contains(s))) { | 73 (CompletionSuggestion s) => !newSuggestions.contains(s))) { |
| 70 return; | 74 return; |
| 71 } | 75 } |
| 72 } | 76 } |
| 73 StringBuffer sb = new StringBuffer( | 77 StringBuffer sb = new StringBuffer( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 (computer as ImportedComputer).shouldWaitForLowPrioritySuggestions = false; | 185 (computer as ImportedComputer).shouldWaitForLowPrioritySuggestions = false; |
| 182 computeFast(); | 186 computeFast(); |
| 183 return computeFull((bool result) { | 187 return computeFull((bool result) { |
| 184 assertSuggestImportedClass('C'); | 188 assertSuggestImportedClass('C'); |
| 185 // Assert computer does not wait for or include low priority results | 189 // Assert computer does not wait for or include low priority results |
| 186 // from non-imported libraries unless instructed to do so. | 190 // from non-imported libraries unless instructed to do so. |
| 187 assertNotSuggested('H'); | 191 assertNotSuggested('H'); |
| 188 }); | 192 }); |
| 189 } | 193 } |
| 190 } | 194 } |
| OLD | NEW |