Skip to content

Commit

Permalink
Ignore ErrorToken when locating previous n tokens for completion ranking
Browse files Browse the repository at this point in the history
Bug: #37798
Change-Id: I65b2b57d874ccf8e748841f3d0742e883a91ec46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112702
Commit-Queue: Ari Aye <ariaye@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
  • Loading branch information
lambdabaa authored and athomas committed Aug 15, 2019
1 parent 20dcfd9 commit 21a6fe4
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/token.dart';
import 'package:front_end/src/fasta/scanner.dart';

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

final result = List<String>();
for (var size = 0; size < n && !token.isEof; token = token.previous) {
if (!token.isSynthetic) {
if (!token.isSynthetic && token is! ErrorToken) {
result.add(token.lexeme);
size += 1;
}
Expand Down

0 comments on commit 21a6fe4

Please sign in to comment.