Thanks for the reply.
If it turns out to be as useful as I'm hoping it will be, then I'll probably
need to repeat it.
I'm not much of a set/awk/perl kind of person, but I can c++/java/sql fairly
well (but not great by anymeans..)
Hmm..that's too bad.
For typical "reasonable" java code awk may well give you your best bang for
the buck.
This is a gawk script.
/\<public\>.*\<class\>/ {
print;
}
/protected[^=]*\(|private[^=]*\(|public[^=]*\(/ {
print;
}
That will take a file and:
a) print any line with that has the word 'public' followed by 'class' in it.
b) print any line that has protected/private/public followed by a '(' but
without an intervening '=';
The first line should give you your class declaration. There are certainly
lines of legal java that this will match that are not class declarations.
The second should give at least the first part of the method names. Same
caveat as above. It should cleverly NOT show lines such as:
public Object o = new Object();
You will have issues with inner classes, or if you break your lines up away
from typical Java. It also doesn't find "package scoped" methods (i.e. those
without public/protected/private).
perl/awk/sed's regular expressions can be very powerful, but are not to be
left unattended. There's a great saying: "You have a problem that you think
regular expressions can solve. Now you have two problems." Java syntax can
not be easily represented by a regular expression, but they can fake it for
common, albeit limited, cases.
That may be enough to get you started. You may as well be able to do the
same thing use regexes or whatever with Java/C++/whatever. But, that would
be my first cut at it, depending on the goals. But, IMHO, 6 lines of awk is
pretty powerful.
Regards,
Will Hartung
(
[email protected])