google / google/google-java-format

Inconsistency between indent level in AOSP and non-aosp

Aberta
#1,189 2 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
Java
Estrelas
6.2k
Forks
937
Merge médio
6min
PRs com merge (30d)
3

Descrição

I am not entirely sure wether this is the intended behavior, so here is an issue. The the continuation of the long string doesn't indent with 8 spaces from the previous line which I would expect in AOSP.

Test.java
```java
public class Test {
String s = "asdfasdfasdfasdf asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}
```

```bash
❯ java -jar ~/Downloads/google-java-format-1.24.0-all-deps.jar Test.java
public class Test {
String s =
"asdfasdfasdfasdf"
+ " asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}
```

```bash
❯ java -jar ~/Downloads/google-java-format-1.24.0-all-deps.jar --aosp Test.java
public class Test {
String s =
"asdfasdfasdfasdf"
+ " asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}
```

I would expect the following output using AOSP style

```java
public class Test {
String s =
"asdfasdfasdfasdf"
+ " asdfasdfasdfasdfasdfasdffasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasd";
}
```

I raised this issue in the spotless repo because I figured that spotless not indenting the same way as GJF would be a spotless bug.

If this is the intended behavior, please let me know, so that I can reraise the issue at spotless.

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Reproduce the report with the Test.java example and run google-java-format both with and without --aosp. Compare the continuation-string indentation with the expected AOSP output, then inspect the formatter behavior responsible for that difference. Done means the AOSP result is clarified or corrected and covered by an appropriate regression test.

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
35/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.