Perl-LanguageServer icon indicating copy to clipboard operation
Perl-LanguageServer copied to clipboard

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

Open tipmaster opened this issue 3 years ago • 7 comments

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.

tipmaster avatar May 09 '21 14:05 tipmaster

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 avatar May 14 '21 12:05 tprommer

Anyone can comment?

tprommer avatar Jun 05 '21 12:06 tprommer

"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.

richterger avatar Jun 06 '21 08:06 richterger

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

willt avatar Sep 04 '21 17:09 willt

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) ;

sezal avatar Feb 09 '22 22:02 sezal

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

tipmaster avatar Jun 15 '23 00:06 tipmaster

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

richterger avatar Sep 23 '23 17:09 richterger