PPIx::EditorTools::ReturnObject - Simple object to return values from PPIx::EditorTools |
PPIx::EditorTools::ReturnObject - Simple object to return values from PPIx::EditorTools
my $brace = PPIx::EditorTools::FindUnmatchedBrace->new->find( code => "package TestPackage;\nsub x { 1;\n" ); my $location = $brace->element->location; my $ppi = $brace->element->ppi;
Retuning a simple PPI::Element
from many of the PPIx::EditorTools
methods often results in the loss of the overall context for that element.
PPIx::EditorTools::ReturnObject
provides an object that can be passed
around which retains the overall context.
For example, in PPIx::EditorTools::FindUnmatchedBrace
if the unmatched
brace were returned by its PPI::Structure::Block
the containing
PPI::Document
is likely to go out of scope, thus the location
method no longer returns a valid location (rather it returns undef).
Using the ReturnObject
preserves the PPI::Document
and the containing
context.
new()
PPIx::EditorTools
. Accepts the following
named parameters:
PPI::Document
representing the (possibly modified) code.
PPI::Element
or a subclass thereof representing the interesting element.
PPI::Document
. May create the PPI::Document
from the $code string (lazily) if needed.
PPI::Document
via the serialize method (lazily) if needed.
PPIx::EditorTools
, the App::EditorTools manpage, Padre, and PPI.
PPIx::EditorTools::ReturnObject - Simple object to return values from PPIx::EditorTools |