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

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

Issue 1692273003: rework LocalLibraryContributor to resolve referenced units (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 260
261 // Gracefully degrade if unit cannot be resolved 261 // Gracefully degrade if unit cannot be resolved
262 if (resolvedUnit == null) { 262 if (resolvedUnit == null) {
263 return; 263 return;
264 } 264 }
265 265
266 // Recompute the target for the newly resolved unit 266 // Recompute the target for the newly resolved unit
267 _updateTargets(resolvedUnit); 267 _updateTargets(resolvedUnit);
268 } 268 }
269 269
270 @override
271 Future<List<CompilationUnitElement>> resolveUnits() async {
272 checkAborted();
273 LibraryElement libElem = libraryElement;
274 if (libElem == null) {
275 return null;
276 }
277 List<CompilationUnitElement> resolvedUnits = <CompilationUnitElement>[];
278 for (CompilationUnitElement unresolvedUnit in libElem.units) {
279 CompilationUnit unit = await _computeAsync(
280 this,
281 new LibrarySpecificUnit(libElem.source, unresolvedUnit.source),
282 RESOLVED_UNIT3,
283 performance,
284 'resolve library unit');
Brian Wilkerson 2016/02/12 20:42:07 Do we want to checkAborted() after returning from
danrubel 2016/02/12 20:54:23 Good catch! Done.
285 CompilationUnitElement resolvedUnit = unit?.element;
286 resolvedUnits.add(resolvedUnit);
Brian Wilkerson 2016/02/12 20:42:07 Do we want to check for null before adding the uni
danrubel 2016/02/12 20:54:23 Good idea. Done.
287 }
288 return resolvedUnits;
289 }
290
270 /** 291 /**
271 * Update the completion [target] and [dotTarget] based on the given [unit]. 292 * Update the completion [target] and [dotTarget] based on the given [unit].
272 */ 293 */
273 void _updateTargets(CompilationUnit unit) { 294 void _updateTargets(CompilationUnit unit) {
274 _opType = null; 295 _opType = null;
275 dotTarget = null; 296 dotTarget = null;
276 target = new CompletionTarget.forOffset(unit, offset); 297 target = new CompletionTarget.forOffset(unit, offset);
277 AstNode node = target.containingNode; 298 AstNode node = target.containingNode;
278 if (node is MethodInvocation) { 299 if (node is MethodInvocation) {
279 if (identical(node.methodName, target.entity)) { 300 if (identical(node.methodName, target.entity)) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // Replacement range for import URI 456 // Replacement range for import URI
436 return new ReplacementRange(start, end - start); 457 return new ReplacementRange(start, end - start);
437 } 458 }
438 } 459 }
439 } 460 }
440 } 461 }
441 } 462 }
442 return new ReplacementRange(requestOffset, 0); 463 return new ReplacementRange(requestOffset, 0);
443 } 464 }
444 } 465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698