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

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

Issue 790743003: bound the time waiting for analysis to complete (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address comment Created 6 years 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 | no next file » | 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 request.replacementLength, 170 request.replacementLength,
171 request.suggestions, 171 request.suggestions,
172 last)); 172 last));
173 if (last) { 173 if (last) {
174 controller.close(); 174 controller.close();
175 } 175 }
176 } 176 }
177 177
178 /** 178 /**
179 * Return a future that completes when analysis is complete. 179 * Return a future that completes when analysis is complete.
180 * Return `true` if the compilation unit is be resolved.
181 */ 180 */
182 Future<CompilationUnit> waitForAnalysis() { 181 Future<CompilationUnit> waitForAnalysis([int waitCount = 10000]) {
182 //TODO (danrubel) replace this when new API is ready.
183 // I expect the new API to be either a stream of resolution events
184 // or a future that completes when the resolved library element is available
183 LibraryElement library = context.getLibraryElement(source); 185 LibraryElement library = context.getLibraryElement(source);
184 if (library != null) { 186 if (library != null) {
185 CompilationUnit unit = 187 CompilationUnit unit =
186 context.getResolvedCompilationUnit(source, library); 188 context.getResolvedCompilationUnit(source, library);
187 if (unit != null) { 189 if (unit != null) {
188 return new Future.value(unit); 190 return new Future.value(unit);
189 } 191 }
190 } 192 }
191 //TODO (danrubel) Determine if analysis is complete but unit not resolved 193 //TODO (danrubel) Remove this HACK
192 return new Future(waitForAnalysis); 194 if (waitCount > 0) {
195 return new Future(() {
196 return waitForAnalysis(waitCount - 1);
197 });
198 }
199 return new Future.value(null);
193 } 200 }
194 } 201 }
195 202
196 /** 203 /**
197 * The context in which the completion is requested. 204 * The context in which the completion is requested.
198 */ 205 */
199 class DartCompletionRequest extends CompletionRequest { 206 class DartCompletionRequest extends CompletionRequest {
200 /** 207 /**
201 * The analysis context in which the completion is requested. 208 * The analysis context in which the completion is requested.
202 */ 209 */
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 _ReplacementOffsetBuilder(this.request) { 274 _ReplacementOffsetBuilder(this.request) {
268 request.replacementOffset = request.offset; 275 request.replacementOffset = request.offset;
269 request.replacementLength = 0; 276 request.replacementLength = 0;
270 } 277 }
271 278
272 visitSimpleIdentifier(SimpleIdentifier node) { 279 visitSimpleIdentifier(SimpleIdentifier node) {
273 request.replacementOffset = node.offset; 280 request.replacementOffset = node.offset;
274 request.replacementLength = node.length; 281 request.replacementLength = node.length;
275 } 282 }
276 } 283 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698