I want to write an eclipse plugin which can take a list of class names and return me a table of classes where they are being referenced in a given project. I was thinking if i can use eclipse cal hierarchy. But not sure how to invoke this command. could someone help me with this, Thanks in advance
3 Answers
It sounds like you want something like References->Workspace (Control+Shift+G) rather than the call hierarchy?
Have you used this option before? It uses FindReferencesAction, take a look at this class and you can see it building up a search query based on the currently selected IJavaElement.
Could you use this as a basic for a search query on multiple IJavaElements? Or do you want your own specific view?

- 2,551
- 24
- 27
-
I am not intending to create a seperate view,but i would like to write it into a file. view is not important. I just want to get the references. as objets is also fine.For your first question yes i have used it too. I do not mind using wither of these searches – Ravisha Mar 22 '11 at 04:05
-
How are you going to drive it? Is it from selecting a some IJavaElement(s)? – katsharp Mar 22 '11 at 09:33
-
Looks like a there could be a hacky way of doing it via running the search from the FindReferencesAction, then accessing the search results from the search query – katsharp Mar 22 '11 at 09:34
-
I will be having a list of strings containing class names for which i need to find the references in a given project – Ravisha Mar 23 '11 at 03:47
Have a look at the OpenCallHierarchyAction class of the org.eclipse.jdt.ui.internal.callhierarchy Package. This is internal Eclipse source code, but the code in the run(ITextSelection selection) method should be interesting to you.

- 916
- 8
- 17
-
Kool this is what i was searchin for. although adding reference of this into plug in project needs to include "org.eclipse.jdt.ui.source" in dependency. – Ravisha Mar 24 '11 at 04:50
Before you write anything like this, make sure you take a look at JDepend4Eclipse, it may do much of what you need. I have used it in the past to do package-level refactoring as well as understanding (and removing) circular dependencies.
If it doesn't do what you need, you may want to peek at their source code.

- 1,003
- 7
- 15