Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments are attached to wrong import declarations #76

Open
mrkkrp opened this issue Mar 19, 2019 · 0 comments
Open

Comments are attached to wrong import declarations #76

mrkkrp opened this issue Mar 19, 2019 · 0 comments

Comments

@mrkkrp
Copy link

mrkkrp commented Mar 19, 2019

We have noticed an inadequate behavior with respect to how comment annotations are generated for import sections. Indeed, it's rather counter-intuitive, for example:

import Foo -- (1)
import Bar -- (2)
import Baz -- (3)

Here, contrary to what a programmer could have meant, -- (1) is saved in the annotation for import Bar, while -- (2) is saved in annotation for import Baz. import Foo doesn't have any comments associated with it, while -- (3) is a comment attached to the entire module.

One could see how wrong this is if we try to do any sort of meaningful transformation on parsed source, such as reordering of imports. Indeed, as simple as it seems, this cannot be done in a satisfactory fashion unless we manage to reassign comments somehow.

Currently we get:

-- (2)
import Bar
-- (3)
import Baz
import Foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant