PPIx::...nObject(3pm)

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

πŸ’– PPIx::EditorTools::ReturnObject πŸ’–

okay so bestie, this page lives in the User Contributed Perl Documentation corner of the manual-verse, and honestly? it's a tiny little diva of a module. her whole job is: carry stuff around so nothing gets lost. iconic behaviour, no notes. πŸ’…


✨ NAME ✨

PPIx::EditorTools::ReturnObject β€” a simple object that returns values from PPIx::EditorTools, and like... keeps them safe. πŸŽ€


🌸 VERSION 🌸

version 0.21


πŸ¦‹ SYNOPSIS πŸ¦‹

  my $brace = PPIx::EditorTools::FindUnmatchedBrace->new->find(
        code => "package TestPackage;\nsub x { 1;\n"
      );
  my $location = $brace->element->location;
  my $ppi      = $brace->element->ppi;

see how we're grabbing element, then location, then ppi off it? yeah. that's the whole vibe. it's giving ✨ context preservation ✨


πŸ’œ DESCRIPTION πŸ’œ

so here's the tea, bestie. when lots of the PPIx::EditorTools methods just hand you back a plain old PPI::Element, you lose the whole overall context for that element. tragic. genuinely tragic. 😭

PPIx::EditorTools::ReturnObject is the fix: it gives you an object you can pass around that retains the overall context. main character energy for a wrapper class, honestly.

for example β€” and this is the part you need to remember β€” in PPIx::EditorTools::FindUnmatchedBrace, if the unmatched brace got returned by its PPI::Structure::Block, the containing PPI::Document is likely to go out of scope, and then the location method stops returning a valid location. instead? it returns undef. yeah. πŸ’€

using the ReturnObject preserves the PPI::Document and the containing context. periodt. πŸ‘‘


πŸ’… METHODS πŸ’…

new()

the constructor, and it's meant to be used by PPIx::EditorTools. it accepts these named parameters:

  • ppi β€” a PPI::Document representing the (possibly modified) code. 🫢
  • code β€” a string representing the (possibly modified) code. ✨
  • element β€” a PPI::Element or a subclass thereof representing the interesting element. πŸ‘€

ppi

accessor to retrieve the PPI::Document. it may create the PPI::Document from the $code string (lazily) if needed. so chill. so lazy. we respect it. 😌


code

accessor to retrieve the string representation of the code. it may be retrieved from the PPI::Document via the serialize method (lazily) if needed. same energy. same slay. 🌈


🌟 SEE ALSO 🌟

PPIx::EditorTools, App::EditorTools, Padre, and PPI. the whole friend group fr fr. πŸ«‚


πŸ‘‘ AUTHORS πŸ‘‘

  • 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>

look at this lineup. absolute legends, every single one. πŸŽ€


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

this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

bestie the license is literally "same as Perl 5 itself" β€” go forth, remix, redistribute, it's free. πŸ¦‹

and that's the whole page!! this was perl v5.34.0, dated 2022-06-17, delivered to you from the PPIx::...nObject(3pm) manual page (the title got a lil truncated in the header, she's shy). anyway mwah, go preserve some context, love u πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from