| 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 domain.completion; | 5 library domain.completion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 * creating a new manager or returning an existing manager as necessary. | 94 * creating a new manager or returning an existing manager as necessary. |
| 95 */ | 95 */ |
| 96 CompletionManager completionManagerFor( | 96 CompletionManager completionManagerFor( |
| 97 AnalysisContext context, Source source) { | 97 AnalysisContext context, Source source) { |
| 98 if (_manager != null) { | 98 if (_manager != null) { |
| 99 if (_manager.context == context && _manager.source == source) { | 99 if (_manager.context == context && _manager.source == source) { |
| 100 return _manager; | 100 return _manager; |
| 101 } | 101 } |
| 102 _discardManager(); | 102 _discardManager(); |
| 103 } | 103 } |
| 104 _manager = createCompletionManager(context, source, searchEngine); | 104 _manager = createCompletionManager(server, context, source); |
| 105 if (context != null) { | 105 if (context != null) { |
| 106 _sourcesChangedSubscription = | 106 _sourcesChangedSubscription = |
| 107 context.onSourcesChanged.listen(sourcesChanged); | 107 context.onSourcesChanged.listen(sourcesChanged); |
| 108 } | 108 } |
| 109 return _manager; | 109 return _manager; |
| 110 } | 110 } |
| 111 | 111 |
| 112 /** | 112 /** |
| 113 * If the context associated with the cache has changed or been removed | 113 * If the context associated with the cache has changed or been removed |
| 114 * then discard the cache. | 114 * then discard the cache. |
| 115 */ | 115 */ |
| 116 void contextsChanged(ContextsChangedEvent event) { | 116 void contextsChanged(ContextsChangedEvent event) { |
| 117 if (_manager != null) { | 117 if (_manager != null) { |
| 118 AnalysisContext context = _manager.context; | 118 AnalysisContext context = _manager.context; |
| 119 if (event.changed.contains(context) || event.removed.contains(context)) { | 119 if (event.changed.contains(context) || event.removed.contains(context)) { |
| 120 _discardManager(); | 120 _discardManager(); |
| 121 } | 121 } |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 CompletionManager createCompletionManager( | 125 CompletionManager createCompletionManager( |
| 126 AnalysisContext context, Source source, SearchEngine searchEngine) { | 126 AnalysisServer server, AnalysisContext context, Source source) { |
| 127 return new CompletionManager.create(context, source, searchEngine); | 127 return new CompletionManager.create(context, source, server.searchEngine, |
| 128 server.serverPlugin.completionContributors); |
| 128 } | 129 } |
| 129 | 130 |
| 130 @override | 131 @override |
| 131 Response handleRequest(Request request) { | 132 Response handleRequest(Request request) { |
| 132 if (searchEngine == null) { | 133 if (searchEngine == null) { |
| 133 return new Response.noIndexGenerated(request); | 134 return new Response.noIndexGenerated(request); |
| 134 } | 135 } |
| 135 return runZoned(() { | 136 return runZoned(() { |
| 136 try { | 137 try { |
| 137 String requestName = request.method; | 138 String requestName = request.method; |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 if (_sourcesChangedSubscription != null) { | 286 if (_sourcesChangedSubscription != null) { |
| 286 _sourcesChangedSubscription.cancel(); | 287 _sourcesChangedSubscription.cancel(); |
| 287 _sourcesChangedSubscription = null; | 288 _sourcesChangedSubscription = null; |
| 288 } | 289 } |
| 289 if (_manager != null) { | 290 if (_manager != null) { |
| 290 _manager.dispose(); | 291 _manager.dispose(); |
| 291 _manager = null; | 292 _manager = null; |
| 292 } | 293 } |
| 293 } | 294 } |
| 294 } | 295 } |
| OLD | NEW |