1Perl::Critic::Utils::PPUIs(e3r)Contributed Perl DocumentPaetrilo:n:Critic::Utils::PPI(3)
2
3
4

NAME

6       Perl::Critic::Utils::PPI - Utility functions for dealing with PPI
7       objects.
8

DESCRIPTION

10       Provides classification of PPI::Elements.
11

INTERFACE SUPPORT

13       This is considered to be a public module.  Any changes to its interface
14       will go through a deprecation cycle.
15

IMPORTABLE SUBS

17       "is_ppi_expression_or_generic_statement( $element )"
18           Answers whether the parameter is an expression or an
19           undifferentiated statement.  I.e. the parameter either is a
20           PPI::Statement::Expression or the class of the parameter is
21           PPI::Statement and not one of its subclasses other than
22           "Expression".
23
24       "is_ppi_generic_statement( $element )"
25           Answers whether the parameter is an undifferentiated statement,
26           i.e.  the parameter is a PPI::Statement but not one of its
27           subclasses.
28
29       "is_ppi_statement_subclass( $element )"
30           Answers whether the parameter is a specialized statement, i.e. the
31           parameter is a PPI::Statement but the class of the parameter is not
32           PPI::Statement.
33
34       "is_ppi_simple_statement( $element )"
35           Answers whether the parameter represents a simple statement, i.e.
36           whether the parameter is a PPI::Statement, PPI::Statement::Break,
37           PPI::Statement::Include, PPI::Statement::Null,
38           PPI::Statement::Package, or PPI::Statement::Variable.
39
40       "is_ppi_constant_element( $element )"
41           Answers whether the parameter represents a constant value, i.e.
42           whether the parameter is a PPI::Token::Number,
43           PPI::Token::Quote::Literal, PPI::Token::Quote::Single, or
44           PPI::Token::QuoteLike::Words, or is a PPI::Token::Quote::Double or
45           PPI::Token::Quote::Interpolate which does not in fact contain any
46           interpolated variables.
47
48           This subroutine does not interpret any form of here document as a
49           constant value, and may not until PPI::Token::HereDoc acquires the
50           relevant portions of the PPI::Token::Quote interface.
51
52           This subroutine also does not interpret entities created by the
53           Readonly module or the constant pragma as constants, because the
54           infrastructure to detect these appears not to be present, and the
55           author of this subroutine (not Mr. Shank or Mr. Thalhammer) lacks
56           the knowledge/expertise/gumption to put it in place.
57
58       "is_subroutine_declaration( $element )"
59           Is the parameter a subroutine declaration, named or not?
60
61       "is_in_subroutine( $element )"
62           Is the parameter a subroutine or inside one?
63
64       "get_constant_name_element_from_declaring_statement($statement)"
65           Given a PPI::Statement, if the statement is a "use constant" or
66           Readonly declaration statement, return the name of the thing being
67           defined.
68
69           Given
70
71               use constant 1.16 FOO => 'bar';
72
73           this will return "FOO".  Similarly, given
74
75               Readonly::Hash my %FOO => ( bar => 'baz' );
76
77           this will return "%FOO".
78
79           Caveat: in the case where multiple constants are declared using the
80           same "use constant" statement (e.g. "use constant { FOO => 1, BAR
81           => 2 };", this subroutine will return the declaring
82           PPI::Structure::Constructor. In the case of "use constant 1.16 {
83           FOO => 1, BAR => 2 };" it may return a PPI::Structure::Block
84           instead of a PPI::Structure::Constructor, due to a parse error in
85           PPI.
86
87       "get_next_element_in_same_simple_statement( $element )"
88           Given a "PPI::Element|PPI::Element", this subroutine returns the
89           next element in the same simple statement as defined by
90           is_ppi_simple_statement(). If no next element can be found, this
91           subroutine simply returns.
92
93           If the $element is undefined or unblessed, we simply return.
94
95           If the $element satisfies "is_ppi_simple_statement()", we return,
96           unless it has a parent which is a PPI::Structure::List.
97
98           If the $element is the last significant element in its PPI::Node,
99           we replace it with its parent and iterate again.
100
101           Otherwise, we return "$element->snext_sibling()".
102
103       "get_previous_module_used_on_same_line( $element )"
104           Given a PPI::Element, returns the PPI::Element representing the
105           name of the module included by the previous "use" or "require" on
106           the same line as the $element. If none is found, simply returns.
107
108           For example, with the line
109
110               use version; our $VERSION = ...;
111
112           given the PPI::Token::Symbol instance for $VERSION, this will
113           return "version".
114
115           If the given element is in a "use" or <require>, the return is from
116           the previous "use" or "require" on the line, if any.
117

AUTHOR

119       Elliot Shank <perl@galumph.com>
120
122       Copyright (c) 2007-2009 Elliot Shank.  All rights reserved.
123
124       This program is free software; you can redistribute it and/or modify it
125       under the same terms as Perl itself.  The full text of this license can
126       be found in the LICENSE file included with this module.
127
128
129
130perl v5.12.1                      2010-09-08       Perl::Critic::Utils::PPI(3)
Impressum