Perl5-IDEA icon indicating copy to clipboard operation
Perl5-IDEA copied to clipboard

Jumping to definitions doesn't work when defined like $self->{PAYMENT} = PayPal->new();

Open Baetek opened this issue 4 years ago • 3 comments

Hey, this is a truly incredible project, hats off to you. I am trying to convince my company to switch to this Perl IDE to make our dev team life A TONNE easier, and the company would likely support your project then.

I have a problem though, one big selling point is being able to jump to function definitions with CTRL+Click. But a lot of our codebase is like this:

test.pl:

sub new {
$self->{PAYMENT_METHOD} = PayPal->new();
}

sub transaction {
 $self->{PAYMENT_METHOD}->get_transaction();
}

then CTR+Click on get_transaction() shows 'can't find declaration to go to'.

if we just did something like $paypal = PayPal->new(); then CTRL+Click on $paypal->get_transaction(); does take me to the get_transaction definition in PayPal.pl

The problem is the code base is enormous and most of it uses this style of definitions: $something->{sampleAccessor} .

Would you expect this to work? Is this style just not implemented in the plugin or is it my system? The Perl interpreter version is 5.32.1 on Linux, and the Perl Target version is v5.26, although switching to other versions doesn't appear to fix it.

Thank you very much!

Baetek avatar Mar 30 '21 18:03 Baetek

For now it works only with intermediate variable with explicit type like my PayPal $paypal = $self->{PAYMENT_METHOD} or getter in class:

sub new {
$self->{PAYMENT_METHOD} = PayPal->new();
}

#@returns PayPal
sub payment_method{
    shift->{PAYMENT_METHOD}
}

sub transaction {
 ...
 $self->payment_method->get_transaction();
}

Solving this would be nice, but no estimations so far.

hurricup avatar Mar 31 '21 06:03 hurricup

Why doesn't it work

# Cannot find declaration to go to
$self->obj->method(); 

but this works fine?

# no annotations
my $foo = $self->obj;

# declaration is found
$foo->method();

Is it depend on amount of ref before method?

$self->ref->ref->ref->ref->ref->method();

zurom avatar Feb 19 '24 14:02 zurom

no, this is expected to work. Can you provide a reproducible sample? And plugin/ide versions.

hurricup avatar Feb 20 '24 04:02 hurricup