Don't add empty leading/trailing strings in multiline strings.

Bug:
Change-Id: Ia556ecb8bbffe94808de34340d60cfff74464476
Reviewed-on: https://dart-review.googlesource.com/32520
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2018-01-04 22:31:34 -08:00 committed by commit-bot@chromium.org
parent d16eeb5eb8
commit 560fb2998d
3 changed files with 19 additions and 5 deletions

View file

@ -4210,6 +4210,17 @@ void main() {
}
}
test_stringInterpolation_multiLine_emptyBeforeAfter() async {
addTestFile(r"""
void main() {
var v = 42;
'''$v''';
}
""");
AnalysisResult result = await driver.getResult(testFile);
expect(result.errors, isEmpty);
}
test_super() async {
String content = r'''
class A {

View file

@ -1363,8 +1363,10 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
// Contains more than just \' or \".
if (first.lexeme.length > 1) {
String value = unescapeFirstStringPart(first.lexeme, quote);
expressions.add(
new ShadowStringLiteral(value)..fileOffset = offsetForToken(first));
if (value.isNotEmpty) {
expressions.add(new ShadowStringLiteral(value)
..fileOffset = offsetForToken(first));
}
}
for (int i = 1; i < parts.length - 1; i++) {
var part = parts[i];
@ -1381,8 +1383,10 @@ class BodyBuilder extends ScopeListener<JumpTarget> implements BuilderHelper {
// Contains more than just \' or \".
if (last.lexeme.length > 1) {
String value = unescapeLastStringPart(last.lexeme, quote);
expressions.add(
new ShadowStringLiteral(value)..fileOffset = offsetForToken(last));
if (value.isNotEmpty) {
expressions.add(new ShadowStringLiteral(value)
..fileOffset = offsetForToken(last));
}
}
push(new ShadowStringConcatenation(expressions)
..fileOffset = offsetForToken(endToken));

View file

@ -98,7 +98,6 @@ rasta/issue_000036: Crash
rasta/issue_000039: VerificationError
rasta/issue_000042: Crash
rasta/issue_000044: Crash
rasta/issue_000045: Crash
rasta/issue_000067: Crash
rasta/issue_000068: Crash
rasta/issue_000069: Crash