wsl
wsl copied to clipboard
Group `DeclStmt` instead of splitting with empty lines
Currently the fixer does not do any rewrite other than adding or removing empty lines. Usually this is the only thing we can do but there are cases where we can do more complex rewrites.
The original idea with declarations should never be cuddled was to convert like this:
From | To |
---|---|
|
|
Mostly because it aligns the variables which when a lot of them are stacked (can for someone like me) improve readability.
This was implemented fairly easy in the original PR but after digging deeper with edge cases around comments it became very complex to figure out where comments would end up. Working with comments in general is very annoying due to the fact that they're not a part of the ast. I tried to use dst which helps a lot but even dst
can behave different depending on the context in regards to which node a comment gets tied to.
I want to keep tracking this because it would be a nice feature and I think a decent compromise would be to merge all DeclStmt
that has no comment or is a single line with a comment after the node since that would probably cover a majority of the cases. Something like this:
From | To |
---|---|
|
|