Al usar JDT, es posible que desee buscar todas las referencias de un método determinado y luego hacer algo con las referencias. Esto se puede hacer usando el método JDTSearchProvider.searchMethodReference ().
El siguiente es un código de muestra:
// 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); } } } |