OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer/dart/ast/ast.dart'; | 5 import 'package:analyzer/dart/ast/ast.dart'; |
6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; | 6 import 'package:analyzer/dart/ast/standard_ast_factory.dart'; |
7 import 'package:analyzer/dart/ast/token.dart'; | 7 import 'package:analyzer/dart/ast/token.dart'; |
8 import 'package:analyzer/src/dart/ast/token.dart'; | 8 import 'package:analyzer/src/dart/ast/token.dart'; |
9 import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart' ; | 9 import 'package:analyzer_plugin/src/utilities/completion/completion_target.dart' ; |
10 | 10 |
11 /** | 11 /** |
12 * Utility class for computing the code completion replacement range. | 12 * Utility class for computing the code completion replacement range. |
13 */ | 13 */ |
14 class ReplacementRange { | 14 class ReplacementRange { |
15 // Copied from analysis_server/lib/src/services/completion/dart/completion_man ager.dart | 15 // Copied from analysis_server/lib/src/services/completion/dart/completion_man ager.dart |
16 int offset; | 16 int offset; |
Brian Wilkerson
2017/06/15 19:18:30
For public code we should probably make these fiel
danrubel
2017/06/15 19:39:45
I created it so that it would be obvious that this
maxkim
2017/06/15 20:31:22
Sure will submit in another CL.
Brian Wilkerson
2017/06/15 20:44:01
If we remove ReplacementRange in favor of using So
| |
17 int length; | 17 int length; |
18 | 18 |
19 ReplacementRange(this.offset, this.length); | 19 ReplacementRange(this.offset, this.length); |
20 | 20 |
21 factory ReplacementRange.compute(int requestOffset, CompletionTarget target) { | 21 factory ReplacementRange.compute(int requestOffset, CompletionTarget target) { |
22 bool isKeywordOrIdentifier(Token token) => | 22 bool isKeywordOrIdentifier(Token token) => |
23 token.type.isKeyword || token.type == TokenType.IDENTIFIER; | 23 token.type.isKeyword || token.type == TokenType.IDENTIFIER; |
24 | 24 |
25 //TODO(danrubel) Ideally this needs to be pushed down into the contributors | 25 //TODO(danrubel) Ideally this needs to be pushed down into the contributors |
26 // but that implies that each suggestion can have a different replacement | 26 // but that implies that each suggestion can have a different replacement |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 if (start <= requestOffset && requestOffset <= end) { | 59 if (start <= requestOffset && requestOffset <= end) { |
60 // Replacement range for import URI | 60 // Replacement range for import URI |
61 return new ReplacementRange(start, end - start); | 61 return new ReplacementRange(start, end - start); |
62 } | 62 } |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 return new ReplacementRange(requestOffset, 0); | 66 return new ReplacementRange(requestOffset, 0); |
67 } | 67 } |
68 } | 68 } |
OLD | NEW |