PPIx::EditorTools::ReturnObject3pm
Simple object to return values from ppix::editortools
Usage
my $brace = PPIx::EditorTools::FindUnmatchedBrace->new->find(code => "package TestPackage;\nsub x { 1;\n");my $location = $brace->element->location;my $ppi = $brace->element->ppi;
Version
version 0.21
Overview
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.
Methods
new()-
Constructor which should be used by
"PPIx::EditorTools". Accepts the following 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". May create the"PPI::Document"from the$codestring (lazily) if needed.
- code
-
Accessor to retrieve the string representation of the code. May be retrieved from the
"PPI::Document"via the serialize method (lazily) if needed.
Copyright and license
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.
Releases
8 releases since Debian 6.0 (Squeeze); the text changed 4 times.