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

fix: Fix sniper-printing of method imports #3744

Merged

Conversation

slarse
Copy link
Collaborator

@slarse slarse commented Jan 7, 2021

Fix #3743

This PR fixes a problem with the Sniper printer, in that the start and end of source fragments would become messed up on method imports. The cause was that method imports have type reference children (e.g. the return type) that are defined in the file in which the method itself is defined, which in turn causes the method import to have children with source positions in a different file. This causes issues when recursively resolving the start and end position of the element.

The fix in this PR is to not link source fragments from different files. An exception is made for children of compilation units, as renaming a type with Refactorings.changeTypeName causes it's CU to get a different source file (unsure if this is a bug or not, but that's the way it is right now). So, children of compilation units are allowed to originate from a different file than the CU itself.

This PR should resolve the problems in Sorald detailed in ASSERT-KTH/sorald#275

@slarse slarse changed the title wip: fix: Fix Sniper printing of method imports review: fix: Fix Sniper printing of method imports Jan 7, 2021
@monperrus monperrus changed the title review: fix: Fix Sniper printing of method imports fix: Fix sniper-printing of method imports Jan 12, 2021
@monperrus monperrus merged commit 0d3d34b into INRIA:master Jan 12, 2021
@monperrus
Copy link
Collaborator

Thanks a lot @slarse, good work!

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

Successfully merging this pull request may close these issues.

bug: Sniper printer crashes on printing method import for which the method source is available
2 participants