| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |