Skip to content

Commit 712d267

Browse files
committed
Update UseTextBlocks, the string Literal's value should be the original string content.
1 parent 2ca989a commit 712d267

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main/java/org/openrewrite/java/migrate/lang/UseTextBlocks.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ private J.Literal toTextBlock(J.Binary binary, String content, List<J.Literal> s
116116
}
117117

118118
StringBuilder sb = new StringBuilder();
119-
119+
StringBuilder originalContent = new StringBuilder();
120120
stringLiterals = stringLiterals.stream().filter(s -> !s.getValue().toString().isEmpty()).collect(Collectors.toList());
121121
for (int i = 0; i < stringLiterals.size(); i++) {
122122
String s = stringLiterals.get(i).getValue().toString();
123123
sb.append(s);
124+
originalContent.append(s);
124125
if (i != stringLiterals.size() - 1) {
125126
String nextLine = stringLiterals.get(i + 1).getValue().toString();
126127
char nextChar = nextLine.charAt(0);
@@ -152,7 +153,7 @@ private J.Literal toTextBlock(J.Binary binary, String content, List<J.Literal> s
152153
content = content + "\\\n" + indentation;
153154
}
154155

155-
return new J.Literal(randomId(), binary.getPrefix(), Markers.EMPTY, content,
156+
return new J.Literal(randomId(), binary.getPrefix(), Markers.EMPTY, originalContent.toString(),
156157
String.format("\"\"\"%s\"\"\"", content), null, JavaType.Primitive.String);
157158
}
158159
};

0 commit comments

Comments
 (0)