1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
package PlSense::ModuleBuilder::PPIBuilder::IncludeStmt;
use strict;
use warnings;
use Class::Std;
use Module::Pluggable instantiate => 'new', search_path => 'PlSense::Plugin::IncludeStmt';
use PlSense::Logger;
use PlSense::Util;
{
my %plugins_of :ATTR();
sub BUILD {
my ($class, $ident, $arg_ref) = @_;
$plugins_of{$ident} = [];
}
sub START {
my ($class, $ident, $arg_ref) = @_;
my @plugins = $class->plugins();
PLUGIN:
foreach my $p ( @plugins ) { push @{$plugins_of{$ident}}, $p; }
}
sub build {
my ($self, $mdl, $stmt) = @_;
my $mdlnm = $stmt->module or return;
PLUGIN:
foreach my $p ( @{$plugins_of{ident $self}} ) {
$p->include_statement($mdl, $mdlnm, $stmt);
}
if ( $stmt->pragma ) { return; }
if ( $mdl->exist_usingmdl($mdlnm) ) { return; }
my $incmdl = mdlkeeper->get_module($mdlnm);
if ( ! $incmdl ) {
logger->warn("Not found module : $mdlnm");
return;
}
my $filepath = $incmdl->get_filepath;
if ( ! $filepath || ! -f $filepath ) {
logger->warn("Not exist module : $mdlnm");
mdlkeeper->remove_module($incmdl->get_name, $filepath, $incmdl->get_projectnm);
return;
}
logger->debug("Found using module of [".$mdl->get_name."] : ".$incmdl->get_name);
$mdl->push_usingmdl($incmdl);
return;
}
}
1;
__END__
|