Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: pkg/analysis_server/lib/plugin/edit/assist/assist_dart.dart

Issue 2862143003: Make an AstProvider available to AssistProcessors (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.plugin.edit.assist.assist_dart; 5 library analysis_server.plugin.edit.assist.assist_dart;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
11 import 'package:analyzer/src/dart/analysis/ast_provider_context.dart';
12 import 'package:analyzer/src/dart/element/ast_provider.dart';
11 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
12 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
13 15
14 /** 16 /**
15 * An object used to provide context information for [DartAssistContributor]s. 17 * An object used to provide context information for [DartAssistContributor]s.
16 * 18 *
17 * Clients may not extend, implement or mix-in this class. 19 * Clients may not extend, implement or mix-in this class.
18 */ 20 */
19 abstract class DartAssistContext { 21 abstract class DartAssistContext {
20 /** 22 /**
21 * The [AnalysisContext] to get assists in. 23 * The [AnalysisContext] to get assists in.
22 */ 24 */
23 AnalysisContext get analysisContext; 25 AnalysisContext get analysisContext;
24 26
25 /** 27 /**
28 * The provider for parsed or resolved ASTs.
29 */
30 AstProvider get astProvider;
31
32 /**
26 * The length of the selection. 33 * The length of the selection.
27 */ 34 */
28 int get selectionLength; 35 int get selectionLength;
29 36
30 /** 37 /**
31 * The start of the selection. 38 * The start of the selection.
32 */ 39 */
33 int get selectionOffset; 40 int get selectionOffset;
34 41
35 /** 42 /**
(...skipping 22 matching lines...) Expand all
58 } 65 }
59 List<Source> libraries = analysisContext.getLibrariesContaining(source); 66 List<Source> libraries = analysisContext.getLibrariesContaining(source);
60 if (libraries.isEmpty) { 67 if (libraries.isEmpty) {
61 return Assist.EMPTY_LIST; 68 return Assist.EMPTY_LIST;
62 } 69 }
63 CompilationUnit unit = 70 CompilationUnit unit =
64 analysisContext.getResolvedCompilationUnit2(source, libraries[0]); 71 analysisContext.getResolvedCompilationUnit2(source, libraries[0]);
65 if (unit == null) { 72 if (unit == null) {
66 return Assist.EMPTY_LIST; 73 return Assist.EMPTY_LIST;
67 } 74 }
68 DartAssistContext dartContext = new _DartAssistContextImpl(context, unit); 75 DartAssistContext dartContext = new _DartAssistContextImpl(
76 new AstProviderForContext(analysisContext), context, unit);
69 return internalComputeAssists(dartContext); 77 return internalComputeAssists(dartContext);
70 } 78 }
71 79
72 /** 80 /**
73 * Completes with a list of assists for the given [context]. 81 * Completes with a list of assists for the given [context].
74 */ 82 */
75 Future<List<Assist>> internalComputeAssists(DartAssistContext context); 83 Future<List<Assist>> internalComputeAssists(DartAssistContext context);
76 } 84 }
77 85
78 /** 86 /**
79 * The implementation of [DartAssistContext]. 87 * The implementation of [DartAssistContext].
80 * 88 *
81 * Clients may not extend, implement or mix-in this class. 89 * Clients may not extend, implement or mix-in this class.
82 */ 90 */
83 class _DartAssistContextImpl implements DartAssistContext { 91 class _DartAssistContextImpl implements DartAssistContext {
92 /**
93 * The provider for parsed or resolved ASTs.
94 */
95 final AstProvider astProvider;
96
84 final AssistContext _context; 97 final AssistContext _context;
85 98
86 /** 99 /**
87 * The [CompilationUnit] to compute assists in. 100 * The [CompilationUnit] to compute assists in.
88 */ 101 */
89 final CompilationUnit unit; 102 final CompilationUnit unit;
90 103
91 _DartAssistContextImpl(this._context, this.unit); 104 _DartAssistContextImpl(this.astProvider, this._context, this.unit);
92 105
93 /** 106 /**
94 * The [AnalysisContext] to get assists in. 107 * The [AnalysisContext] to get assists in.
95 */ 108 */
96 AnalysisContext get analysisContext => _context.analysisContext; 109 AnalysisContext get analysisContext => _context.analysisContext;
97 110
98 /** 111 /**
99 * The length of the selection. 112 * The length of the selection.
100 */ 113 */
101 int get selectionLength => _context.selectionLength; 114 int get selectionLength => _context.selectionLength;
102 115
103 /** 116 /**
104 * The start of the selection. 117 * The start of the selection.
105 */ 118 */
106 int get selectionOffset => _context.selectionOffset; 119 int get selectionOffset => _context.selectionOffset;
107 120
108 /** 121 /**
109 * The source to get assists in. 122 * The source to get assists in.
110 */ 123 */
111 Source get source => _context.source; 124 Source get source => _context.source;
112 } 125 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/edit/edit_domain.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698