 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
TimOnGoogle Guest
|
Posted: Tue Aug 30, 2005 12:05 am Post subject: Need tool that finds all types of a certain scope... |
|
|
For example, a tool where I can say "Show me all public statics" or
"show me all private methods returning voids" etc.
Eclipse doesn't seem to have a complete set of searches for that kind
of thing, so I'm looking elsewhere.
Any ideas?
- Tim
|
|
| Back to top |
|
 |
Roedy Green Guest
|
Posted: Tue Aug 30, 2005 9:24 am Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
On 29 Aug 2005 17:05:35 -0700, "TimOnGoogle" <fromGoogle (AT) apeshit (DOT) com>
wrote or quoted :
| Quote: | Eclipse doesn't seem to have a complete set of searches for that kind
of thing, so I'm looking elsewhere.
|
Check out Java Guru by kinabaloo software.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
|
|
| Back to top |
|
 |
TimOnGoogle Guest
|
Posted: Tue Aug 30, 2005 6:56 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
Thanks, Roedy, but that doesn't do it. It shows ONLY methods (not all
class members), is based on Javadocs (apparently), and, in any case,
only allows you to see the public and protected interface elements.
Did you know that?
- Tim
|
|
| Back to top |
|
 |
iamfractal@hotmail.com Guest
|
Posted: Wed Aug 31, 2005 10:29 am Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
TimOnGoogle skrev:
| Quote: | For example, a tool where I can say "Show me all public statics" or
"show me all private methods returning voids" etc.
Eclipse doesn't seem to have a complete set of searches for that kind
of thing, so I'm looking elsewhere.
Any ideas?
- Tim
|
I just saw it in passing, I've not tried it myself, and it probably
doesn't show all you want, but:
http://jrefactory.sourceforge.net/csmetrics.html
..ed
--
www.EdmundKirwan.com - Home of The Fractal Class Composition.
|
|
| Back to top |
|
 |
Larry Barowski Guest
|
Posted: Wed Aug 31, 2005 1:26 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
"TimOnGoogle" <fromGoogle (AT) apeshit (DOT) com> wrote
| Quote: | For example, a tool where I can say "Show me all public statics" or
"show me all private methods returning voids" etc.
Eclipse doesn't seem to have a complete set of searches for that kind
of thing, so I'm looking elsewhere.
|
What exactly do you have in mind? I can easily add something
like this to jGRASP (easily as in "tomorrow"), since we already
have class file scanning code that is used for UML generation,
dependency analysis, etc. It would be class-file based (as opposed
to source-code based) though, so it would not be able to find
source line numbers for field definitions.
|
|
| Back to top |
|
 |
TimOnGoogle Guest
|
Posted: Wed Aug 31, 2005 8:41 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
Well, basically, I'm modifying code with lots of references within
classes to other classes' non-method members (usually static). Very
bad design, I think.
So I want to compile a list (among the hundreds of classes in this
project) of all non-private non-method members, or, even better, of all
references from outside all classes (not any one class, but ALL
classes) to all of their non-method members. This way, I can start to
remove all of these random references to public static, class static,
and package static members.
Can jGRASP do that kind of thing?
- Tim
|
|
| Back to top |
|
 |
Hemal Pandya Guest
|
Posted: Thu Sep 01, 2005 2:59 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
TimOnGoogle wrote:
| Quote: | Well, basically, I'm modifying code with lots of references within
classes to other classes' non-method members (usually static). Very
bad design, I think.
So I want to compile a list (among the hundreds of classes in this
project) of all non-private non-method members, or, even better, of all
references from outside all classes (not any one class, but ALL
classes) to all of their non-method members. This way, I can start to
remove all of these random references to public static, class static,
and package static members.
Can jGRASP do that kind of thing?
- Tim
|
Not to say jGRASP will not be a more sophisticated solution, but you
might be able to meet your short-term needs with:
- etags
- javadoc, usuing a custom DocLet
|
|
| Back to top |
|
 |
Larry Barowski Guest
|
Posted: Thu Sep 01, 2005 3:42 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
"TimOnGoogle" <fromGoogle (AT) apeshit (DOT) com> wrote
| Quote: | Well, basically, I'm modifying code with lots of references within
classes to other classes' non-method members (usually static). Very
bad design, I think.
So I want to compile a list (among the hundreds of classes in this
project) of all non-private non-method members, or, even better, of all
references from outside all classes (not any one class, but ALL
classes) to all of their non-method members. This way, I can start to
remove all of these random references to public static, class static,
and package static members.
Can jGRASP do that kind of thing?
|
As of now, no. It will show all references between any pair
of classes, and let you jump to each of the uses and method
definitions. You can also search multiple files using a "grep"
or "awk" regular expression, and click on each result to jump
to the location. So you could probably find most public static
non-final (I assume public static final refs are OK) fields by
searching for the Perl regular expression:
publics+statics+[a-zA-Z0-9_.]+s+[a-zA-Z0-9_]+s*;
Doing that just now on the jGRASP sources turned up eight
static fields that shouldn't be public. Once you find these
you can make each one private and recompile the project to
find the uses that are now broken.
A class member search could be quite a useful feature though,
and I can add it in the next few days. I'm thinking of a text
search string with wildcards, and "or" and "not" operators
allowed for modifiers. So in your case, you could search on:
^private * or if only showing external uses, just: * since
there can't be any private external uses. Or to ignore
constants, maybe: static ^final * and ^static * .
In your case you probably don't care about references to
public fields from outer to inner class and vice-versa, so there
needs to be a way to filter those out. Let's say there will be
checkboxes for
Show Method Definitions
Show Internal Uses
Show Inner/Outer Uses
Show External Uses
The results would be something like
SomeClass.someField
External Uses:
C:some_directorySomeOtherClass.java:16
C:some_directoryYetAnotherClass.java:124
and you could click on each path/line to jump to it.
Send me an email and I'll let you know where to pick up an
alpha version when I add this feature.
|
|
| Back to top |
|
 |
TimOnGoogle Guest
|
Posted: Thu Sep 01, 2005 7:22 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
Hemal...
Hmm... well, I don't use Emacs, so I looked at ctags, but am not sure
how I can get vi/vim to display all tags that contain a certain java
scope... don't think it's smart enough to do that.
However, writing my own Doclet might be a good way of doing it. I'll
look into it -- thanks!
- Tim
|
|
| Back to top |
|
 |
Hemal Pandya Guest
|
Posted: Fri Sep 02, 2005 5:09 am Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
| Quote: | Hemal...
Hmm... well, I don't use Emacs, so I looked at ctags, but am not sure
how I can get vi/vim to display all tags that contain a certain java
scope... don't think it's smart enough to do that.
However, writing my own Doclet might be a good way of doing it. I'll
look into it -- thanks!
|
The idea I had was to just delete unwanted lines from the TAGS files
(first delete all lines with '(' to delete methods, then delete lines
not containing 'public').
But Doclet does sound like a better way to do it. Will you (can you,
legal issues?) post the code here? Extending that into a api-grep kind
of functionality
sounds like a good idea.
|
|
| Back to top |
|
 |
Oliver Wong Guest
|
Posted: Fri Sep 02, 2005 5:16 pm Post subject: Re: Need tool that finds all types of a certain scope... |
|
|
"TimOnGoogle" <fromGoogle (AT) apeshit (DOT) com> wrote
| Quote: | For example, a tool where I can say "Show me all public statics" or
"show me all private methods returning voids" etc.
Any ideas?
|
If you're fairly confident in your programming skills, you might want to
actually look into a writing your own tool to do this. It's not as difficult
as it sounds!
Get a parser generator like JavaCC, and provide it with a grammar file
describing the Java programming language (you can download this grammar file
from the JavaCC website). From there, parse all the files you're interested
into abstract syntax trees.
Then write a visitor to walk through all the trees and to mark or
otherwise store the nodes you're interested.
You might want to talk to the people in comp.compilers and
comp.compilers.tools.javacc if you want to take this path.
- Oliver
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|