richterger / Perl-LanguageServer

Language Server for Perl
Other
222 stars 53 forks source link

Should "Go To Definition" for package/module navigation be working currently? #94

Open tipmaster opened 3 years ago

tipmaster commented 3 years ago

From everything I researched online it did not become clear to me if "Go To Definition" for package/module navigation is currently supported or not?

Putting a screenshot below to show exactly what I am referring to and what currently is showing an error 'no definition found'. The path to the directories where the modules are located is set as absolute paths in PERL5LIB, PERLLIB and as "perl.perlInc" in the settings.json.

Am I missing something or is this functionality that just isn't currently supported?

Screenshot error message and configuration: https://imgur.com/a/bVhHUyO

I did activate the logs of the language server but that did not return anything meaningful.

tprommer commented 3 years ago

Anyone with any feedback? A "no this is currently not meant to be supported" is totally acceptable. We are just trying to understand the current status.

tprommer commented 3 years ago

Anyone can comment?

richterger commented 3 years ago

"Go To Definition" for package/module is not currently supported. It shouldn't be too hrad to implement. Mainly the parser in Perl::LanguageServer::Methods::textDocument get_symbol_from_doc needs be a little smarter to return full package names. The Information about package definition is already available inside the LanguageServer.

willt commented 2 years ago

+1 for me on this. Any more hints to get this working?

sezal commented 2 years ago

Probably not perfect fix, but helped.

--- /opt/local/lib/perl5/vendor_perl/5.28/Perl/LanguageServer/Methods/textDocument.pm.bak   2021-07-11 09:43:10.000000000 -0700
+++ /opt/local/lib/perl5/vendor_perl/5.28/Perl/LanguageServer/Methods/textDocument.pm   2022-02-09 14:07:46.000000000 -0800
@@ -26,7 +26,7 @@
     my $datapos = $-[1] ;
     $self -> logger ("line $line: <$data>\n") if ($Perl::LanguageServer::debug2) ;

-    while ($data =~ /([a-zA-Z0-9_\$\%\@]+)/g)
+    while ($data =~ /([:a-zA-Z0-9_\$\%\@]+)/g)
         {
         my $pos = pos ($data) ;
         my $len = length ($1) ;
tipmaster commented 1 year ago

Coming back to this: what I am experiencing right now is that in VSCode it can jump to the right class files but when it comes to deep linking into methods it is not able to differentiate A::B::C::init from A::B::D::init although the full path is specified in the code?

Is that expected and should motivate me to write more unique method names or am I missing something in the configuration? Screenshot attached.

screenshot

richterger commented 10 months ago

Perl::LanhguageServer is only looking at the method name and does not take the package name into account. You can either use different method names or you enhance the Parser in Perl::LanguageServer and send a pull requst