1PPIx::EditorTools::RetuUrsneOrbjCeocntt(r3i)buted Perl DPoPcIuxm:e:nEtdaittioornTools::ReturnObject(3)
2
3
4

NAME

6       PPIx::EditorTools::ReturnObject - Simple object to return values from
7       PPIx::EditorTools
8

SYNOPSIS

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

DESCRIPTION

17       Retuning a simple "PPI::Element" from many of the "PPIx::EditorTools"
18       methods often results in the loss of the overall context for that
19       element.  "PPIx::EditorTools::ReturnObject" provides an object that can
20       be passed around which retains the overall context.
21
22       For example, in "PPIx::EditorTools::FindUnmatchedBrace" if the
23       unmatched brace were returned by its "PPI::Structure::Block" the
24       containing "PPI::Document" is likely to go out of scope, thus the
25       "location" method no longer returns a valid location (rather it returns
26       undef).  Using the "ReturnObject" preserves the "PPI::Document" and the
27       containing context.
28

METHODS

30       new()
31           Constructor which should be used by "PPIx::EditorTools". Accepts
32           the following named parameters:
33
34           ppi A "PPI::Document" representing the (possibly modified) code.
35
36           code
37               A string representing the (possibly modified) code.
38
39           element
40               A "PPI::Element" or a subclass thereof representing the
41               interesting element.
42
43       ppi Accessor to retrieve the "PPI::Document". May create the
44           "PPI::Document" from the $code string (lazily) if needed.
45
46       code
47           Accessor to retrieve the string representation of the code. May be
48           retrieved from the "PPI::Document" via the serialize method
49           (lazily) if needed.
50

SEE ALSO

52       "PPIx::EditorTools", App::EditorTools, Padre, and PPI.
53

AUTHOR

55       Mark Grimes "mgrimes@cpan.org"
56
58       Copyright 2008-2009 The Padre development team as listed in Padre.pm.
59
60       This program is free software; you can redistribute it and/or modify it
61       under the same terms as Perl 5 itself.
62
63
64
65perl v5.12.0                      2009-09-19PPIx::EditorTools::ReturnObject(3)
Impressum