NAME
App::perlimports::Document - Make implicit imports explicit
VERSION
version 0.000059
MOTIVATION
This module is to be used internally by perlimports. It shouldn't be relied upon by anything else.
inspector_for( $module_name )
Returns an App::perlimports::ExporterInspector object for the given module.
linter_success
Returns true if document was linted without errors, otherwise false.
tidied_document
Returns a serialized PPI document with (hopefully) tidy import statements.
ATTRIBUTES
- constants
-
Hashref catalog of detected constants in the document. So the line:
use constant FIRST_IDX => 0;results in a corresponding entry in the constants hashref:
FIRST_IDX => { name => 'FIRST_IDX', # (plain string) token => 'FIRST_IDX', # (PPI::Token::Word usually) definition => [ PPI::Token.. ], end => { line => 9, column => 32 }, },The
endis the (line, character) position of the last character of the constant import statement. This might be useful since the constant is only defined (at compile time!) after this statement. (Note: locations can become stale!)The
namefield is useful when the constant was defined using atypical syntax (no fat arrow), since the token doesn't stringify the same:use constant 'FIRST_IDX', 0; # token eq "'FIRST_IDX'", # (PPI::Token::Quote::Single) # name eq 'FIRST_IDX', # same as $token->string - includes
-
An arrayref of PPI::Statement::Include statements found in the document, excluding pragmas, ignored modules, and 'use VERSION' statements.
- found_imports
-
A hashref catalog of symbols imported from each package by a use statement, e.g.
{ Carp => ['croak', ..], ... }In lint mode, this attribute is never altered.
In edit mode, when tidied_document is called, with each include that gets processed, this list gets updated to what we think it should be. We do this so that we can keep track of what previous modules are really importing, to avoid duplicate imports (same symbol name from different packages).
AUTHOR
Olaf Alders <olaf@wundercounter.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020 by Olaf Alders.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.