diff --git a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml index cfcb201ba3..a5ca6ade8d 100644 --- a/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml +++ b/pmd-eclipse-plugin/plugins/net.sourceforge.pmd.eclipse.plugin/plugin.xml @@ -226,6 +226,29 @@ id="pmdPopupMenus" name="PMD Popup Menus" point="org.eclipse.ui.popupMenus"> + + + + + + + + i = selection.iterator(); i.hasNext();) { - Object element = i.next(); - if (element instanceof AbstractPMDRecord) { - final IResource resource = ((AbstractPMDRecord) element).getResource(); - if (resource != null) { - cmd.addResource(resource); - } else { - log.warn("The selected object has no resource"); - log.debug(" -> selected object : " + element); - } - } else if (element instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) element; - IResource resource = (IResource) adaptable.getAdapter(IResource.class); - if (resource != null) { - cmd.addResource(resource); - } else { - log.warn("The selected object cannot adapt to a resource"); - log.debug(" -> selected object : " + element); - } - } else { - log.warn("The selected object is not adaptable"); - log.debug(" -> selected object : " + element); - } - } + // Add selected resources to the list of resources to be reviewed + for (Iterator i = selection.iterator(); i.hasNext();) { + Object element = i.next(); + if (element instanceof AbstractPMDRecord) { + final IResource resource = ((AbstractPMDRecord) element) + .getResource(); + if (resource != null) { + cmd.addResource(resource); + } else { + log.warn("The selected object has no resource"); + log.debug(" -> selected object : " + element); + } + } else if (element instanceof IWorkingSet) { + IWorkingSet set = (IWorkingSet) element; + for (IAdaptable adaptable : set.getElements()) { + addAdaptable(cmd, adaptable); + } + } else if (element instanceof IAdaptable) { + IAdaptable adaptable = (IAdaptable) element; + addAdaptable(cmd, adaptable); + } else { + log.warn("The selected object is not adaptable"); + log.debug(" -> selected object : " + element); + } + } - // Run the command - setupAndExecute(cmd, countElement(selection)); - } + // Run the command + setupAndExecute(cmd, countElement(selection)); + } + private void addAdaptable(ReviewCodeCmd cmd, IAdaptable adaptable) { + IResource resource = (IResource) adaptable.getAdapter(IResource.class); + if (resource != null) { + cmd.addResource(resource); + } else { + log.warn("The selected object cannot adapt to a resource"); + log.debug(" -> selected object : " + adaptable); + } + } + /** * Count the number of resources of a selection *