Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: pkg/analysis_server/lib/src/domain_completion.dart

Issue 2844413002: Guard against files that are not being analyzed (issue 29493) (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 CompletionGetSuggestionsParams params) async { 76 CompletionGetSuggestionsParams params) async {
77 // 77 //
78 // Allow plugins to start computing fixes. 78 // Allow plugins to start computing fixes.
79 // 79 //
80 Map<PluginInfo, Future<plugin.Response>> pluginFutures; 80 Map<PluginInfo, Future<plugin.Response>> pluginFutures;
81 plugin.CompletionGetSuggestionsParams requestParams; 81 plugin.CompletionGetSuggestionsParams requestParams;
82 if (server.options.enableNewAnalysisDriver) { 82 if (server.options.enableNewAnalysisDriver) {
83 String file = params.file; 83 String file = params.file;
84 int offset = params.offset; 84 int offset = params.offset;
85 AnalysisDriver driver = server.getAnalysisDriver(file); 85 AnalysisDriver driver = server.getAnalysisDriver(file);
86 requestParams = new plugin.CompletionGetSuggestionsParams(file, offset); 86 if (driver != null) {
87 pluginFutures = server.pluginManager 87 requestParams = new plugin.CompletionGetSuggestionsParams(file, offset);
88 .broadcastRequest(requestParams, contextRoot: driver.contextRoot); 88 pluginFutures = server.pluginManager
89 .broadcastRequest(requestParams, contextRoot: driver.contextRoot);
90 }
89 } 91 }
90 // 92 //
91 // Compute completions generated by server. 93 // Compute completions generated by server.
92 // 94 //
93 Iterable<CompletionContributor> newContributors = 95 Iterable<CompletionContributor> newContributors =
94 server.serverPlugin.completionContributors; 96 server.serverPlugin.completionContributors;
95 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; 97 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[];
96 98
97 const COMPUTE_SUGGESTIONS_TAG = 'computeSuggestions'; 99 const COMPUTE_SUGGESTIONS_TAG = 'computeSuggestions';
98 performance.logStartTime(COMPUTE_SUGGESTIONS_TAG); 100 performance.logStartTime(COMPUTE_SUGGESTIONS_TAG);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } 149 }
148 return null; 150 return null;
149 }, onError: (exception, stackTrace) { 151 }, onError: (exception, stackTrace) {
150 server.sendServerErrorNotification( 152 server.sendServerErrorNotification(
151 'Failed to handle completion domain request: ${request.toJson()}', 153 'Failed to handle completion domain request: ${request.toJson()}',
152 exception, 154 exception,
153 stackTrace); 155 stackTrace);
154 }); 156 });
155 } 157 }
156 158
159 void ifMatchesRequestClear(CompletionRequest completionRequest) {
160 if (_currentRequest == completionRequest) {
161 _currentRequest = null;
162 }
163 }
164
157 /** 165 /**
158 * Process a `completion.getSuggestions` request. 166 * Process a `completion.getSuggestions` request.
159 */ 167 */
160 Future<Null> processRequest(Request request) async { 168 Future<Null> processRequest(Request request) async {
161 performance = new CompletionPerformance(); 169 performance = new CompletionPerformance();
162 170
163 // extract and validate params 171 // extract and validate params
164 CompletionGetSuggestionsParams params = 172 CompletionGetSuggestionsParams params =
165 new CompletionGetSuggestionsParams.fromRequest(request); 173 new CompletionGetSuggestionsParams.fromRequest(request);
166 174
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 performance.notificationCount = 1; 254 performance.notificationCount = 1;
247 performance.logFirstNotificationComplete('notification 1 complete'); 255 performance.logFirstNotificationComplete('notification 1 complete');
248 performance.suggestionCountFirst = result.suggestions.length; 256 performance.suggestionCountFirst = result.suggestions.length;
249 performance.suggestionCountLast = result.suggestions.length; 257 performance.suggestionCountLast = result.suggestions.length;
250 performance.complete(); 258 performance.complete();
251 }).whenComplete(() { 259 }).whenComplete(() {
252 ifMatchesRequestClear(completionRequest); 260 ifMatchesRequestClear(completionRequest);
253 }); 261 });
254 } 262 }
255 263
256 void setNewRequest(CompletionRequest completionRequest) {
257 _abortCurrentRequest();
258 _currentRequest = completionRequest;
259 }
260
261 void ifMatchesRequestClear(CompletionRequest completionRequest) {
262 if (_currentRequest == completionRequest) {
263 _currentRequest = null;
264 }
265 }
266
267 /** 264 /**
268 * If tracking code completion performance over time, then 265 * If tracking code completion performance over time, then
269 * record addition information about the request in the performance record. 266 * record addition information about the request in the performance record.
270 */ 267 */
271 void recordRequest(CompletionPerformance performance, AnalysisContext context, 268 void recordRequest(CompletionPerformance performance, AnalysisContext context,
272 Source source, int offset) { 269 Source source, int offset) {
273 performance.source = source; 270 performance.source = source;
274 if (performanceListMaxLength == 0 || context == null || source == null) { 271 if (performanceListMaxLength == 0 || context == null || source == null) {
275 return; 272 return;
276 } 273 }
(...skipping 11 matching lines...) Expand all
288 /** 285 /**
289 * Send completion notification results. 286 * Send completion notification results.
290 */ 287 */
291 void sendCompletionNotification(String completionId, int replacementOffset, 288 void sendCompletionNotification(String completionId, int replacementOffset,
292 int replacementLength, Iterable<CompletionSuggestion> results) { 289 int replacementLength, Iterable<CompletionSuggestion> results) {
293 server.sendNotification(new CompletionResultsParams( 290 server.sendNotification(new CompletionResultsParams(
294 completionId, replacementOffset, replacementLength, results, true) 291 completionId, replacementOffset, replacementLength, results, true)
295 .toNotification()); 292 .toNotification());
296 } 293 }
297 294
295 void setNewRequest(CompletionRequest completionRequest) {
296 _abortCurrentRequest();
297 _currentRequest = completionRequest;
298 }
299
298 /** 300 /**
299 * Abort the current completion request, if any. 301 * Abort the current completion request, if any.
300 */ 302 */
301 void _abortCurrentRequest() { 303 void _abortCurrentRequest() {
302 if (_currentRequest != null) { 304 if (_currentRequest != null) {
303 _currentRequest.abort(); 305 _currentRequest.abort();
304 _currentRequest = null; 306 _currentRequest = null;
305 } 307 }
306 } 308 }
307 } 309 }
(...skipping 18 matching lines...) Expand all
326 final int replacementOffset; 328 final int replacementOffset;
327 329
328 /** 330 /**
329 * The suggested completions. 331 * The suggested completions.
330 */ 332 */
331 final List<CompletionSuggestion> suggestions; 333 final List<CompletionSuggestion> suggestions;
332 334
333 CompletionResult( 335 CompletionResult(
334 this.replacementOffset, this.replacementLength, this.suggestions); 336 this.replacementOffset, this.replacementLength, this.suggestions);
335 } 337 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698