From 32e8dc3084a8dbe6ff857d72b7d5102e864e963b Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sat, 27 Jul 2024 16:13:28 -0700 Subject: [PATCH] add closing side comments for anonymous subs --- lib/Perl/Tidy.pm | 14 +++++----- lib/Perl/Tidy/Formatter.pm | 44 ++++++++++++++++---------------- lib/Perl/Tidy/HtmlWriter.pm | 6 ++--- lib/Perl/Tidy/VerticalAligner.pm | 2 +- perltidyrc | 4 +-- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 0dca348c..fbfcdffe 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -502,7 +502,7 @@ my $md5_hex = sub { my $octets = Encode::encode( "utf8", $buf ); my $digest = md5_hex($octets); return $digest; -}; +}; ## end $md5_hex = sub sub get_iteration_count { return $rstatus->{iteration_count}; @@ -668,7 +668,7 @@ EOM } } return $hash_ref; - }; + }; ## end $get_hash_ref = sub %input_hash = ( %defaults, %input_hash ); my $argv = $input_hash{'argv'}; @@ -3184,7 +3184,7 @@ sub compare_string_buffers { $str = substr( $str, 0, $lenmax ) . "..."; } return $str; - }; + }; ## end $truncate = sub while (1) { if ($linei) { $last_nonblank_line = $linei; @@ -3427,7 +3427,7 @@ sub generate_options { } } return; - }; + }; ## end $add_option = sub # Install long option names which have a simple abbreviation. # Options with code '!' get standard negation ('no' for long names, @@ -4975,7 +4975,7 @@ EOM } } return; - }; + }; ## end $check_blank_count = sub # check for reasonable number of blank lines and fix to avoid problems $check_blank_count->( 'blank-lines-before-subs', '-blbs' ); @@ -5431,7 +5431,7 @@ sub find_config_file { return 0 unless $config_file; ${$rconfig_file_chatter} .= "# Testing: $config_file\n"; return -f $config_file; - }; + }; ## end $exists_config_file = sub # Sub to search upward for config file my $resolve_config_file = sub { @@ -5455,7 +5455,7 @@ sub find_config_file { } } return $config_file; - }; + }; ## end $resolve_config_file = sub my $config_file; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index d551c969..9eaf2ab8 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -2148,7 +2148,7 @@ sub initialize_token_break_preferences { } } return; - }; + }; ## end $break_after = sub my $break_before = sub { my @toks = @_; @@ -2162,7 +2162,7 @@ sub initialize_token_break_preferences { } } return; - }; + }; ## end $break_before = sub $break_after->(@all_operators) if ( $rOpts->{'break-after-all-operators'} ); $break_before->(@all_operators) @@ -3280,7 +3280,7 @@ sub set_whitespace_flags { $ws = $rOpts_space_signature_paren == 0 ? WS_NO : WS_YES; } return $ws; - }; + }; ## end $ws_signature_paren = sub my $last_token = SPACE; my $last_type = 'b'; @@ -7568,7 +7568,7 @@ sub set_ci { return $is_block_with_ci{$block_type}; } return; - }; + }; ## end $map_block_follows = sub my $redo_preceding_comment_ci = sub { @@ -7582,7 +7582,7 @@ sub set_ci { } } return; - }; + }; ## end $redo_preceding_comment_ci = sub # Definitions of the sequence of ci_values being maintained: # $ci_last = the ci value of the previous non-blank, non-comment token @@ -8763,7 +8763,7 @@ sub scan_variable_usage { push @{$rblock_stack}, { seqno => $seqno, package => $current_package, rvars => $rvars }; return; - }; + }; ## end $push_block_stack = sub $push_block_stack->(SEQ_ROOT); @@ -8906,7 +8906,7 @@ sub scan_variable_usage { K => $KK, }; return; - }; + }; ## end $checkin_new_identifier = sub #-------------------------------------------------- # sub to update counts for a list of variable names @@ -8960,7 +8960,7 @@ sub scan_variable_usage { } } return; - }; + }; ## end $update_use_count = sub #----------------------------------------------- # sub to check for zero counts when stack closes @@ -8984,7 +8984,7 @@ sub scan_variable_usage { } } return; - }; + }; ## end $check_for_unused_names = sub #--------------------------------------- # sub to scan interpolated text for vars @@ -9001,7 +9001,7 @@ sub scan_variable_usage { $update_use_count->( $sigil_string, $word, $brace ); } return; - }; + }; ## end $scan_quoted_text = sub #------------------------------------------------------------- # sub to find the next opening brace seqno of an if-elsif- chain @@ -9058,7 +9058,7 @@ sub scan_variable_usage { $push_block_stack->( $seqno_block, $rpopped_vars ); } return; - }; + }; ## end $push_next_if_chain = sub my $scan_braced_id = sub { my ($KK) = @_; @@ -9098,7 +9098,7 @@ sub scan_variable_usage { } $update_use_count->( $sigil_string, $word, $bracket ); return; - }; + }; ## end $scan_braced_id = sub my $check_sub_signature = sub { my ($KK) = @_; @@ -9144,7 +9144,7 @@ sub scan_variable_usage { $push_block_stack->($seqno_brace); } return; - }; + }; ## end $check_sub_signature = sub #-------------------- # Loop over all lines @@ -10322,7 +10322,7 @@ sub interbracket_arrow_check { my $msg = "$first_word $num_changes '->'$ess1 at line$ess2 $str\n"; warning($msg); return; - }; + }; ## end $warn = sub # Complexity control flag: # =0 left container must just contain a single token @@ -14071,7 +14071,7 @@ sub count_list_elements { $KK_last_nb = $KK_last_last_nb; $KK_last_last_nb = undef; return; - }; + }; ## end $backup_on_last = sub #-------------------------------------------------------- # Main loop to scan the container looking for list items. @@ -14616,7 +14616,7 @@ sub count_sub_input_args { my $name = $rLL->[$K_mmm]->[_TOKEN_]; return unless ( $name =~ /^\$\w/ ); return $name; - }; + }; ## end $dollar_underscore_zero_name = sub my $rseqno_DOLLAR_underscore = $self->[_rDOLLAR_underscore_by_sub_seqno_]->{$seqno_block}; @@ -15490,7 +15490,7 @@ sub update_sub_call_paren_info { my $K_p = $self->K_previous_code($Ko); return unless ( $rLL->[$K_p]->[_TOKEN_] eq '$_' ); return 1; - }; + }; ## end $is_dollar_underscore_zero = sub #---------------------------------------------- # Loop over sequence numbers of all call parens @@ -16280,7 +16280,7 @@ sub cross_check_sub_calls { output_line => $output_line, }; return; - }; + }; ## end $push_call_arg_warning = sub my $push_return_warning = sub { my ( $letter, $note, $lno_return ) = @_; @@ -16300,7 +16300,7 @@ sub cross_check_sub_calls { output_line => $output_line, }; return; - }; + }; ## end $push_return_warning = sub #------------------- # Loop over each sub @@ -18378,7 +18378,7 @@ sub weld_nested_quotes { return if ( $test_type ne $quote_type ); } return 1; - }; + }; ## end $is_single_quote = sub # Length tolerance - same as previously used for sub weld_nested my $multiline_tol = @@ -18650,7 +18650,7 @@ sub mark_short_nested_blocks { my $length = $self->cumulative_length_before_K($K) - $starting_lentot; my $excess_length = $length + $length_tol - $maximum_text_length; return ($excess_length); - }; + }; ## end $excess_length_to_K = sub # loop over all containers my @open_block_stack; @@ -38276,7 +38276,7 @@ sub get_asub_block_label { } } return $block_label; -} +} ## end sub get_asub_block_label sub add_closing_side_comment { diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index cc3044e3..e626731a 100644 --- a/lib/Perl/Tidy/HtmlWriter.pm +++ b/lib/Perl/Tidy/HtmlWriter.pm @@ -233,7 +233,7 @@ sub add_toc_item { ${$rin_toc_package} = EMPTY_STRING; } return; - }; + }; ## end $end_package_list = sub my $start_package_list = sub { my ( $unique_name, $package ) = @_; @@ -244,7 +244,7 @@ sub add_toc_item { EOM ${$rin_toc_package} = $package; return; - }; + }; ## end $start_package_list = sub # start the table of contents on the first item if ( !${$rtoc_item_count} ) { @@ -788,7 +788,7 @@ sub pod_to_html { if ($in_toc) { push @toc, $line } } return; - }; + }; ## end $html_print = sub # loop over lines of html output from pod2html and merge in # the necessary perltidy html sections diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 17a265bd..0a43b4bc 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -3951,7 +3951,7 @@ sub prune_alignment_tree { ]; return; - }; ## end sub end_node + }; ## end $end_node = sub #----------------------------------------------------- # Prune Tree Step 2. Loop to form the tree of matches. diff --git a/perltidyrc b/perltidyrc index b8fc98f9..b270bc2d 100644 --- a/perltidyrc +++ b/perltidyrc @@ -26,9 +26,9 @@ # user-defined subs must have args in parens --want-call-parens='&' -# add closing side comments for named subs +# add closing side comments for subs --closing-side-comments ---closing-side-comment-list='sub' +--closing-side-comment-list='sub asub' # remove trailing commas followed by paren --want-trailing-commas='b' -- 2.39.5