| Index: pkg/analysis_server/lib/completion/completion_dart.dart
|
| diff --git a/pkg/analysis_server/lib/completion/completion_dart.dart b/pkg/analysis_server/lib/completion/completion_dart.dart
|
| index daeba77a3e3fac4225478b7eea77ee62aa11667e..590e13d3b87474e4a5280894ca2d57c793f34a72 100644
|
| --- a/pkg/analysis_server/lib/completion/completion_dart.dart
|
| +++ b/pkg/analysis_server/lib/completion/completion_dart.dart
|
| @@ -5,7 +5,10 @@
|
| library analysis_server.completion.completion_dart;
|
|
|
| import 'package:analysis_server/completion/completion_core.dart';
|
| +import 'package:analysis_server/src/services/completion/completion_dart.dart';
|
| import 'package:analyzer/src/generated/ast.dart';
|
| +import 'package:analyzer/src/generated/engine.dart';
|
| +import 'package:analyzer/src/generated/source.dart';
|
|
|
| /**
|
| * An object used to produce completions for a specific error within a Dart
|
| @@ -17,10 +20,30 @@ import 'package:analyzer/src/generated/ast.dart';
|
| abstract class DartCompletionContributor extends CompletionContributor {
|
| @override
|
| CompletionResult computeSuggestions(CompletionRequest request) {
|
| - // TODO(brianwilkerson) Implement this by getting the information required
|
| - // to create a DartCompletionRequest and calling:
|
| - // return internalComputeSuggestions(dartRequest);
|
| - return null;
|
| + if (request is DartCompletionRequest) {
|
| + return internalComputeSuggestions(request);
|
| + }
|
| + AnalysisContext context = request.context;
|
| + Source source = request.source;
|
| + List<Source> libraries = context.getLibrariesContaining(source);
|
| + if (libraries.length < 1) {
|
| + return null;
|
| + }
|
| + CompilationUnit unit =
|
| + context.getResolvedCompilationUnit2(source, libraries[0]);
|
| + bool isResolved = true;
|
| + if (unit == null) {
|
| + // TODO(brianwilkerson) Implement a method for getting a parsed
|
| + // compilation unit without parsing the unit if it hasn't been parsed.
|
| +// unit = context.getParsedCompilationUnit(source);
|
| + if (unit == null) {
|
| + return null;
|
| + }
|
| + isResolved = false;
|
| + }
|
| + DartCompletionRequest dartRequest =
|
| + new DartCompletionRequestImpl(request, unit, isResolved);
|
| + return internalComputeSuggestions(dartRequest);
|
| }
|
|
|
| /**
|
| @@ -42,7 +65,7 @@ abstract class DartCompletionRequest extends CompletionRequest {
|
| bool get isResolved;
|
|
|
| /**
|
| - * The compilation unit in which the completion was requested.
|
| + * Return the compilation unit in which the completion was requested.
|
| */
|
| CompilationUnit get unit;
|
|
|
| @@ -52,7 +75,7 @@ abstract class DartCompletionRequest extends CompletionRequest {
|
| //DartCompletionCache get cache;
|
|
|
| /**
|
| - * The completion target. This determines what part of the parse tree
|
| + * Return the completion target. This determines what part of the parse tree
|
| * will receive the newly inserted text.
|
| */
|
| //CompletionTarget get target;
|
|
|