| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.manager; | 5 library services.completion.dart.manager; |
| 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/ide_options.dart'; | 10 import 'package:analysis_server/src/ide_options.dart'; |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 * Utility class for computing the code completion replacement range | 501 * Utility class for computing the code completion replacement range |
| 502 */ | 502 */ |
| 503 class ReplacementRange { | 503 class ReplacementRange { |
| 504 int offset; | 504 int offset; |
| 505 int length; | 505 int length; |
| 506 | 506 |
| 507 ReplacementRange(this.offset, this.length); | 507 ReplacementRange(this.offset, this.length); |
| 508 | 508 |
| 509 factory ReplacementRange.compute(int requestOffset, CompletionTarget target) { | 509 factory ReplacementRange.compute(int requestOffset, CompletionTarget target) { |
| 510 bool isKeywordOrIdentifier(Token token) => | 510 bool isKeywordOrIdentifier(Token token) => |
| 511 token.type == TokenType.KEYWORD || token.type == TokenType.IDENTIFIER; | 511 token.type.isKeyword || token.type == TokenType.IDENTIFIER; |
| 512 | 512 |
| 513 //TODO(danrubel) Ideally this needs to be pushed down into the contributors | 513 //TODO(danrubel) Ideally this needs to be pushed down into the contributors |
| 514 // but that implies that each suggestion can have a different | 514 // but that implies that each suggestion can have a different |
| 515 // replacement offsent/length which would mean an API change | 515 // replacement offsent/length which would mean an API change |
| 516 | 516 |
| 517 var entity = target.entity; | 517 var entity = target.entity; |
| 518 Token token = entity is AstNode ? entity.beginToken : entity; | 518 Token token = entity is AstNode ? entity.beginToken : entity; |
| 519 if (token != null && requestOffset < token.offset) { | 519 if (token != null && requestOffset < token.offset) { |
| 520 token = token.previous; | 520 token = token.previous; |
| 521 } | 521 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 544 if (start <= requestOffset && requestOffset <= end) { | 544 if (start <= requestOffset && requestOffset <= end) { |
| 545 // Replacement range for import URI | 545 // Replacement range for import URI |
| 546 return new ReplacementRange(start, end - start); | 546 return new ReplacementRange(start, end - start); |
| 547 } | 547 } |
| 548 } | 548 } |
| 549 } | 549 } |
| 550 } | 550 } |
| 551 return new ReplacementRange(requestOffset, 0); | 551 return new ReplacementRange(requestOffset, 0); |
| 552 } | 552 } |
| 553 } | 553 } |
| OLD | NEW |