Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Unified Diff: pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart

Issue 2936143002: update statement completion for fasta scanner (Closed)
Patch Set: address comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/ast/utilities.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart b/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
index 1a6945a65b9cbdd2c7e6630e68090282c2e89db2..133bd70fd78eefd9cbc71ec9fc2669016d2a527d 100644
--- a/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
+++ b/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
@@ -328,7 +328,8 @@ class StatementCompletionProcessor {
_removeError(ScannerErrorCode.UNTERMINATED_STRING_LITERAL);
_addInsertEdit(loc, delimiter);
}
- expr = errorMatching(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
+ expr = errorMatching(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "']'") ??
+ errorMatching(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
if (expr != null) {
expr = expr.getAncestor((n) => n is ListLiteral);
if (expr != null) {
@@ -343,6 +344,7 @@ class StatementCompletionProcessor {
_addInsertEdit(loc, ']');
}
_removeError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
+ _removeError(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "']'");
var ms =
_findError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "';'");
if (ms != null) {
@@ -425,7 +427,10 @@ class StatementCompletionProcessor {
_findError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "';'");
if (error != null) {
int insertOffset;
- if (expr == null || expr.isSynthetic) {
+ // Fasta scanner reports unterminated string literal errors
+ // and generates a synthetic string token with non-zero length.
+ // Because of this, check for length == 0 rather than isSynthetic.
+ if (expr == null || expr.length == 0) {
if (node is ReturnStatement) {
insertOffset = (node as ReturnStatement).returnKeyword.end;
} else if (node is ExpressionStatement) {
@@ -828,7 +833,8 @@ class StatementCompletionProcessor {
bool _complete_methodCall() {
var parenError =
- _findError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "')'");
+ _findError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "')'") ??
+ _findError(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "')'");
if (parenError == null) {
return false;
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/dart/ast/utilities.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698