[java-injection] Fix handling of empty lines in text blocks

GitOrigin-RevId: e3887bb5c7504d925dab62be8b7182a654b2cc0c
This commit is contained in:
Tagir Valeev
2024-01-26 10:22:51 +00:00
committed by intellij-monorepo-bot
parent 52f82c8921
commit bee9170893
3 changed files with 5 additions and 2 deletions
@@ -9,6 +9,7 @@ public class Hello {
void test(@Subst("MyClass") String name, String message) {
String s = JAVA."""
import static java.lang.System.*;
class \{name} {
private MyClass() {
}
@@ -9,6 +9,7 @@ public class Hello {
void test(@Subst("MyClass") String name, String message) {
String s = JAVA."""
import static java.lang.System.*;
<caret>class \{name} {
void main(int x) {
if (x > 0) {
@@ -436,8 +436,9 @@ public final class ConcatenationInjector implements ConcatenationAwareInjector {
while (endOffset > 0) {
endOffset++;
result.add(new TextRange(startOffset, endOffset));
startOffset = endOffset + indent;
endOffset = text.indexOf('\n', startOffset);
int newEndOffset = text.indexOf('\n', endOffset);
startOffset = Math.min(endOffset + indent, newEndOffset == -1 ? Integer.MAX_VALUE : newEndOffset);
endOffset = newEndOffset;
}
endOffset = textRange.getEndOffset();
if (startOffset <= endOffset) {