Ticket #653 (closed defect: fixed)
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:
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.
Attachments
Change History
Changed 4 years ago by patrickas
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.
