PPIx::...ariable(3pm)

πŸ“¦
version 0.21 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute

πŸ’– PPIx::...ariable(3pm) β€” the manual page, but make it fashion πŸ’–

okay bestie, gather round, because today we're talking about PPIx::EditorTools::RenameVariable β€” it lives in the User Contributed Perl Documentation section, and yeah the manual name up top is a little cursed (PPIx::...ariable(3pm), they really said "abbreviate the middle, it'll be fine") but the module itself? iconic. it lexically replaces variable names in Perl code. that's the whole gig. slay. πŸŽ€


✨ VERSION ✨

version 0.21</purl> β€” that's the one, no cap. πŸ’…


🌈 SYNOPSIS 🌈

look at her go:

my $munged = PPIx::EditorTools::RenameVariable->new->rename(
    code        => $code,
    line        => 15,
    column      => 13,
    replacement => 'stuff',
);
my $code_as_strig = $munged->code;
my $code_as_ppi   = $munged->ppi;
my $location      = $munged->element->location;

(yes, $code_as_strig is spelled like that in the original. we do not fix it. we respect her. 🫢)


πŸ¦‹ DESCRIPTION πŸ¦‹

bestie. this module lexically replaces a variable name. that's it, that's the vibe. it finds the variable, it swaps the name, it moves on with main character energy. ✨


πŸ’… METHODS πŸ’…

🌸 new()

constructor energy. generally shouldn't be called with any arguments β€” like, just let her be, she knows what she's doing. πŸ™ˆ

🌸 rename( ppi => PPI::Document $ppi, line => Int, column => Int, replacement => Str )

🌸 rename( code => Str $code, line => Int, column => Int, replacement => Str )

🌸 rename( code => Str $code, line => Int, column => Int, to_camel_case => Bool, [ucfirst => Bool] )

🌸 rename( code => Str $code, line => Int, column => Int, from_camel_case => Bool, [ucfirst => Bool] )

so here's the tea β˜• β€” you hand her either a PPI::Document to process, or a string with the code in it (and she'll convert that into a PPI::Document herself, she's capable). then she renames the variable found at line, column with whatever you put in the replacement parameter. and she gives you back a PPIx::EditorTools::ReturnObject with the new code chillin' in the ppi or code accessors β€” as a PPI::Document or a string, respectively, iykyk. the PPI::Token she found at line, column? that's available through the element accessor. πŸ’–

and listen β€” instead of specifying an explicit replacement variable name, you can use the to_camel_case or from_camel_case options, which automatically convert to/from camelCase. in that mode, the ucfirst option will force uppercasing of the first letter. lowercase-to-Uppercase glow-up, we love to see it. πŸ”₯

⚠️ but fr fr: you can not specify a replacement name and use the to/from_camel_case options. pick a lane, bestie. not both. 🚫

and the dramatic parts, because we keep it real:

  • she croaks with a "no token" exception if no token is found at the location. πŸ’€
  • she croaks with a "no declaration" exception if she's unable to find the declaration. 😭

πŸ‘‘ SEE ALSO πŸ‘‘

this class inherits from PPIx::EditorTools. also go look at App::EditorTools, Padre, and PPI. the whole friend group. 🫢


🌟 AUTHORS 🌟

the legends, in order:

  • Steffen Mueller smueller@cpan.org
  • Mark Grimes mgrimes@cpan.org
  • Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
  • Gabor Szabo <gabor@szabgab.com>
  • Yanick Champoux <yanick@cpan.org>

this software is copyright (c) 2017, 2014, 2012 by The Padre development team as listed in Padre.pm..

and it's free software, bestie β€” you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. πŸ’œ


and that's the whole page, mwah πŸ’‹ β€” this lil doc came to you from perl v5.34.0, dated 2022-06-17, and it's the PPIx::...ariable(3pm) page. go rename something. stay hydrated. πŸ“πŸ§š

πŸ“¦ where this page comes from