Preliminar java extractor.
[deps.git] / lib / graphincludes / extractor / java.pm
blob9220002a2b7708a5f472280cd53e5f14d9d21d92
1 # This file is part of the DEPS/graph-includes package
3 # (c) 2009 Yann Dirson <ydirson@altern.org>
4 # Distributed under version 2 of the GNU GPL.
6 package graphincludes::extractor::java;
7 use strict;
8 use warnings;
10 use File::Spec::Functions qw(catfile);
12 use base qw(graphincludes::extractor);
14 use graphincludes::params;
16 # This is only a preliminary extractor for java dependencies.
17 # Does not try to do anything with .class
19 # sub get_default_sysincludes {
20 # # since this program does mess wih @INC, we must ask another perl
21 # # what it thinks @INC is
22 # open INC, 'perl -e \'print join "\n", @INC\' |';
23 # my @incs;
24 # while (<INC>) {
25 # chomp;
26 # push @incs, $_;
27 # }
28 # close INC;
30 # return @incs;
31 # }
33 sub pattern { '\.java$' }
35 sub getdeps {
36 my $self = shift;
37 my ($graph) = @_;
39 @ARGV = map {$_->{LABEL}} $graph->get_nodes();
40 while (<>) {
41 my $dstfile;
42 if (m/^\s*import\s+(\S+);/) {
43 print STDERR "Found import: $_" if $graphincludes::params::debug;
44 my $import = $1;
45 $import =~ tr,.,/,;
46 $dstfile = $self->locatefile ($import . '.java', @graphincludes::params::inclpath);
48 } else {
49 next;
52 if (defined $dstfile) {
53 $graph->record_edge ($ARGV, $dstfile);
54 } else {
55 $self->record_missed_dep ($ARGV, catfile (split(/\./, $1)) . '.java');