Perl::Critic::Document - Caching wrapper around a PPI::Document.
use PPI::Document;
use Perl::Critic::Document;
my $doc = PPI::Document->new('Foo.pm');
$doc = Perl::Critic::Document->new($doc);
## Then use the instance just like a PPI::Document
Perl::Critic does a lot of iterations over the PPI document tree via
the PPI::Document::find() method. To save some time, this class
pre-caches a lot of the common find() calls in a single traversal.
Then, on subsequent requests we return the cached data.
This is implemented as a facade, where method calls are handed to the
stored PPI::Document instance.
This facade does not implement the overloaded operators from
PPI::Document (that is, the use overload ... work). Therefore,
users of this facade must not rely on that syntactic sugar. So, for
example, instead of my $source = "$doc"; you should write my
$source = $doc-content();>
Perhaps there is a CPAN module out there which implements a facade better than we do here?
new($doc)
new($doc)
ppi_document()
find($wanted)
find_first($wanted)
find_any($wanted)
$wanted is a simple PPI class name, then the cache is employed.
Otherwise we forward the call to the corresponding method of the
PPI::Document instance.
filename()
undef otherwise (PPI::Document).
isa( $classname )
highest_explicit_perl_version()
use or require statement. Returns nothing if
there is no version statement.
Chris Dolan <cdolan@cpan.org>
Copyright (c) 2006-2008 Chris Dolan. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.