From 37fe7cfb0e232db5b8c630259811374f5ce090dc Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 2 Mar 2024 15:14:12 -0800 Subject: [PATCH] add caller name to hash of sub calls --- lib/Perl/Tidy/Formatter.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index 0f0ccc9b..3a2b77ed 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -13753,8 +13753,17 @@ sub update_sub_call_paren_info { $arg_count += 1; } - my $call_type = - $type_mm eq '->' ? '->' : $is_ampersand_call ? '&' : EMPTY_STRING; + my $call_type = $is_ampersand_call ? '&' : EMPTY_STRING; + my $caller_name = EMPTY_STRING; + if ( $type_mm eq '->' ) { + $call_type = '->'; + my $K_m = $self->K_previous_code($Ko); + my $K_mm = $self->K_previous_code($K_m); + my $K_mmm = $self->K_previous_code($K_mm); + if ( defined($K_mmm) && $rLL->[$K_mmm]->[_TYPE_] eq 'i' ) { + $caller_name = $rLL->[$K_mmm]->[_TOKEN_]; + } + } # update the hash of info for this item my $line_number = $rLL->[$Ko]->[_LINE_INDEX_] + 1; @@ -13763,6 +13772,7 @@ sub update_sub_call_paren_info { $item->{name} = $name; $item->{line_number} = $line_number; $item->{call_type} = $call_type; + $item->{caller_name} = $caller_name; } return; } ## end sub update_sub_call_paren_info -- 2.39.5