| 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 services.completion.dart; | 5 library services.completion.dart; |
| 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/arglist_computer.dart'; | 10 import 'package:analysis_server/src/services/completion/arglist_computer.dart'; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 new LocalComputer(), | 60 new LocalComputer(), |
| 61 new ArgListComputer(), | 61 new ArgListComputer(), |
| 62 new CombinatorComputer(), | 62 new CombinatorComputer(), |
| 63 new ImportedComputer(), | 63 new ImportedComputer(), |
| 64 new InvocationComputer()]; | 64 new InvocationComputer()]; |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * Create a new initialized Dart source completion manager | 67 * Create a new initialized Dart source completion manager |
| 68 */ | 68 */ |
| 69 factory DartCompletionManager.create(AnalysisContext context, | 69 factory DartCompletionManager.create(AnalysisContext context, |
| 70 SearchEngine searchEngine, Source source, CompletionCache oldCache) { | 70 SearchEngine searchEngine, Source source) { |
| 71 DartCompletionCache newCache; | 71 return new DartCompletionManager( |
| 72 if (oldCache is DartCompletionCache) { | 72 context, |
| 73 if (oldCache.context == context && oldCache.source == source) { | 73 searchEngine, |
| 74 newCache = oldCache; | 74 source, |
| 75 } | 75 new DartCompletionCache(context, source)); |
| 76 } | |
| 77 if (newCache == null) { | |
| 78 newCache = new DartCompletionCache(context, source); | |
| 79 } | |
| 80 return new DartCompletionManager(context, searchEngine, source, newCache); | |
| 81 } | 76 } |
| 82 | 77 |
| 83 @override | 78 @override |
| 84 void computeSuggestions(CompletionRequest completionRequest) { | 79 void computeSuggestions(CompletionRequest completionRequest) { |
| 85 DartCompletionRequest request = new DartCompletionRequest( | 80 DartCompletionRequest request = new DartCompletionRequest( |
| 86 context, | 81 context, |
| 87 searchEngine, | 82 searchEngine, |
| 88 source, | 83 source, |
| 89 completionRequest.offset, | 84 completionRequest.offset, |
| 90 cache, | 85 cache, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 _ReplacementOffsetBuilder(this.request) { | 254 _ReplacementOffsetBuilder(this.request) { |
| 260 request.replacementOffset = request.offset; | 255 request.replacementOffset = request.offset; |
| 261 request.replacementLength = 0; | 256 request.replacementLength = 0; |
| 262 } | 257 } |
| 263 | 258 |
| 264 visitSimpleIdentifier(SimpleIdentifier node) { | 259 visitSimpleIdentifier(SimpleIdentifier node) { |
| 265 request.replacementOffset = node.offset; | 260 request.replacementOffset = node.offset; |
| 266 request.replacementLength = node.length; | 261 request.replacementLength = node.length; |
| 267 } | 262 } |
| 268 } | 263 } |
| OLD | NEW |