redhat-developer / lsp4ij

LSP Client for IntelliJ
Eclipse Public License 2.0
105 stars 23 forks source link

Open references if definition result has the same range than clicked offset #531

Open InSyncWithFoo opened 1 month ago

InSyncWithFoo commented 1 month ago

Currently Ctrl + Click always send textDocument/definition, which might not be ideal when the definition itself is clicked. LSP4IJ integrators should be able to configure that programmatically.

(Filed as requested at this issue.)

CppCXY commented 1 month ago

in VSCode, when you ctrl + click on a reference, it first sends a textDocument/definition request. If the returned range overlaps with the clicked position, it then sends a textDocument/references request.

CppCXY commented 1 month ago

test

angelozerr commented 1 month ago

Thanks so much @CppCXY for your information.

I see now more the benefit to consume references.

@InSyncWithFoo is it the same usecase in the reported issue from your project?

InSyncWithFoo commented 1 month ago

Yes, that's probably the best behaviour.

angelozerr commented 1 month ago

Yes, that's probably the best behaviour.

Indeed, but do you think it is the behavior that user would like to have?

InSyncWithFoo commented 1 month ago

Of course. They want a panel; we should give them a panel.

angelozerr commented 1 month ago

@InSyncWithFoo after debugging Java support in IJ, I undertand more how the go to declaration is working.

There are 2 means to manage go to declaration:

What do you think about that @InSyncWithFoo : loosing go to definition (but I think PyCharm should work good) but benefit with Show references panel (and for other language the proper hyperlinked). For many language I think using ImplicitReferenceProvider#getImplicitReferences will be very nice,but before doing that I would liketo know your feeling. If you don't want to loose the LSP go to definition, perhaps we should provide an API to know if the language server must use GotoDeclarationHandler or ImplicitReferenceProvider.

InSyncWithFoo commented 1 month ago

Either seems suboptimal. Hyperlinking is a small problem, so I slightly prefer the first in this "choose your poison" situation.

I'm not familiar with these extension points though. Take this comment only at face value.