logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Perl::Tidy::Sweetened::Keyword::Block - Perl::Tidy::Sweetened filter plugin to define new subroutine and

Author

       Mark Grimes <mgrimes@cpan.org>

Bugs

       Please     report     any     bugs     or     feature     requests     on    the    bugtracker    website
       <https://github.com/mvgrimes/Perl-Tidy-Sweetened/issues>

       When submitting a bug or request, please include a test-file or a patch to  an  existing  test-file  that
       illustrates the bug or desired feature.

Description

       This is a Perl::Tidy::Sweetened filter which enables the definition of arbitrary keywords for subroutines
       with any number of potential signature definitions. New accepts:

       keyword
               keyword => 'method'

           Declares a new keyword (in this example the "method" keyword).

       marker
               marker => 'METHOD'

           Provides  a  text marker to be used to flag the new keywords during "prefilter". The source code will
           be filtered prior to formatting by Perl::Tidy such that:

               method foo {
               }

           is turned into:

               sub foo { # __METHOD 1
               }

       replacement
               replacement => 'sub'

           Will convert the keyword to a "sub" as shown above.

       clauses
               clauses => [ 'PAREN?' ]

           Provides a list of strings which will be turned into a regex to capture additional clauses. The regex
           will include the 'xm' flags (so be sure to escape spaces).  The clause can be  marked  optional  with
           '?'. The special text "PAREN" can be used to capture a balanced parenthetical.

           This example will capture a parameter list enclosed by parenthesis, ie:

               method foo (Int $i) {
               }

           No formatting is done on the clauses at this time. The order of declaration is significant.

Name

       Perl::Tidy::Sweetened::Keyword::Block - Perl::Tidy::Sweetened filter plugin to define new subroutine and
       class keywords

Source

       Source repository is at <https://github.com/mvgrimes/Perl-Tidy-Sweetened>.

Synopsis

           our $plugins = Perl::Tidy::Sweetened::Pluggable->new();

           $plugins->add_filter(
               Perl::Tidy::Sweetened::Keyword::Block->new(
                   keyword     => 'method',
                   marker      => 'METHOD',
                   replacement => 'sub',
                   clauses     => [ 'PAREN?', '(returns \s* PAREN)?' ],
               ) );

Version

       version 1.20

See Also