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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart/completion_manager.dart

Issue 1898983004: Code completion API refactoring: replace resolveExpression(Expression) with resolveContainingExpres… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Comments from danrubel Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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.manager; 5 library services.completion.dart.manager;
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/provisional/completion/completion_core.dart' 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart'
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 } 218 }
219 219
220 /** 220 /**
221 * Throw [AbortCompletion] if the completion request has been aborted. 221 * Throw [AbortCompletion] if the completion request has been aborted.
222 */ 222 */
223 void checkAborted() { 223 void checkAborted() {
224 _originalRequest.checkAborted(); 224 _originalRequest.checkAborted();
225 } 225 }
226 226
227 @override 227 @override
228 Future resolveExpression(Expression expression) async { 228 Future resolveContainingExpression(AstNode node) async {
229 // TODO When an Expression can be resolved instead of just an entire unit,
230 // this will be revisited with code searching up the parent until an
231 // Expression is found.
232
233 return resolveContainingStatement(node);
234 }
235
236 @override
237 Future resolveContainingStatement(AstNode node) async {
238 // TODO When a Statement can be resolved instead of just an entire unit,
239 // this will be revisited with code searching up the parent until a
240 // Statement is found.
241
229 checkAborted(); 242 checkAborted();
230 243
231 // Return immediately if the expression has already been resolved 244 // Return immediately if the expression has already been resolved
232 if (expression.propagatedType != null) { 245 if (node is Expression && node.propagatedType != null) {
233 return; 246 return;
234 } 247 }
235 248
236 // Gracefully degrade if librarySource cannot be determined 249 // Gracefully degrade if librarySource cannot be determined
237 if (librarySource == null) { 250 if (librarySource == null) {
238 return; 251 return;
239 } 252 }
240 253
241 // Resolve declarations in the target unit 254 // Resolve declarations in the target unit
242 // TODO(danrubel) resolve the expression or containing method 255 // TODO(danrubel) resolve the expression or containing method
243 // rather than the entire complilation unit 256 // rather than the entire compilation unit
244 CompilationUnit resolvedUnit = await _computeAsync( 257 CompilationUnit resolvedUnit = await _computeAsync(
245 this, 258 this,
246 new LibrarySpecificUnit(librarySource, source), 259 new LibrarySpecificUnit(librarySource, source),
247 RESOLVED_UNIT, 260 RESOLVED_UNIT,
248 performance, 261 performance,
249 'resolve expression'); 262 'resolve expression');
250 263
251 // TODO(danrubel) determine if the underlying source has been modified 264 // TODO(danrubel) determine if the underlying source has been modified
252 // in a way that invalidates the completion request 265 // in a way that invalidates the completion request
253 // and return null 266 // and return null
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 performance); 405 performance);
393 406
394 // Resolve the expression in which the completion occurs 407 // Resolve the expression in which the completion occurs
395 // to properly determine if identifiers should be suggested 408 // to properly determine if identifiers should be suggested
396 // rather than invocations. 409 // rather than invocations.
397 if (dartRequest.target.maybeFunctionalArgument()) { 410 if (dartRequest.target.maybeFunctionalArgument()) {
398 AstNode node = dartRequest.target.containingNode.parent; 411 AstNode node = dartRequest.target.containingNode.parent;
399 if (node is Expression) { 412 if (node is Expression) {
400 const FUNCTIONAL_ARG_TAG = 'resolve expression for isFunctionalArg'; 413 const FUNCTIONAL_ARG_TAG = 'resolve expression for isFunctionalArg';
401 performance.logStartTime(FUNCTIONAL_ARG_TAG); 414 performance.logStartTime(FUNCTIONAL_ARG_TAG);
402 await dartRequest.resolveExpression(node); 415 await dartRequest.resolveContainingExpression(node);
403 performance.logElapseTime(FUNCTIONAL_ARG_TAG); 416 performance.logElapseTime(FUNCTIONAL_ARG_TAG);
404 dartRequest.checkAborted(); 417 dartRequest.checkAborted();
405 } 418 }
406 } 419 }
407 420
408 performance.logElapseTime(BUILD_REQUEST_TAG); 421 performance.logElapseTime(BUILD_REQUEST_TAG);
409 return dartRequest; 422 return dartRequest;
410 } 423 }
411 424
412 static Future _computeAsync( 425 static Future _computeAsync(
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 // Replacement range for import URI 496 // Replacement range for import URI
484 return new ReplacementRange(start, end - start); 497 return new ReplacementRange(start, end - start);
485 } 498 }
486 } 499 }
487 } 500 }
488 } 501 }
489 } 502 }
490 return new ReplacementRange(requestOffset, 0); 503 return new ReplacementRange(requestOffset, 0);
491 } 504 }
492 } 505 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698