google / google/google-java-format
Incorrect behaviour on Text-blocks preceded by return
- Linguagem predominante
- Java
- Estrelas
- 6.2k
- Forks
- 937
- Merge médio
- 6min
- PRs com merge (30d)
- 3
Descrição
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.
Guia de contribuição
Direção de pesquisa
Start by reproducing the issue with the TextBlocks.java example using google-java-format-1.27.0-all-deps.jar, comparing text blocks assigned to variables with the one following return. Trace the formatter’s handling of a return statement followed by a text block; done means the opening quotes after return are placed on a new line without changing the other demonstrated formatting.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- java
- Domínio
- tooling
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 45/100