From 703c59215b4f3d2ed8160a2c67daaf6ff8b380e7 Mon Sep 17 00:00:00 2001 From: Philippe Herlin Date: Thu, 30 Oct 2003 23:27:59 +0000 Subject: [PATCH] Merging from eclipse-v2 branch Simplify the code : moving the deep nested CountVisitor class as a first level nested inner class. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2353 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/eclipse/actions/PMDCheckAction.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/actions/PMDCheckAction.java b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/actions/PMDCheckAction.java index 391a93a009..50c773bb47 100644 --- a/pmd-eclipse/src/net/sourceforge/pmd/eclipse/actions/PMDCheckAction.java +++ b/pmd-eclipse/src/net/sourceforge/pmd/eclipse/actions/PMDCheckAction.java @@ -34,6 +34,10 @@ import org.eclipse.ui.IWorkbenchPart; * @version $Revision$ * * $Log$ + * Revision 1.9 2003/10/30 23:27:59 phherlin + * Merging from eclipse-v2 branch + * Simplify the code : moving the deep nested CountVisitor class as a first level nested inner class. + * * Revision 1.8 2003/08/13 20:08:40 phherlin * Refactoring private->protected to remove warning about non accessible member access in enclosing types * @@ -85,6 +89,24 @@ public class PMDCheckAction implements IObjectActionDelegate { public void selectionChanged(IAction action, ISelection selection) { } + // Inner visitor to count number of childs of a resource + private class CountVisitor implements IResourceVisitor { + public int count = 0; + public boolean visit(IResource resource) { + boolean fVisitChildren = true; + count++; + + if ((resource instanceof IFile) + && (((IFile) resource).getFileExtension() != null) + && ((IFile) resource).getFileExtension().equals("java")) { + + fVisitChildren = false; + } + + return fVisitChildren; + } + }; + // Inner class to run PMD in a thread private class CheckPMDTask implements IRunnableWithProgress { private ISelection sel; @@ -149,23 +171,6 @@ public class PMDCheckAction implements IObjectActionDelegate { * @return the element count */ private int countElement(IStructuredSelection selection) { - final class CountVisitor implements IResourceVisitor { - public int count = 0; - public boolean visit(IResource resource) { - boolean fVisitChildren = true; - count++; - - if ((resource instanceof IFile) - && (((IFile) resource).getFileExtension() != null) - && ((IFile) resource).getFileExtension().equals("java")) { - - fVisitChildren = false; - } - - return fVisitChildren; - } - }; - CountVisitor visitor = new CountVisitor(); for (Iterator i = selection.iterator(); i.hasNext();) {