Skip to content

Commit 21a6fe4

Browse files
lambdabaaathomas
authored andcommitted
Ignore ErrorToken when locating previous n tokens for completion ranking
Bug: #37798 Change-Id: I65b2b57d874ccf8e748841f3d0742e883a91ec46 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112702 Commit-Queue: Ari Aye <[email protected]> Reviewed-by: Dan Rubel <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 20dcfd9 commit 21a6fe4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

pkg/analysis_server/lib/src/services/completion/dart/completion_ranking_internal.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
88
import 'package:analyzer/dart/analysis/features.dart';
99
import 'package:analyzer/dart/ast/ast.dart';
1010
import 'package:analyzer/dart/ast/token.dart';
11+
import 'package:front_end/src/fasta/scanner.dart';
1112

1213
/// Constructs a [CompletionSuggestion] object.
1314
CompletionSuggestion createCompletionSuggestion(
@@ -160,7 +161,7 @@ List<String> constructQuery(DartCompletionRequest request, int n) {
160161

161162
final result = List<String>();
162163
for (var size = 0; size < n && !token.isEof; token = token.previous) {
163-
if (!token.isSynthetic) {
164+
if (!token.isSynthetic && token is! ErrorToken) {
164165
result.add(token.lexeme);
165166
size += 1;
166167
}

0 commit comments

Comments
 (0)