From 33a1c432641f1d750d32f758486a25e8b1fd15e1 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Thu, 23 Apr 2009 12:58:04 +0200 Subject: [PATCH] Preliminar java extractor. --- NEWS | 14 ++++++++- lib/graphincludes/extractor/java.pm | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 lib/graphincludes/extractor/java.pm diff --git a/NEWS b/NEWS index d49dc65..e178dee 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,16 @@ -Version 0.13 - 2006-01-08 +Version 0.14 - unreleased + + End-user-visible changes + + * Added a preliminar java extractor. + + Bugs fixed: + + Changes for the plugin writer: + +================================================== + +Version 0.13 - 2006-02-08 End-user-visible changes diff --git a/lib/graphincludes/extractor/java.pm b/lib/graphincludes/extractor/java.pm new file mode 100644 index 0000000..9220002 --- /dev/null +++ b/lib/graphincludes/extractor/java.pm @@ -0,0 +1,60 @@ +# This file is part of the DEPS/graph-includes package +# +# (c) 2009 Yann Dirson +# Distributed under version 2 of the GNU GPL. + +package graphincludes::extractor::java; +use strict; +use warnings; + +use File::Spec::Functions qw(catfile); + +use base qw(graphincludes::extractor); + +use graphincludes::params; + +# This is only a preliminary extractor for java dependencies. +# Does not try to do anything with .class + +# sub get_default_sysincludes { +# # since this program does mess wih @INC, we must ask another perl +# # what it thinks @INC is +# open INC, 'perl -e \'print join "\n", @INC\' |'; +# my @incs; +# while () { +# chomp; +# push @incs, $_; +# } +# close INC; + +# return @incs; +# } + +sub pattern { '\.java$' } + +sub getdeps { + my $self = shift; + my ($graph) = @_; + + @ARGV = map {$_->{LABEL}} $graph->get_nodes(); + while (<>) { + my $dstfile; + if (m/^\s*import\s+(\S+);/) { + print STDERR "Found import: $_" if $graphincludes::params::debug; + my $import = $1; + $import =~ tr,.,/,; + $dstfile = $self->locatefile ($import . '.java', @graphincludes::params::inclpath); + + } else { + next; + } + + if (defined $dstfile) { + $graph->record_edge ($ARGV, $dstfile); + } else { + $self->record_missed_dep ($ARGV, catfile (split(/\./, $1)) . '.java'); + } + } +} + +1; -- 2.11.4.GIT