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 analysis_server.completion.completion_dart; | 5 library analysis_server.completion.completion_dart; |
6 | 6 |
7 import 'package:analysis_server/completion/completion_core.dart'; | 7 import 'package:analysis_server/completion/completion_core.dart'; |
8 import 'package:analysis_server/src/services/completion/completion_dart.dart'; | |
9 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
10 import 'package:analyzer/src/generated/engine.dart'; | 9 import 'package:analyzer/src/generated/engine.dart'; |
11 import 'package:analyzer/src/generated/source.dart'; | 10 import 'package:analyzer/src/generated/source.dart'; |
12 | 11 |
13 /** | 12 /** |
14 * An object used to produce completions for a specific error within a Dart | 13 * An object used to produce completions for a specific error within a Dart |
15 * file. Completion contributors are long-lived objects and must not retain any | 14 * file. Completion contributors are long-lived objects and must not retain any |
16 * state between invocations of [computeSuggestions]. | 15 * state between invocations of [computeSuggestions]. |
17 * | 16 * |
18 * Clients are expected to subtype this class when implementing plugins. | 17 * Clients are expected to subtype this class when implementing plugins. |
19 */ | 18 */ |
20 abstract class DartCompletionContributor extends CompletionContributor { | 19 abstract class DartCompletionContributor extends CompletionContributor { |
21 @override | 20 @override |
22 CompletionResult computeSuggestions(CompletionRequest request) { | 21 CompletionResult computeSuggestions(CompletionRequest request) { |
23 if (request is DartCompletionRequest) { | 22 if (request is DartCompletionRequest) { |
24 return internalComputeSuggestions(request); | 23 return internalComputeSuggestions(request); |
25 } | 24 } |
26 AnalysisContext context = request.context; | 25 AnalysisContext context = request.context; |
27 Source source = request.source; | 26 Source source = request.source; |
28 List<Source> libraries = context.getLibrariesContaining(source); | 27 List<Source> libraries = context.getLibrariesContaining(source); |
29 if (libraries.length < 1) { | 28 if (libraries.length < 1) { |
30 return null; | 29 return null; |
31 } | 30 } |
32 CompilationUnit unit = | 31 // CompilationUnit unit = |
33 context.getResolvedCompilationUnit2(source, libraries[0]); | 32 // context.getResolvedCompilationUnit2(source, libraries[0]); |
34 bool isResolved = true; | 33 // bool isResolved = true; |
35 if (unit == null) { | 34 // if (unit == null) { |
36 // TODO(brianwilkerson) Implement a method for getting a parsed | 35 // // TODO(brianwilkerson) Implement a method for getting a parsed |
37 // compilation unit without parsing the unit if it hasn't been parsed. | 36 // // compilation unit without parsing the unit if it hasn't been parsed. |
38 // unit = context.getParsedCompilationUnit(source); | 37 // unit = context.getParsedCompilationUnit(source); |
39 if (unit == null) { | 38 // if (unit == null) { |
40 return null; | 39 // return null; |
41 } | 40 // } |
42 isResolved = false; | 41 // isResolved = false; |
43 } | 42 // } |
44 DartCompletionRequest dartRequest = | 43 // DartCompletionRequest dartRequest = |
45 new DartCompletionRequestImpl(request, unit, isResolved); | 44 // new DartCompletionRequestImpl(request, unit, isResolved); |
46 return internalComputeSuggestions(dartRequest); | 45 // return internalComputeSuggestions(dartRequest); |
| 46 return null; |
47 } | 47 } |
48 | 48 |
49 /** | 49 /** |
50 * Compute a list of completion suggestions based on the given completion | 50 * Compute a list of completion suggestions based on the given completion |
51 * [request] and return a result that includes those suggestions. This method | 51 * [request] and return a result that includes those suggestions. This method |
52 * is called after specific phases of analysis until the contributor indicates | 52 * is called after specific phases of analysis until the contributor indicates |
53 * computation is complete by setting [CompletionResult.isLast] to `true`. | 53 * computation is complete by setting [CompletionResult.isLast] to `true`. |
54 */ | 54 */ |
55 CompletionResult internalComputeSuggestions(DartCompletionRequest request); | 55 CompletionResult internalComputeSuggestions(DartCompletionRequest request); |
56 } | 56 } |
(...skipping 21 matching lines...) Expand all Loading... |
78 * Return the completion target. This determines what part of the parse tree | 78 * Return the completion target. This determines what part of the parse tree |
79 * will receive the newly inserted text. | 79 * will receive the newly inserted text. |
80 */ | 80 */ |
81 //CompletionTarget get target; | 81 //CompletionTarget get target; |
82 | 82 |
83 /** | 83 /** |
84 * Information about the types of suggestions that should be included. | 84 * Information about the types of suggestions that should be included. |
85 */ | 85 */ |
86 //OpType get _optype; | 86 //OpType get _optype; |
87 } | 87 } |
OLD | NEW |