google / google/google-java-format

Incorrect behaviour on Text-blocks preceded by return

Đang mở
#1,258 2 bình luận 1 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
6.2k
Fork
937
Merge trung bình
6 phút
Pull request đã merge (30 ngày)
3

Mô tả

https://google.github.io/styleguide/javaguide.html#s4.8.9-text-blocks

> The opening """ of a text block is always on a new line. That line may either follow the same indentation rules as other constructs, or it may have no indentation at all (so it starts at the left margin). The closing """ is on a new line with the same indentation as the opening """, and may be followed on the same line by further code

Original code:
```java
$ cat TextBlocks.java
/** some javadoc. */
public class TextBlocks {

/** some javadoc. */
public static String textFun(String[] args) {

final String simpleScript = """
s
""";

final String simpleScript1 =
"""
this is simple test;
""";

final String simpleScript2 =
"""
this is sample text """;

return """
this is sample text
""";
}
}
```

Output by the formatter:
```java
$ java -jar testing/google-java-format-1.27.0-all-deps.jar TextBlocks.java
/** some javadoc. */
public class TextBlocks {

/** some javadoc. */
public static String textFun(String[] args) {
final String simpleScript =
""" // CORRECT BEHAVIOUR
s
""";

final String simpleScript1 =
"""
this is simple test;
""";

final String simpleScript2 =
"""
this is sample text\
"""; // CORRECT BEHAVIOUR

return """ // INCORRECT BEHAVIOUR
this is sample text
""";
}
}
```

I expected the opening quotations of the text-block after `return` to be on new line.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.