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

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

Issue 1531353002: report invalid param if offset is out of bounds (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 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
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/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/provisional/completion/completion_core.dart' 10 import 'package:analysis_server/src/provisional/completion/completion_core.dart'
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 * Compute suggestions based upon cached information only 125 * Compute suggestions based upon cached information only
126 * then send an initial response to the client. 126 * then send an initial response to the client.
127 * Return a list of contributors for which [computeFull] should be called 127 * Return a list of contributors for which [computeFull] should be called
128 */ 128 */
129 List<DartCompletionContributor> computeFast( 129 List<DartCompletionContributor> computeFast(
130 DartCompletionRequest request, CompletionPerformance performance) { 130 DartCompletionRequest request, CompletionPerformance performance) {
131 return performance.logElapseTime('computeFast', () { 131 return performance.logElapseTime('computeFast', () {
132 CompilationUnit unit = context.parseCompilationUnit(source); 132 CompilationUnit unit = context.parseCompilationUnit(source);
133 request.unit = unit; 133 request.unit = unit;
134 request.target = new CompletionTarget.forOffset(unit, request.offset); 134 request.target = new CompletionTarget.forOffset(unit, request.offset);
135 if (request.offset < 0 || request.offset > unit.end) {
136 request.replacementOffset = request.offset;
137 request.replacementLength = 0;
138 sendResults(request, true);
139 return [];
140 }
141 135
142 ReplacementRange range = 136 ReplacementRange range =
143 new ReplacementRange.compute(request.offset, request.target); 137 new ReplacementRange.compute(request.offset, request.target);
144 request.replacementOffset = range.offset; 138 request.replacementOffset = range.offset;
145 request.replacementLength = range.length; 139 request.replacementLength = range.length;
146 140
147 List<DartCompletionContributor> todo = new List.from(contributors); 141 List<DartCompletionContributor> todo = new List.from(contributors);
148 todo.removeWhere((DartCompletionContributor c) { 142 todo.removeWhere((DartCompletionContributor c) {
149 return performance.logElapseTime('computeFast ${c.runtimeType}', () { 143 return performance.logElapseTime('computeFast ${c.runtimeType}', () {
150 return c.computeFast(request); 144 return c.computeFast(request);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // Replacement range for import URI 452 // Replacement range for import URI
459 return new ReplacementRange(start, end - start); 453 return new ReplacementRange(start, end - start);
460 } 454 }
461 } 455 }
462 } 456 }
463 } 457 }
464 } 458 }
465 return new ReplacementRange(requestOffset, 0); 459 return new ReplacementRange(requestOffset, 0);
466 } 460 }
467 } 461 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domain_completion.dart ('k') | pkg/analysis_server/test/domain_completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698