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

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

Issue 774033003: skip completion if client closed stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 /** 111 /**
112 * If there is remaining work to be done, then wait for the unit to be 112 * If there is remaining work to be done, then wait for the unit to be
113 * resolved and request that each remaining computer finish their work. 113 * resolved and request that each remaining computer finish their work.
114 */ 114 */
115 void computeFull(DartCompletionRequest request, 115 void computeFull(DartCompletionRequest request,
116 List<DartCompletionComputer> todo) { 116 List<DartCompletionComputer> todo) {
117 request.performance.logStartTime('waitForAnalysis'); 117 request.performance.logStartTime('waitForAnalysis');
118 waitForAnalysis().then((CompilationUnit unit) { 118 waitForAnalysis().then((CompilationUnit unit) {
119 if (controller.isClosed) {
120 return;
121 }
119 request.performance.logElapseTime('waitForAnalysis'); 122 request.performance.logElapseTime('waitForAnalysis');
120 if (unit == null) { 123 if (unit == null) {
121 sendResults(request, true); 124 sendResults(request, true);
122 return; 125 return;
123 } 126 }
124 request.performance.logElapseTime('computeFull', () { 127 request.performance.logElapseTime('computeFull', () {
125 request.unit = unit; 128 request.unit = unit;
126 request.node = new NodeLocator.con1(request.offset).searchWithin(unit); 129 request.node = new NodeLocator.con1(request.offset).searchWithin(unit);
127 int count = todo.length; 130 int count = todo.length;
128 todo.forEach((DartCompletionComputer c) { 131 todo.forEach((DartCompletionComputer c) {
(...skipping 28 matching lines...) Expand all
157 if (!todo.isEmpty) { 160 if (!todo.isEmpty) {
158 computeFull(request, todo); 161 computeFull(request, todo);
159 } 162 }
160 }); 163 });
161 } 164 }
162 165
163 /** 166 /**
164 * Send the current list of suggestions to the client. 167 * Send the current list of suggestions to the client.
165 */ 168 */
166 void sendResults(DartCompletionRequest request, bool last) { 169 void sendResults(DartCompletionRequest request, bool last) {
170 if (controller.isClosed) {
171 return;
172 }
167 controller.add( 173 controller.add(
168 new CompletionResult( 174 new CompletionResult(
169 request.replacementOffset, 175 request.replacementOffset,
170 request.replacementLength, 176 request.replacementLength,
171 request.suggestions, 177 request.suggestions,
172 last)); 178 last));
173 if (last) { 179 if (last) {
174 controller.close(); 180 controller.close();
175 } 181 }
176 } 182 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 _ReplacementOffsetBuilder(this.request) { 280 _ReplacementOffsetBuilder(this.request) {
275 request.replacementOffset = request.offset; 281 request.replacementOffset = request.offset;
276 request.replacementLength = 0; 282 request.replacementLength = 0;
277 } 283 }
278 284
279 visitSimpleIdentifier(SimpleIdentifier node) { 285 visitSimpleIdentifier(SimpleIdentifier node) {
280 request.replacementOffset = node.offset; 286 request.replacementOffset = node.offset;
281 request.replacementLength = node.length; 287 request.replacementLength = node.length;
282 } 288 }
283 } 289 }
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