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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart

Issue 1054363003: replace request.node with request.target (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/keyword_computer.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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; 5 library services.completion.dart;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:analysis_server/src/services/completion/arglist_computer.dart'; 10 import 'package:analysis_server/src/services/completion/arglist_computer.dart';
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 /** 116 /**
117 * Compute suggestions based upon cached information only 117 * Compute suggestions based upon cached information only
118 * then send an initial response to the client. 118 * then send an initial response to the client.
119 * Return a list of computers for which [computeFull] should be called 119 * Return a list of computers for which [computeFull] should be called
120 */ 120 */
121 List<DartCompletionComputer> computeFast(DartCompletionRequest request) { 121 List<DartCompletionComputer> computeFast(DartCompletionRequest request) {
122 return request.performance.logElapseTime('computeFast', () { 122 return request.performance.logElapseTime('computeFast', () {
123 CompilationUnit unit = context.parseCompilationUnit(source); 123 CompilationUnit unit = context.parseCompilationUnit(source);
124 request.unit = unit; 124 request.unit = unit;
125 request.node = new NodeLocator.con1(request.offset).searchWithin(unit);
126 request.target = new CompletionTarget.forOffset(unit, request.offset); 125 request.target = new CompletionTarget.forOffset(unit, request.offset);
127 request.replacementOffset = request.offset; 126 request.replacementOffset = request.offset;
128 request.replacementLength = 0; 127 request.replacementLength = 0;
129 if (request.node == null) { 128 if (request.offset < 0 || request.offset > unit.end) {
130 sendResults(request, true); 129 sendResults(request, true);
131 return []; 130 return [];
132 } 131 }
133 132
134 var entity = request.target.entity; 133 var entity = request.target.entity;
135 Token token = entity is AstNode ? entity.beginToken : entity; 134 Token token = entity is AstNode ? entity.beginToken : entity;
136 if (token != null && 135 if (token != null &&
137 token.offset <= request.offset && 136 token.offset <= request.offset &&
138 (token.type == TokenType.KEYWORD || 137 (token.type == TokenType.KEYWORD ||
139 token.type == TokenType.IDENTIFIER)) { 138 token.type == TokenType.IDENTIFIER)) {
(...skipping 26 matching lines...) Expand all
166 if (controller.isClosed) { 165 if (controller.isClosed) {
167 return; 166 return;
168 } 167 }
169 request.performance.logElapseTime('waitForAnalysis'); 168 request.performance.logElapseTime('waitForAnalysis');
170 if (unit == null) { 169 if (unit == null) {
171 sendResults(request, true); 170 sendResults(request, true);
172 return; 171 return;
173 } 172 }
174 request.performance.logElapseTime('computeFull', () { 173 request.performance.logElapseTime('computeFull', () {
175 request.unit = unit; 174 request.unit = unit;
176 request.node = new NodeLocator.con1(request.offset).searchWithin(unit);
177 // TODO(paulberry): Do we need to invoke _ReplacementOffsetBuilder 175 // TODO(paulberry): Do we need to invoke _ReplacementOffsetBuilder
178 // again? 176 // again?
179 request.target = new CompletionTarget.forOffset(unit, request.offset); 177 request.target = new CompletionTarget.forOffset(unit, request.offset);
180 int count = todo.length; 178 int count = todo.length;
181 todo.forEach((DartCompletionComputer c) { 179 todo.forEach((DartCompletionComputer c) {
182 String name = c.runtimeType.toString(); 180 String name = c.runtimeType.toString();
183 String completeTag = 'computeFull $name complete'; 181 String completeTag = 'computeFull $name complete';
184 request.performance.logStartTime(completeTag); 182 request.performance.logStartTime(completeTag);
185 request.performance.logElapseTime('computeFull $name', () { 183 request.performance.logElapseTime('computeFull $name', () {
186 c.computeFull(request).then((bool changed) { 184 c.computeFull(request).then((bool changed) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 final DartCompletionCache cache; 270 final DartCompletionCache cache;
273 271
274 /** 272 /**
275 * The compilation unit in which the completion was requested. This unit 273 * The compilation unit in which the completion was requested. This unit
276 * may or may not be resolved when [DartCompletionComputer.computeFast] 274 * may or may not be resolved when [DartCompletionComputer.computeFast]
277 * is called but is resolved when [DartCompletionComputer.computeFull]. 275 * is called but is resolved when [DartCompletionComputer.computeFull].
278 */ 276 */
279 CompilationUnit unit; 277 CompilationUnit unit;
280 278
281 /** 279 /**
282 * The node in which the completion occurred. This node
283 * may or may not be resolved when [DartCompletionComputer.computeFast]
284 * is called but is resolved when [DartCompletionComputer.computeFull].
285 */
286 AstNode node;
287
288 /**
289 * The completion target. This determines what part of the parse tree 280 * The completion target. This determines what part of the parse tree
290 * will receive the newly inserted text. 281 * will receive the newly inserted text.
291 *
292 * TODO(paulberry) gradually transition code over to using this rather than
293 * [node].
294 */ 282 */
295 CompletionTarget target; 283 CompletionTarget target;
296 284
297 /** 285 /**
298 * Information about the types of suggestions that should be included. 286 * Information about the types of suggestions that should be included.
299 */ 287 */
300 OpType _optype; 288 OpType _optype;
301 289
302 /** 290 /**
303 * The offset of the start of the text to be replaced. 291 * The offset of the start of the text to be replaced.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 parameterNames: suggestion.parameterNames, 372 parameterNames: suggestion.parameterNames,
385 parameterTypes: suggestion.parameterTypes, 373 parameterTypes: suggestion.parameterTypes,
386 requiredParameterCount: suggestion.requiredParameterCount, 374 requiredParameterCount: suggestion.requiredParameterCount,
387 hasNamedParameters: suggestion.hasNamedParameters, 375 hasNamedParameters: suggestion.hasNamedParameters,
388 returnType: suggestion.returnType, 376 returnType: suggestion.returnType,
389 element: suggestion.element); 377 element: suggestion.element);
390 } 378 }
391 } 379 }
392 } 380 }
393 } 381 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/keyword_computer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698