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.src.services.completion.completion_dart; | 5 library analysis_server.src.services.completion.completion_dart; |
6 | 6 |
7 import 'dart:async'; | |
8 | |
7 import 'package:analysis_server/src/provisional/completion/completion_core.dart' ; | 9 import 'package:analysis_server/src/provisional/completion/completion_core.dart' ; |
8 import 'package:analysis_server/src/provisional/completion/completion_dart.dart' ; | 10 import 'package:analysis_server/src/provisional/completion/completion_dart.dart' ; |
9 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; | 11 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; |
10 import 'package:analysis_server/src/services/completion/completion_core.dart'; | 12 import 'package:analysis_server/src/services/completion/completion_core.dart'; |
13 import 'package:analyzer/src/context/context.dart'; | |
11 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
15 import 'package:analyzer/src/task/dart.dart'; | |
16 import 'package:analyzer/task/dart.dart'; | |
17 import 'package:analyzer/task/model.dart'; | |
18 import 'package:analyzer/src/generated/element.dart'; | |
12 | 19 |
13 /** | 20 /** |
14 * The information about a requested list of completions within a Dart file. | 21 * The information about a requested list of completions within a Dart file. |
15 */ | 22 */ |
16 class DartCompletionRequestImpl extends CompletionRequestImpl | 23 class DartCompletionRequestImpl extends CompletionRequestImpl |
17 implements DartCompletionRequest { | 24 implements DartCompletionRequest { |
18 /** | 25 /** |
19 * The compilation unit in which the completion was requested. | 26 * The parsed completion target. This determines |
27 * what part of the parse tree will receive the newly inserted text. | |
28 * Use [resolvedDeclarationTarget] to obtain a resolved completion target. | |
20 */ | 29 */ |
21 final CompilationUnit unit; | 30 final CompletionTarget parsedTarget; |
22 | 31 |
23 /** | 32 @deprecated // Use parsedTarget |
24 * A flag indicating whether the compilation [unit] is resolved. | 33 CompletionTarget get target => parsedTarget; |
25 */ | |
26 final bool isResolved; | |
27 | 34 |
28 /** | 35 @deprecated // Use parsedTarget.unit or resolvedTarget(...).unit |
29 * The completion target. This determines what part of the parse tree | 36 CompilationUnit get unit => parsedTarget.unit; |
30 * will receive the newly inserted text. | |
31 */ | |
32 final CompletionTarget target; | |
33 | 37 |
34 /** | 38 /** |
35 * Initialize a newly created completion request based on the given arguments. | 39 * Initialize a newly created completion request based on the given arguments. |
36 */ | 40 */ |
37 DartCompletionRequestImpl( | 41 DartCompletionRequestImpl(CompletionRequest request, this.parsedTarget) |
38 CompletionRequest request, this.unit, this.isResolved, this.target) | |
39 : super(request.context, request.resourceProvider, request.source, | 42 : super(request.context, request.resourceProvider, request.source, |
40 request.offset); | 43 request.offset); |
44 | |
45 @override | |
46 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.
| |
47 return (context as AnalysisContextImpl) | |
48 .computeResolvedCompilationUnitAsync2(source, LIBRARY_ELEMENT1) | |
49 .then((LibraryElement libraryElement) { | |
50 return (context as AnalysisContextImpl) | |
51 .computeResolvedCompilationUnitAsync2( | |
52 new LibrarySpecificUnit(libraryElement.source, source), | |
53 RESOLVED_UNIT3); | |
54 }).then((CompilationUnit resolvedUnit) { | |
55 return new CompletionTarget.forOffset(resolvedUnit, offset); | |
56 }); | |
57 } | |
41 } | 58 } |
OLD | NEW |