1 ##############################################################################
2 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/lib/Perl/Critic/Utils/PPI.pm $
3 # $Date: 2008-07-03 10:19:10 -0500 (Thu, 03 Jul 2008) $
6 ##############################################################################
8 package Perl::Critic::Utils::PPI;
16 our $VERSION = '1.088';
18 #-----------------------------------------------------------------------------
21 is_ppi_expression_or_generic_statement
22 is_ppi_generic_statement
23 is_ppi_statement_subclass
30 #-----------------------------------------------------------------------------
32 sub is_ppi_expression_or_generic_statement {
35 my $element_class = ref $element;
37 return 0 if not $element_class;
38 return 0 if not $element->isa('PPI::Statement');
40 return 1 if $element->isa('PPI::Statement::Expression');
42 return $element_class eq 'PPI::Statement';
45 #-----------------------------------------------------------------------------
47 sub is_ppi_generic_statement {
50 my $element_class = ref $element;
52 return 0 if not $element_class;
53 return 0 if not $element->isa('PPI::Statement');
55 return $element_class eq 'PPI::Statement';
58 #-----------------------------------------------------------------------------
60 sub is_ppi_statement_subclass {
63 my $element_class = ref $element;
65 return 0 if not $element_class;
66 return 0 if not $element->isa('PPI::Statement');
68 return $element_class ne 'PPI::Statement';
75 #-----------------------------------------------------------------------------
83 Perl::Critic::Utils::PPI - Utility functions for dealing with PPI objects.
88 Provides classification of L<PPI::Elements>.
91 =head1 IMPORTABLE SUBS
95 =item C<is_ppi_expression_or_generic_statement( $element )>
97 Answers whether the parameter is an expression or an undifferentiated
98 statement. I.e. the parameter either is a
99 L<PPI::Statement::Expression> or the class of the parameter is
100 L<PPI::Statement> and not one of its subclasses other than
104 =item C<is_ppi_generic_statement( $element )>
106 Answers whether the parameter is an undifferentiated statement, i.e.
107 the parameter is a L<PPI::Statement> but not one of its subclasses.
110 =item C<is_ppi_statement_subclass( $element )>
112 Answers whether the parameter is a specialized statement, i.e. the
113 parameter is a L<PPI::Statement> but the class of the parameter is not
122 Elliot Shank <perl@galumph.com>
126 Copyright (c) 2007-2008 Elliot Shank. All rights reserved.
128 This program is free software; you can redistribute it and/or modify
129 it under the same terms as Perl itself. The full text of this license
130 can be found in the LICENSE file included with this module.
136 # cperl-indent-level: 4
138 # indent-tabs-mode: nil
139 # c-indentation-style: bsd
141 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :