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           This subroutine is deprecated. You should use
66           "get_constant_name_elements_from_declaring_statement()" in
67           PPIx::Utilities::Statement instead.
68
69           Given a PPI::Statement, if the statement is a "use constant" or
70           Readonly declaration statement, return the name of the thing being
71           defined.
72
73           Given
74
75               use constant 1.16 FOO => 'bar';
76
77           this will return "FOO".  Similarly, given
78
79               Readonly::Hash my %FOO => ( bar => 'baz' );
80
81           this will return "%FOO".
82
83           Caveat: in the case where multiple constants are declared using the
84           same "use constant" statement (e.g. "use constant { FOO => 1, BAR
85           => 2 };", this subroutine will return the declaring
86           PPI::Structure::Constructor. In the case of "use constant 1.16 {
87           FOO => 1, BAR => 2 };" it may return a PPI::Structure::Block
88           instead of a PPI::Structure::Constructor, due to a parse error in
89           PPI.
90
91       "get_next_element_in_same_simple_statement( $element )"
92           Given a PPI::Element, this subroutine returns the next element in
93           the same simple statement as defined by is_ppi_simple_statement().
94           If no next element can be found, this subroutine simply returns.
95
96           If the $element is undefined or unblessed, we simply return.
97
98           If the $element satisfies "is_ppi_simple_statement()", we return,
99           unless it has a parent which is a PPI::Structure::List.
100
101           If the $element is the last significant element in its PPI::Node,
102           we replace it with its parent and iterate again.
103
104           Otherwise, we return "$element->snext_sibling()".
105
106       "get_previous_module_used_on_same_line( $element )"
107           Given a PPI::Element, returns the PPI::Element representing the
108           name of the module included by the previous "use" or "require" on
109           the same line as the $element. If none is found, simply returns.
110
111           For example, with the line
112
113               use version; our $VERSION = ...;
114
115           given the PPI::Token::Symbol instance for $VERSION, this will
116           return "version".
117
118           If the given element is in a "use" or <require>, the return is from
119           the previous "use" or "require" on the line, if any.
120

AUTHOR

122       Elliot Shank <perl@galumph.com>
123
125       Copyright (c) 2007-2011 Elliot Shank.
126
127       This program is free software; you can redistribute it and/or modify it
128       under the same terms as Perl itself.  The full text of this license can
129       be found in the LICENSE file included with this module.
130
131
132
133perl v5.30.0                      2019-07-26       Perl::Critic::Utils::PPI(3)
Impressum