Skip to content

Instantly share code, notes, and snippets.

@samueltcsantos
Created April 19, 2014 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueltcsantos/11097956 to your computer and use it in GitHub Desktop.
Save samueltcsantos/11097956 to your computer and use it in GitHub Desktop.
Acessando o nomes dos pacotes com código fonte.
/**
* 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 {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot 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){
System.out.println("Package Name: " + myPackage.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