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 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 return new Future.value(); | 38 return new Future.value(); |
39 } | 39 } |
40 | 40 |
41 /** | 41 /** |
42 * Return a [Future] that completes with a list of suggestions | 42 * Return a [Future] that completes with a list of suggestions |
43 * for the given completion [request]. | 43 * for the given completion [request]. |
44 */ | 44 */ |
45 Future<List<CompletionSuggestion>> _computeDartSuggestions( | 45 Future<List<CompletionSuggestion>> _computeDartSuggestions( |
46 DartCompletionRequest request) async { | 46 DartCompletionRequest request) async { |
47 // Build the Dart specific completion contributors | |
48 List<DartCompletionContributor> contributors = | |
49 <DartCompletionContributor>[]; | |
50 for (DartCompletionContributorFactory contributorFactory | |
51 in dartCompletionPlugin.contributorFactories) { | |
52 contributors.add(contributorFactory()); | |
53 } | |
54 | |
55 // Request Dart specific completions from each contributor | 47 // Request Dart specific completions from each contributor |
56 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; | 48 List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; |
57 for (DartCompletionContributor contributor in contributors) { | 49 for (DartCompletionContributor c in dartCompletionPlugin.contributors) { |
58 suggestions.addAll(await contributor.computeSuggestions(request)); | 50 suggestions.addAll(await c.computeSuggestions(request)); |
59 } | 51 } |
60 return suggestions; | 52 return suggestions; |
61 } | 53 } |
62 } | 54 } |
63 | 55 |
64 /** | 56 /** |
65 * The information about a requested list of completions within a Dart file. | 57 * The information about a requested list of completions within a Dart file. |
66 */ | 58 */ |
67 class DartCompletionRequestImpl extends CompletionRequestImpl | 59 class DartCompletionRequestImpl extends CompletionRequestImpl |
68 implements DartCompletionRequest { | 60 implements DartCompletionRequest { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 | 132 |
141 @override | 133 @override |
142 CompletionTarget get target { | 134 CompletionTarget get target { |
143 if (_target == null) { | 135 if (_target == null) { |
144 CompilationUnit unit = context.computeResult(source, PARSED_UNIT); | 136 CompilationUnit unit = context.computeResult(source, PARSED_UNIT); |
145 _target = new CompletionTarget.forOffset(unit, offset); | 137 _target = new CompletionTarget.forOffset(unit, offset); |
146 } | 138 } |
147 return _target; | 139 return _target; |
148 } | 140 } |
149 } | 141 } |
OLD | NEW |