scalameta / metals-feature-requests

Issue tracker for Metals feature requests
37 stars 4 forks source link

Allow to exclude import statements when using find references #304

Open PiotrBosak opened 2 years ago

PiotrBosak commented 2 years ago

Describe the feature

It would be nice if there was an option to exclude all the import statements when referencing a symbol. Sometimes it might get quite noisy.

https://user-images.githubusercontent.com/65810468/190855458-a563b0fc-086a-4930-8e7c-c17b2e0b2f1f.mov

Potential ways to implement

I think having shortcuts for finding references both with and without import statements would be useful, so I guess having it as a parameter to a function rather than a more static setting like excludedPackages would be a better choice.

I'd be happy to try to do it myself, but I'd need some guidance on how to approach it.

PiotrBosak commented 2 years ago

I was told on discord that it might be a good idea to move this issue to metals itself as it's not a vim specific problem. If that's the case(meaning it should be addressed in metals), then I'll go ahead and do so.

ckipp01 commented 2 years ago

Thanks for the request @PiotrBosak. As you mentioned this functionality is sort of generic, so I've moved it to the Metals feature request repo.

tgodzik commented 2 years ago

Thanks for reporting! This would probably require an additional user setting that would by default also show import statements.

The tricky part is figuring out if it's an import, since we don't have that information in semanticdb and we want to keep find references as fast as possible. We could check the tree for each file and filter out any positions in the import statements, but that might not be ideal for larger workspace since we would need to parse much more files. Any other approach (such as tokenizing) might have a lot of edge cases.