Ticket #653 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

Lexically Rename Variable doesn't work when clicking on declaration of variable

Reported by: waxhead Owned by: patrickas
Priority: major Milestone:
Component: editor Version: 0.50
Keywords: Cc:

Description

In the example code, taken straight from tsee's blog about refarctoring in padre:

# http://use.perl.org/~tsee/journal/39121


sub _derive_atan2 {

my ( $tree, $var, $cloned, $d_sub ) = @_;
# d/df atan(y/x) = x2/(x2+y2) * (d/df y/x)
my ($op1, $op2) = @{$tree->{operands}};
my $inner = $d_sub->( $op1->new()/$op2->new(), $var, 0 );
# templates
my $two = Math::Symbolic::Constant->new(2);
my $op = Math::Symbolic::Operator->new('+', $two, $two);

my $result = $op->new('*',

$op->new('/',

$op->new('', $op2->new(), $two->new()),
$op->new(

'+', $op->new('', $op2->new(), $two->new()),
$op->new('
', $op1->new(), $two->new())

)

),
$inner

);
return $result;

}

To see the problem, on the line:

my ($op1, $op2) = @{$tree->{operands}};

click on either $op1 or $op2 and try to Lexically Rename them.

You get an error:

No declaration could be found for the specified (lexical?) variable

You can get this to work by selecting any other occurance of the variable name in the code block.

But this isn't what you'd expect.

Change History

comment:1 Changed 5 years ago by waxhead

  • Owner set to azawawi
  • Status changed from new to assigned

comment:2 Changed 4 years ago by patrickas

  • Owner changed from azawawi to patrickas
  • Status changed from assigned to accepted
  • Version changed from 0.47 to 0.50

The patch attached should fix the issue.

However, I noticed there were two declarations for the sub find_variable_declaration in

http://svn.perlide.org/padre/trunk/PPIx-EditorTools/lib/PPIx/EditorTools.pm

and in

http://svn.perlide.org/padre/trunk/Padre/lib/Padre/PPI.pm

The two subs are slightly different and this change makes them even more different.

I have no idea if they should be the same or if they are different on purpose.

comment:3 Changed 4 years ago by patrickas

Smaller test case:

my ($foo , $bar);

Place the cursor over $bar and select "Find variable declaration"

comment:4 Changed 4 years ago by Sewi

Fixed in r9181

comment:5 Changed 4 years ago by patrickas

  • Status changed from accepted to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.