Chromium Code Reviews| Index: pkg/analysis_server/lib/src/services/completion/completion_dart.dart |
| diff --git a/pkg/analysis_server/lib/src/services/completion/completion_dart.dart b/pkg/analysis_server/lib/src/services/completion/completion_dart.dart |
| index 1cfff042d6017ca98311ae8b46b881391146b2e3..d034d9b298db6a99e29cda7505e77f66d944778d 100644 |
| --- a/pkg/analysis_server/lib/src/services/completion/completion_dart.dart |
| +++ b/pkg/analysis_server/lib/src/services/completion/completion_dart.dart |
| @@ -4,11 +4,18 @@ |
| library analysis_server.src.services.completion.completion_dart; |
| +import 'dart:async'; |
| + |
| import 'package:analysis_server/src/provisional/completion/completion_core.dart'; |
| import 'package:analysis_server/src/provisional/completion/completion_dart.dart'; |
| import 'package:analysis_server/src/provisional/completion/dart/completion_target.dart'; |
| import 'package:analysis_server/src/services/completion/completion_core.dart'; |
| +import 'package:analyzer/src/context/context.dart'; |
| import 'package:analyzer/src/generated/ast.dart'; |
| +import 'package:analyzer/src/task/dart.dart'; |
| +import 'package:analyzer/task/dart.dart'; |
| +import 'package:analyzer/task/model.dart'; |
| +import 'package:analyzer/src/generated/element.dart'; |
| /** |
| * The information about a requested list of completions within a Dart file. |
| @@ -16,26 +23,36 @@ import 'package:analyzer/src/generated/ast.dart'; |
| class DartCompletionRequestImpl extends CompletionRequestImpl |
| implements DartCompletionRequest { |
| /** |
| - * The compilation unit in which the completion was requested. |
| + * The parsed completion target. This determines |
| + * what part of the parse tree will receive the newly inserted text. |
| + * Use [resolvedDeclarationTarget] to obtain a resolved completion target. |
| */ |
| - final CompilationUnit unit; |
| + final CompletionTarget parsedTarget; |
| - /** |
| - * A flag indicating whether the compilation [unit] is resolved. |
| - */ |
| - final bool isResolved; |
| + @deprecated // Use parsedTarget |
| + CompletionTarget get target => parsedTarget; |
| - /** |
| - * The completion target. This determines what part of the parse tree |
| - * will receive the newly inserted text. |
| - */ |
| - final CompletionTarget target; |
| + @deprecated // Use parsedTarget.unit or resolvedTarget(...).unit |
| + CompilationUnit get unit => parsedTarget.unit; |
| /** |
| * Initialize a newly created completion request based on the given arguments. |
| */ |
| - DartCompletionRequestImpl( |
| - CompletionRequest request, this.unit, this.isResolved, this.target) |
| + DartCompletionRequestImpl(CompletionRequest request, this.parsedTarget) |
| : super(request.context, request.resourceProvider, request.source, |
| request.offset); |
| + |
| + @override |
| + Future<CompletionTarget> get resolvedDeclarationTarget { |
|
Brian Wilkerson
2015/10/19 23:15:46
Consider making this an async function body.
danrubel
2015/10/20 00:11:17
Good idea. It's now easier to read.
|
| + return (context as AnalysisContextImpl) |
| + .computeResolvedCompilationUnitAsync2(source, LIBRARY_ELEMENT1) |
| + .then((LibraryElement libraryElement) { |
| + return (context as AnalysisContextImpl) |
| + .computeResolvedCompilationUnitAsync2( |
| + new LibrarySpecificUnit(libraryElement.source, source), |
| + RESOLVED_UNIT3); |
| + }).then((CompilationUnit resolvedUnit) { |
| + return new CompletionTarget.forOffset(resolvedUnit, offset); |
| + }); |
| + } |
| } |