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' |
11 show CompletionContributor, CompletionRequest; | 11 show CompletionContributor, CompletionRequest; |
12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 12 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
13 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; | 13 import 'package:analysis_server/src/provisional/completion/dart/completion_plugi
n.dart'; |
14 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; | 14 import 'package:analysis_server/src/provisional/completion/dart/completion_targe
t.dart'; |
15 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 15 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
16 import 'package:analysis_server/src/services/search/search_engine.dart'; | 16 import 'package:analysis_server/src/services/search/search_engine.dart'; |
17 import 'package:analyzer/file_system/file_system.dart'; | 17 import 'package:analyzer/file_system/file_system.dart'; |
18 import 'package:analyzer/src/context/context.dart' | 18 import 'package:analyzer/src/context/context.dart' |
19 show AnalysisFutureHelper, AnalysisContextImpl; | 19 show AnalysisFutureHelper, AnalysisContextImpl; |
20 import 'package:analyzer/src/generated/ast.dart'; | 20 import 'package:analyzer/src/generated/ast.dart'; |
| 21 import 'package:analyzer/src/generated/element.dart'; |
21 import 'package:analyzer/src/generated/engine.dart' hide AnalysisContextImpl; | 22 import 'package:analyzer/src/generated/engine.dart' hide AnalysisContextImpl; |
22 import 'package:analyzer/src/generated/source.dart'; | 23 import 'package:analyzer/src/generated/source.dart'; |
23 import 'package:analyzer/src/task/dart.dart'; | 24 import 'package:analyzer/src/task/dart.dart'; |
24 import 'package:analyzer/task/dart.dart'; | 25 import 'package:analyzer/task/dart.dart'; |
25 | 26 |
26 /** | 27 /** |
27 * [DartCompletionManager] determines if a completion request is Dart specific | 28 * [DartCompletionManager] determines if a completion request is Dart specific |
28 * and forwards those requests to all [DartCompletionContributor]s. | 29 * and forwards those requests to all [DartCompletionContributor]s. |
29 */ | 30 */ |
30 class DartCompletionManager implements CompletionContributor { | 31 class DartCompletionManager implements CompletionContributor { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 84 |
84 DartCompletionRequestImpl._( | 85 DartCompletionRequestImpl._( |
85 AnalysisContext context, | 86 AnalysisContext context, |
86 ResourceProvider resourceProvider, | 87 ResourceProvider resourceProvider, |
87 SearchEngine searchEngine, | 88 SearchEngine searchEngine, |
88 Source source, | 89 Source source, |
89 int offset) | 90 int offset) |
90 : super(context, resourceProvider, searchEngine, source, offset); | 91 : super(context, resourceProvider, searchEngine, source, offset); |
91 | 92 |
92 @override | 93 @override |
| 94 Future<LibraryElement> get libraryElement async { |
| 95 //TODO(danrubel) build the library element rather than all the declarations |
| 96 CompilationUnit unit = await resolveDeclarationsInScope(); |
| 97 if (unit != null) { |
| 98 CompilationUnitElement elem = unit.element; |
| 99 if (elem != null) { |
| 100 return elem.library; |
| 101 } |
| 102 } |
| 103 return null; |
| 104 } |
| 105 |
| 106 @override |
93 CompletionTarget get target { | 107 CompletionTarget get target { |
94 if (_target == null) { | 108 if (_target == null) { |
95 CompilationUnit unit = context.computeResult(source, PARSED_UNIT); | 109 CompilationUnit unit = context.computeResult(source, PARSED_UNIT); |
96 _target = new CompletionTarget.forOffset(unit, offset); | 110 _target = new CompletionTarget.forOffset(unit, offset); |
97 } | 111 } |
98 return _target; | 112 return _target; |
99 } | 113 } |
100 | 114 |
101 @override | 115 @override |
102 Future<CompilationUnit> resolveDeclarationsInScope() async { | 116 Future<CompilationUnit> resolveDeclarationsInScope() async { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // Gracefully degrade if unit cannot be resolved | 190 // Gracefully degrade if unit cannot be resolved |
177 if (resolvedUnit == null) { | 191 if (resolvedUnit == null) { |
178 return; | 192 return; |
179 } | 193 } |
180 | 194 |
181 // Recompute the target for the newly resolved unit | 195 // Recompute the target for the newly resolved unit |
182 _target = new CompletionTarget.forOffset(resolvedUnit, offset); | 196 _target = new CompletionTarget.forOffset(resolvedUnit, offset); |
183 _haveResolveDeclarationsInScope = true; | 197 _haveResolveDeclarationsInScope = true; |
184 } | 198 } |
185 } | 199 } |
OLD | NEW |