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

NAME

6       Perl::Critic::Document - Caching wrapper around 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 PPI::Docu‐
26       ment (that is, the "use overload ..." work). Therefore, users of this
27       facade must not rely on that syntactic sugar.  So, for example, instead
28       of "my $source = "$doc";" you should write "my $source = $doc-"con‐
29       tent();>
30
31       Perhaps there is a CPAN module out there which implements a facade bet‐
32       ter than we do here?
33

METHODS

35       $pkg->new($doc)
36           Create a new instance referencing a PPI::Document instance.
37
38       $self->find($wanted)
39       $self->find_first($wanted)
40       $self->find_any($wanted)
41           If $wanted is a simple PPI class name, then the cache is employed.
42           Otherwise we forward the call to the corresponding method of the
43           "PPI::Document" instance.
44
45       $self->filename()
46           Returns the filename for the source code if applicable (PPI::Docu‐
47           ment::File) or "undef" otherwise (PPI::Document).
48
49       $self->isa( $classname )
50           To be compatible with other modules that expect to get a PPI::Docu‐
51           ment, the Perl::Critic::Document class masquerades as the PPI::Doc‐
52           ument class.
53

AUTHOR

55       Chris Dolan <cdolan@cpan.org>
56
58       Copyright (c) 2006 Chris Dolan.  All rights reserved.
59
60       This program is free software; you can redistribute it and/or modify it
61       under the same terms as Perl itself.  The full text of this license can
62       be found in the LICENSE file included with this module.
63
64
65
66perl v5.8.8                       2007-03-20         Perl::Critic::Document(3)
Impressum