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

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

Issue 2936143002: update statement completion for fasta scanner (Closed)
Patch Set: 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..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;
}
« 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