New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle module runtime #14

Merged
merged 2 commits into from Jan 30, 2016
Jump to file or symbol
Failed to load files and symbols.
+5,167 −2,698
Diff settings

Always

Just for now

Next

Detect uses of Module::Runtime

finds require_module, use_module and use_package_optimistically
  • Loading branch information...
brummett committed Jan 22, 2016
commit 83cb8db237f0c401ffa7ed5619993052af88766d
Copy path View file
15 grammar
@@ -45,6 +45,21 @@ token_no: /\bno\s/ no_stuff /[;}]/
no_stuff: (base | version | module)
#----------------------------------------------------------------
# Functions provided by Module::Runtime
#----------------------------------------------------------------
module_runtime_require_module: ( 'Module::Runtime::require_module(' | /\brequire_module\(/ ) <perl_quotelike> ')'
{ $return = $item[2][2] }
module_runtime_use_module: ( 'Module::Runtime::use_module(' | /\buse_module\(/ ) <perl_quotelike> (',' | ')' )
{ $return = $item[2][2] }
module_runtime_use_package_optimistically: ( 'Module::Runtime::use_package_optimistically(' | /\buse_package_optimistically\(/ ) <perl_quotelike> (',' | ')' )
{ return $item[2][2] }
token_module_runtime: module_runtime_require_module | module_runtime_use_module | module_runtime_use_package_optimistically
#-----------------------------------------------------------------
# General Rules
#-----------------------------------------------------------------
Copy path View file
@@ -194,7 +194,16 @@ sub extract_use {
# parse it! (using different entry point to save some more
# time)
my $type;
if ($statement=~/\buse/) {
if ($statement=~m/require_module|use_module|use_package_optimistically/) {
$statement=~s/^(.*?)\b(\S+(?:require_module|use_module|use_package_optimistically)\([^)]*\))/$2/;
next if $1 && $1 =~ /->\s*$/;
eval {
my $parser=Module::ExtractUse::Grammar->new();
$result=$parser->token_module_runtime($statement);
};
$type = $statement =~ m/require/ ? 'require' : 'use';
}
elsif ($statement=~/\buse/) {
$statement=~s/^(.*?)use\b/use/;
next if $1 && $1 =~ /->\s*$/;
eval {
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.