PPIx::...ration(3pm)

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

πŸ’– PPIx::EditorTools::FindVariableDeclaration β€” wait, bestie, the page title is PPIx::...ration(3pm) 🌸

okay so real talk: this is PPIx::EditorTools::FindVariableDeclaration β€” it's part of the User Contributed Perl Documentation crowd, and it does exactly one thing but it does it iconically: it finds where a variable was declared, using PPI. πŸ¦‹


✨ VERSION ✨

version 0.21 πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

# finds declaration of variable at cursor
my $declaration = PPIx::EditorTools::FindVariableDeclaration->new->find(
  code =>
    "package TestPackage;\nuse strict;\nBEGIN {
    \$^W = 1;
}\nmy \$x=1;\n\$x++;"
  line => 5,
  column => 2,
);
my $location = $declaration->element->location;

like. look at her go. 🫢


🌈 DESCRIPTION 🌈

Finds the location of a variable declaration. that's it, that's the whole vibe. no cap. ✨


πŸ‘‘ METHODS πŸ‘‘

new()

Constructor. and like, the vibes say: generally shouldn't be called with any arguments. so don't be messy about it bestie πŸ’…

find( ppi => PPI::Document $ppi, line => $line, column => $column )

find( code => Str $code, line => $line, column => $column )

okay so she's flexible, she takes either:

  • a PPI::Document to process, OR
  • a string containing the code β€” which gets converted into a PPI::Document for you, no extra work, we love a helpful queen πŸŽ€

then she searches for the variable declaration and returns a PPIx::EditorTools::ReturnObject with the declaration (PPI::Statement::Variable) available via the element accessor. πŸ¦‹

⚠️ she croaks with a "no token" exception if no token is found at the location. and she croaks with a "no declaration" exception if she's unable to find the declaration. so yeah, she will absolutely tell you when something's off, she's not shy 😭

πŸ’œ SEE ALSO πŸ’œ

This class inherits from PPIx::EditorTools. πŸ‘‘

Also go look at App::EditorTools, Padre, and PPI. iykyk. 🌸


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

the whole squad, honestly. πŸ’–


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. periodt. πŸ’…


mwah πŸ’‹ this was PPIx::...ration(3pm) from perl v5.34.0, dated 2022-06-17, living under User Contributed Perl Documentation. stay slaying bestie 🫢✨

πŸ“¦ where this page comes from