Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Created April 19, 2014 22:12
Show Gist options
  • Save samueltcsantos/11099177 to your computer and use it in GitHub Desktop.
Save samueltcsantos/11099177 to your computer and use it in GitHub Desktop.
Como listar ao nomes de todos os métodos em um projeto.
/**
* the command has been executed, so extract extract the needed information
* from the application context.
*
* @see {https://github.com/samueltcsantos/eclipse-jdt}
*
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
workspace = ResourcesPlugin.getWorkspace();
root = workspace.getRoot();
IProject[] projects = root.getProjects();
for (IProject project : projects){
try {
IJavaProject javaProject = createIJavaProject(project);
for (IPackageFragment myPackage : getProjectPackages(javaProject)){
//only at the package from the source folder
if (myPackage.getKind() == IPackageFragmentRoot.K_SOURCE){
ICompilationUnit [] units = getCompilationUnits(myPackage);
for (ICompilationUnit unit: units){
IType [] types = getITypes(unit);
for (IType type : types){
for (IMethod method : getIMethods(type)){
System.out.println(method.getElementName());
}
}
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment