When using JDT, you may want to find all references of a given method and then do something with the references. This can be done by using method JDTSearchProvider.searchMethodReference().
The following is sample code:
// First of all, get all the type declaration of the class. IType [] typeDeclarationList = unit.getTypes(); for (IType typeDeclaration : typeDeclarationList) { // get methods list IMethod [] methodList = typeDeclaration.getMethods(); for (IMethod method : methodList) { final List<String> referenceList = new ArrayList<String>(); // check each method. String methodName = method.getElementName(); if (!method.isConstructor()) { // Finds the references of the method and record references of the method to referenceList parameter. JDTSearchProvider.searchMethodReference(referenceList, method, scope, iJavaProject); } } } |
U can use new JDT core and JDT ui to do this.
U can use your own implementation to replace some original dependences . U can use java model in this way.
yes where we can find it ? After three years you figured it out ?
I didn’t find it…
Some heads up here -> https://stackoverflow.com/questions/21839197/run-java-code-error-workspace-is-closed?rq=1
But this is not enough.
All the jar can be found in MavenRepository, but problem is after doing all one will get error like –
Exception in thread “main” java.lang.IllegalStateException: Workspace is closed.
So one needs to load Eclipse workspace first, which I found need lot of effort.
how i can get library for : JDTSearchProvider.searchMethodReference(referenceList, method, scope, iJavaProject)
yes where we can find it ? After two years you figured it out ?
I didn’t find it…
Hello
Where should i find the class JDTSearchProvider? It isn’t included in the JDT.