1PPIx::EditorTools::IntrUosdeurceCToenmtPprPoiIrbxau:rt:yeEVddairPtieoarrblTloeDo(ol3cs)u:m:eInnttartoidounceTemporaryVariable(3)
2
3
4

NAME

6       PPIx::EditorTools::IntroduceTemporaryVariable - Introduces a temporary
7       variable using PPI
8

VERSION

10       version 0.21
11

SYNOPSIS

13           my $munged = PPIx::EditorTools::IntroduceTemporaryVariable->new->introduce(
14               code           => "use strict; BEGIN {
15               $^W = 1;
16       }\n\tmy $x = ( 1 + 10 / 12 ) * 2;\n\tmy $y = ( 3 + 10 / 12 ) * 2;\n",
17               start_location => [ 2, 19 ],
18               end_location   => [ 2, 25 ],
19               varname        => '$foo',
20           );
21           my $modified_code_as_string = $munged->code;
22           my $location_of_new_var_declaration = $munged->element->location;
23

DESCRIPTION

25       Given a region of code within a statement, replaces all occurrences of
26       that code with a temporary variable. Declares and initializes the
27       temporary variable right above the statement that included the selected
28       expression.
29

METHODS

31       new()
32           Constructor. Generally shouldn't be called with any arguments.
33
34       find( ppi => PPI::Document, start_location => Int, end_location => Int,
35       varname => Str )
36       find( code => Str, start_location => Int, end_location => Int, varname
37       => Str )
38           Accepts either a "PPI::Document" to process or a string containing
39           the code (which will be converted into a "PPI::Document") to
40           process.
41
42           Given the region of code specified by start_location and
43           end_location, replaces that code with a temporary variable with the
44           name given in varname (defaults to "tmp"). Declares and initializes
45           the temporary variable right above the statement that included the
46           selected expression.
47
48           Returns a "PPIx::EditorTools::ReturnObject" with the modified code
49           as a string available via the "code" accessor (or as a
50           "PPI::Document" via the "ppi" accessor), and the "PPI::Token" where
51           the new variable is declared available via the "element" accessor.
52
53           Croaks with a "no token" exception if no token is found at the
54           location.  Croaks with a "no statement" exception if unable to find
55           the statement.
56

SEE ALSO

58       This class inherits from "PPIx::EditorTools".  Also see
59       App::EditorTools, Padre, and PPI.
60

AUTHORS

62       ·   Steffen Mueller "smueller@cpan.org"
63
64       ·   Mark Grimes "mgrimes@cpan.org"
65
66       ·   Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
67
68       ·   Gabor Szabo  <gabor@szabgab.com>
69
70       ·   Yanick Champoux <yanick@cpan.org>
71
73       This software is copyright (c) 2017, 2014, 2012 by The Padre
74       development team as listed in Padre.pm..
75
76       This is free software; you can redistribute it and/or modify it under
77       the same terms as the Perl 5 programming language system itself.
78
79
80
81perl v5.30.1                  PPIx2:0:2E0d-i0t1o-r3T0ools::IntroduceTemporaryVariable(3)
Impressum