1Perl::Critic::Document(U3s)er Contributed Perl DocumentatPieornl::Critic::Document(3)
2
3
4

NAME

6       Perl::Critic::Document - Caching wrapper around a PPI::Document.
7

SYNOPSIS

9           use PPI::Document;
10           use Perl::Critic::Document;
11           my $doc = PPI::Document->new('Foo.pm');
12           $doc = Perl::Critic::Document->new($doc);
13           ## Then use the instance just like a PPI::Document
14

DESCRIPTION

16       Perl::Critic does a lot of iterations over the PPI document tree via
17       the "PPI::Document::find()" method.  To save some time, this class pre-
18       caches a lot of the common "find()" calls in a single traversal.  Then,
19       on subsequent requests we return the cached data.
20
21       This is implemented as a facade, where method calls are handed to the
22       stored "PPI::Document" instance.
23

CAVEATS

25       This facade does not implement the overloaded operators from
26       PPI::Document (that is, the "use overload ..."  work). Therefore, users
27       of this facade must not rely on that syntactic sugar.  So, for example,
28       instead of "my $source = "$doc";" you should write "my $source =
29       $doc-"content();>
30
31       Perhaps there is a CPAN module out there which implements a facade
32       better than we do here?
33

INTERFACE SUPPORT

35       This is considered to be a public class.  Any changes to its interface
36       will go through a deprecation cycle.
37

CONSTRUCTOR

39       "new($source_code)"
40           Create a new instance referencing a PPI::Document instance.  The
41           $source_code can be the name of a file, a reference to a scalar
42           containing actual source code, or a PPI::Document or
43           PPI::Document::File.
44

METHODS

46       "ppi_document()"
47           Accessor for the wrapped PPI::Document instance.  Note that
48           altering this instance in any way can cause unpredictable failures
49           in Perl::Critic's subsequent analysis because some caches may fall
50           out of date.
51
52       "find($wanted)"
53       "find_first($wanted)"
54       "find_any($wanted)"
55           If $wanted is a simple PPI class name, then the cache is employed.
56           Otherwise we forward the call to the corresponding method of the
57           "PPI::Document" instance.
58
59       "filename()"
60           Returns the filename for the source code if applicable
61           (PPI::Document::File) or "undef" otherwise (PPI::Document).
62
63       "isa( $classname )"
64           To be compatible with other modules that expect to get a
65           PPI::Document, the Perl::Critic::Document class masquerades as the
66           PPI::Document class.
67
68       "highest_explicit_perl_version()"
69           Returns a version object for the highest Perl version requirement
70           declared in the document via a "use" or "require" statement.
71           Returns nothing if there is no version statement.
72
73       "process_annotations()"
74           Causes this Document to scan itself and mark which lines & policies
75           are disabled by the "## no critic" annotations.
76
77       "line_is_disabled_for_policy($line, $policy_object)"
78           Returns true if the given $policy_object or $policy_name has been
79           disabled for at $line in this Document.  Otherwise, returns false.
80
81       "add_annotation( $annotation )"
82           Adds an $annotation object to this Document.
83
84       "annotations()"
85           Returns a list containing all the Perl::Critic::Annotation that
86           were found in this Document.
87
88       "add_suppressed_violation($violation)"
89           Informs this Document that a $violation was found but not reported
90           because it fell on a line that had been suppressed by a "## no
91           critic" annotation. Returns $self.
92
93       "suppressed_violations()"
94           Returns a list of references to all the Perl::Critic::Violations
95           that were found in this Document but were suppressed.
96

AUTHOR

98       Chris Dolan <cdolan@cpan.org>
99
101       Copyright (c) 2006-2009 Chris Dolan.
102
103       This program is free software; you can redistribute it and/or modify it
104       under the same terms as Perl itself.  The full text of this license can
105       be found in the LICENSE file included with this module.
106
107
108
109perl v5.10.1                      2010-11-12         Perl::Critic::Document(3)
Impressum