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: prefer non-export definition locations #20252

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

kasiaMarek
Copy link
Contributor

.filter(_.source == sym.source)
.partition(_.tree.symbol.is(Exported))

otherDefs.headOption.orElse(exportedDefs.headOption) match
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if instead of returning the head option we returned all the locations, in that List(loc) below, so that then downstream can show users a choice of location (i.e. the source of the export and the original)?

Other than that lgtm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, that makes sense. However, for this particular case it will cause an inconsistency in Metals. If the definition and user's cursor are not in the same file, pc will use Metals's symbol search, and that search will not be able to find the export <smth>.*. So I am not sure that it would be better.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that lgtm

@kasiaMarek kasiaMarek requested a review from tgodzik April 26, 2024 07:51
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We can switch to showing export location also if needed, but that is more complex, since semanticdb doesn't contain the symbols within the file with exports

@tgodzik tgodzik merged commit 5c8e5e2 into scala:main Apr 29, 2024
19 checks passed
@tgodzik tgodzik added area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. labels Apr 29, 2024
@tgodzik tgodzik removed the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label May 8, 2024
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
WojciechMazur added a commit that referenced this pull request Jul 6, 2024
Backports #20252 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:presentation-compiler Related to the presentation compiler module used by Metals and possibly other tools
Projects
None yet
4 participants