You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
var (
foo=1notFoo=2b=3aBitLonger=errors.New("an error")
)
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
vara=1varb=2// This is finevarc=3var (
d=4
)
var (
e=5// This should be finef=6
)
// Comment abovevarg=7varh=8// Comment after// Comment between with spacesvari=9// Between no spacesvarj=10
var (
a=1b=2// This is finec=3
)
var (
d=4e=5// This should be finef=6
)
// Comment abovevarg=7varh=8// Comment after// Comment between with spacesvari=9// Between no spacesvarj=10
The text was updated successfully, but these errors were encountered:
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:
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:The text was updated successfully, but these errors were encountered: