| 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/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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 * Compute suggestions based upon cached information only | 111 * Compute suggestions based upon cached information only |
| 112 * then send an initial response to the client. | 112 * then send an initial response to the client. |
| 113 * Return a list of computers for which [computeFull] should be called | 113 * Return a list of computers for which [computeFull] should be called |
| 114 */ | 114 */ |
| 115 List<DartCompletionComputer> computeFast(DartCompletionRequest request) { | 115 List<DartCompletionComputer> computeFast(DartCompletionRequest request) { |
| 116 return request.performance.logElapseTime('computeFast', () { | 116 return request.performance.logElapseTime('computeFast', () { |
| 117 CompilationUnit unit = context.parseCompilationUnit(source); | 117 CompilationUnit unit = context.parseCompilationUnit(source); |
| 118 request.unit = unit; | 118 request.unit = unit; |
| 119 request.node = new NodeLocator.con1(request.offset).searchWithin(unit); | 119 request.node = new NodeLocator.con1(request.offset).searchWithin(unit); |
| 120 request.target = new CompletionTarget.forOffset(unit, request.offset); | 120 request.target = new CompletionTarget.forOffset(unit, request.offset); |
| 121 if (request.node == null) { |
| 122 return []; |
| 123 } |
| 121 | 124 |
| 122 request.replacementOffset = request.offset; | 125 request.replacementOffset = request.offset; |
| 123 request.replacementLength = 0; | 126 request.replacementLength = 0; |
| 124 var entity = request.target.entity; | 127 var entity = request.target.entity; |
| 125 Token token = entity is AstNode ? entity.beginToken : entity; | 128 Token token = entity is AstNode ? entity.beginToken : entity; |
| 126 if (token != null && | 129 if (token != null && |
| 127 token.offset <= request.offset && | 130 token.offset <= request.offset && |
| 128 (token.type == TokenType.KEYWORD || token.type == TokenType.IDENTIFIER
)) { | 131 (token.type == TokenType.KEYWORD || token.type == TokenType.IDENTIFIER
)) { |
| 129 request.replacementOffset = token.offset; | 132 request.replacementOffset = token.offset; |
| 130 request.replacementLength = token.length; | 133 request.replacementLength = token.length; |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 * Information about the types of suggestions that should be included. | 336 * Information about the types of suggestions that should be included. |
| 334 * The [target] must be set first. | 337 * The [target] must be set first. |
| 335 */ | 338 */ |
| 336 OpType get optype { | 339 OpType get optype { |
| 337 if (_optype == null) { | 340 if (_optype == null) { |
| 338 _optype = new OpType.forCompletion(target, offset); | 341 _optype = new OpType.forCompletion(target, offset); |
| 339 } | 342 } |
| 340 return _optype; | 343 return _optype; |
| 341 } | 344 } |
| 342 } | 345 } |
| OLD | NEW |