Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 } |
| OLD | NEW |