google / google/google-java-format
Conditional OpenOp / CloseOp
- Linguagem predominante
- Java
- Estrelas
- 6.2k
- Forks
- 937
- Merge médio
- 6min
- PRs com merge (30d)
- 3
Descrição
In `ktfmt`, I'd like to format the following:
```
fun longName() = coroutineScope {
foo()
//
}
```
but if it doesn't fit in a single line, I'd like to get
```
fun longName() =
coroutineScope {
foo()
//
}
```
I only managed to create the first form by _not_ wrapping the lambda in an `OpenOp` / `CloseOp` block, while the second form arises naturally from such a block around `coroutine { … }`.
One way to solve this is to create a conditional `OpenOp` / `CloseOp`, similarly to `Indent.If`, and then emit a block that materializes only if there had been a break after the `=`.
What do you think?
(I admit this isn't super clear, let me know if I should make another attempt at explaining this)
cc @cushon @bethcutler
Guia de contribuição
Direção de pesquisa
Comece rastreando o tratamento de OpenOp e CloseOp pelo formatter e, em seguida, compare-o com Indent.If. Reproduza o exemplo de coroutineScope e determine como as quebras de linha após o sinal de igual afetam a indentação. O trabalho estará concluído quando tanto a forma compacta quanto a forma com quebra de linha forem produzidas corretamente, com testes cobrindo esse comportamento.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- java
- Domínio
- tooling
- Tipo de issue
- Funcionalidade
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 35/100