rebar3_format icon indicating copy to clipboard operation
rebar3_format copied to clipboard

Option to not rewrite list constructions

Open elbrujohalcon opened this issue 5 years ago • 2 comments

In @michalmuskala words:

[1 | []] and [1] have exactly the same AST

That means the formatter won't preserve that source structure, which in some cases might be intentional.

elbrujohalcon avatar Jan 21 '20 13:01 elbrujohalcon

This might be impossible to solve due to ktn_dodger not returning the text for the whole structure, for complex structures… i.e. when parsing [1], the text property for the list is just "[".

elbrujohalcon avatar Jun 22 '20 08:06 elbrujohalcon

In the same way as https://github.com/AdRoll/rebar3_format/issues/167#issuecomment-780650290 … erl_syntax:subtrees/1 and other erl_syntax functions, like list_suffix/1, cons_suffix/1, etc… go to great lengths to hide the syntactic information to make stuff like [1, 2 | []] behave exactly equal to [1 | [2 | []]] and [1, 2]. 😢

As time passes and I work on new issues I'm getting more and more convinced that we'll eventually need to move away from the OTP way of parsing Erlang code (i.e. erl_syntax)…

elbrujohalcon avatar Feb 18 '21 10:02 elbrujohalcon