Issue 33034. Fix statement completion with missing condition right parenthesis.

Bug: https://github.com/dart-lang/sdk/issues/33034
Change-Id: I87a47e5ddc41596b4bcd0c07d250a7afb00546ef
Reviewed-on: https://dart-review.googlesource.com/53680
Reviewed-by: Steve Messick <messick@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2018-05-03 17:48:53 +00:00 committed by commit-bot@chromium.org
parent 3fd2d5fb05
commit 9d10a6ad4a
2 changed files with 24 additions and 0 deletions

View file

@ -804,6 +804,9 @@ class StatementCompletionProcessor {
if (_isSyntheticExpression(statement.condition)) {
exitPosition = _newPosition(statement.leftParenthesis.offset + 1);
sb = new SourceBuilder(file, statement.rightParenthesis.offset + 1);
} else if (statement.rightParenthesis.isSynthetic) {
sb = new SourceBuilder(file, statement.condition.end);
sb.append(')');
} else {
int afterParen = statement.rightParenthesis.offset + 1;
if (utils

View file

@ -1235,6 +1235,27 @@ main() {
(s) => _after(s, ' '));
}
test_withCondition_noRightParenthesis() async {
await _prepareCompletion(
'if (true',
'''
main() {
if (true
}
''',
atEnd: true);
_assertHasChange(
'Complete if-statement',
'''
main() {
if (true) {
////
}
}
''',
(s) => _after(s, ' '));
}
test_withElse() async {
await _prepareCompletion(
'else',