From 7de8ac0a90ab87565c4a0bd8d8e4070f4967cdbe Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Sun, 13 Jul 2008 18:13:55 +0000 Subject: [PATCH] make script more robust: classes w/o a constructor arg we're looking for, anonymous classes, better regex for restricting to java files git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@676389 13f79535-47bb-0310-9956-ffa450edef68 --- src/dev-tools/stub-analysis-factory-maker.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dev-tools/stub-analysis-factory-maker.pl b/src/dev-tools/stub-analysis-factory-maker.pl index 114d8f611b2..99eb3d38846 100755 --- a/src/dev-tools/stub-analysis-factory-maker.pl +++ b/src/dev-tools/stub-analysis-factory-maker.pl @@ -46,7 +46,10 @@ use File::Find; my %classes = (); while () { chomp; - $classes{$_} = 1; + # skip anonymous classes + if (!/\$/) { + $classes{$_} = 1; + } } find({wanted => \&wanted, @@ -58,7 +61,7 @@ sub wanted { my $file = $File::Find::name; - return unless $file =~ m{/([^/]*)\.java}; + return unless $file =~ m{/([^/]*)\.java$}; my $class = $1; open(my $f, "<", $file) or die "can't open $file: $!"; @@ -81,6 +84,8 @@ sub wanted { # only looking for certain classes return unless $classes{$fullname}; + print STDERR "$file\n"; + my @imports = $data =~ m/import\s+.*;/g; if ($data =~ m{public \s+ ((?:\w+\s+)*) $class \s*\(\s* ([^\)]*) \) }sx) { @@ -100,6 +105,9 @@ sub wanted { ($k, $v) } split /\s*,\s*/, $argline; + # wacky, doesn't use Reader or TokenStream ... skip (maybe a Sink?) + return unless defined $mainArgType; + my $type = ("Reader" eq $mainArgType) ? "Tokenizer" : "TokenFilter"; my $facClass = "${class}Factory"; @@ -119,8 +127,8 @@ sub wanted { } if (1 < @orderedArgs) { # we need to init something, stub it out - print $o " public abstract void init(SolrConfig solrConfig, Map args) {\n"; - print $o " super.init(solrConfig, args);\n"; + print $o " public abstract void init(Map args) {\n"; + print $o " super.init(args);\n"; print $o " // ABSTRACT BECAUSE IT'S A STUB .. FILL IT IN\n"; print $o " }\n"; }