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..44754d63e85b7a43f0ff3e4cfce667ffa25c851e 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 |
@@ -329,6 +329,10 @@ class StatementCompletionProcessor { |
_addInsertEdit(loc, delimiter); |
} |
expr = errorMatching(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "']'"); |
+ if (expr == null) { |
Brian Wilkerson
2017/06/14 04:14:31
You could also use `??` to avoid the extra weight
danrubel
2017/06/14 06:05:41
Good point. Done.
|
+ expr = |
+ errorMatching(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "']'"); |
+ } |
if (expr != null) { |
expr = expr.getAncestor((n) => n is ListLiteral); |
if (expr != null) { |
@@ -343,6 +347,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 +430,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. |
Brian Wilkerson
2017/06/14 04:14:31
If `isSynthetic` doesn't always return a valid res
|
+ if (expr == null || expr.length == 0) { |
if (node is ReturnStatement) { |
insertOffset = (node as ReturnStatement).returnKeyword.end; |
} else if (node is ExpressionStatement) { |
@@ -829,6 +837,10 @@ class StatementCompletionProcessor { |
bool _complete_methodCall() { |
var parenError = |
_findError(ParserErrorCode.EXPECTED_TOKEN, partialMatch: "')'"); |
+ if (parenError == null) { |
+ parenError = |
+ _findError(ScannerErrorCode.EXPECTED_TOKEN, partialMatch: "')'"); |
+ } |
if (parenError == null) { |
return false; |
} |