1
# -*- tab-width: 4 -*- ###############################################
3
# $Id: Java.pm,v 1.4 2001/11/14 15:27:36 mbox Exp $
5
# Enhances the support for the Java language over that provided by
8
# This program is free software; you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation; either version 2 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
package LXR::Lang::Java;
25
my $CVSID = '$Id: Java.pm,v 1.4 2001/11/14 15:27:36 mbox Exp $ ';
30
require LXR::Lang::Generic;
32
@LXR::Lang::Java::ISA = ('LXR::Lang::Generic');
34
# Only override the include handling. For java, this is really package
35
# handling, as there is no include mechanism, so deals with "package"
36
# and "import" keywords
39
my ($self, $frag, $dir) = @_;
40
# Deal with package declaration of the form
41
# "package java.lang.util"
42
$$frag =~ s#(package\s+)([\w.]+)#
44
($index->issymbol($2, $$self{'release'}) ?
45
join($2, @{$$self{'itag'}}) : $2)
47
# Deal with import declaration of the form
48
# "import java.awt.*" by providing link to the package
49
$$frag =~ s#(import\s+)([\w.]+)(\.\*)#
51
($index->issymbol($2, $$self{'release'}) ?
52
join($2, @{$$self{'itag'}}) : $2) .
55
# Deal with import declaration of the form
56
# "import java.awt.classname" by providing links to the
57
# package and the class
58
$$frag =~ s#(import\s+)([\w.]+)\.(\w+)(\W)#
60
($index->issymbol($2, $$self{'release'}) ?
61
join($2, @{$$self{'itag'}}) : $2) . "." .
62
($index->issymbol($3, $$self{'release'}) ?
63
join($3, @{$$self{'itag'}}) : $3) . $4#e;