Chromium Code Reviews| Index: pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart |
| diff --git a/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart |
| index 9fb70bab53b14f87d7c808befc55bf91e758584f..7f3af3fe998cb9c43bb958f4c97db688f726c8b8 100644 |
| --- a/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart |
| +++ b/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart |
| @@ -127,6 +127,9 @@ class DartCompletionManager extends CompletionManager { |
| */ |
| List<DartCompletionContributor> computeFast( |
| DartCompletionRequest request, CompletionPerformance performance) { |
| + bool isKeywordOrIdentifier(Token token) => |
| + token.type == TokenType.KEYWORD || token.type == TokenType.IDENTIFIER; |
| + |
| return performance.logElapseTime('computeFast', () { |
| CompilationUnit unit = context.parseCompilationUnit(source); |
| request.unit = unit; |
| @@ -140,12 +143,19 @@ class DartCompletionManager extends CompletionManager { |
| var entity = request.target.entity; |
| Token token = entity is AstNode ? entity.beginToken : entity; |
| - if (token != null && |
| - token.offset <= request.offset && |
| - (token.type == TokenType.KEYWORD || |
| - token.type == TokenType.IDENTIFIER)) { |
| - request.replacementOffset = token.offset; |
| - request.replacementLength = token.length; |
| + if (token != null && request.offset < token.offset) { |
|
Brian Wilkerson
2015/08/03 13:53:07
Does this need to be a loop, or is the previous to
danrubel
2015/08/03 21:00:12
I considered that but did not have a test case tha
|
| + token = token.previous; |
| + } |
| + if (token != null) { |
| + if (request.offset == token.offset && !isKeywordOrIdentifier(token)) { |
|
Brian Wilkerson
2015/08/03 13:53:07
A comment about why this is necessary would be goo
danrubel
2015/08/03 21:00:12
Good point. Added.
|
| + token = token.previous; |
| + } |
| + if (token != null && isKeywordOrIdentifier(token)) { |
| + if (token.offset <= request.offset && request.offset <= token.end) { |
| + request.replacementOffset = token.offset; |
| + request.replacementLength = token.length; |
| + } |
| + } |
| } |
| List<DartCompletionContributor> todo = new List.from(contributors); |