Refactory: removed unnecessary local variables and imports.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / ModelUpdater.java
index 83f09e9..cfc583a 100644 (file)
@@ -29,14 +29,15 @@ public class ModelUpdater {
        HashSet projectsToUpdate = new HashSet();
 
        /**
-        * Adds the given child handle to its parent's cache of children. 
+        * Adds the given child handle to its parent's cache of children.
         */
        protected void addToParentInfo(Openable child) {
 
                Openable parent = (Openable) child.getParent();
                if (parent != null && parent.isOpen()) {
                        try {
-                               JavaElementInfo info = (JavaElementInfo)parent.getElementInfo();
+                               JavaElementInfo info = (JavaElementInfo) parent
+                                               .getElementInfo();
                                info.addChild(child);
                        } catch (JavaModelException e) {
                                // do nothing - we already checked if open
@@ -45,7 +46,8 @@ public class ModelUpdater {
        }
 
        /**
-        * Closes the given element, which removes it from the cache of open elements.
+        * Closes the given element, which removes it from the cache of open
+        * elements.
         */
        protected static void close(Openable element) {
 
@@ -57,10 +59,11 @@ public class ModelUpdater {
        }
 
        /**
-        * Processing for an element that has been added:<ul>
+        * Processing for an element that has been added:
+        * <ul>
         * <li>If the element is a project, do nothing, and do not process
-        * children, as when a project is created it does not yet have any
-        * natures - specifically a java nature.
+        * children, as when a project is created it does not yet have any natures -
+        * specifically a java nature.
         * <li>If the elemet is not a project, process it as added (see
         * <code>basicElementAdded</code>.
         * </ul>
@@ -76,33 +79,38 @@ public class ModelUpdater {
                } else {
                        addToParentInfo(element);
 
-                       // Force the element to be closed as it might have been opened 
-                       // before the resource modification came in and it might have a new child
+                       // Force the element to be closed as it might have been opened
+                       // before the resource modification came in and it might have a new
+                       // child
                        // For example, in an IWorkspaceRunnable:
                        // 1. create a package fragment p using a java model operation
                        // 2. open package p
                        // 3. add file X.java in folder p
-                       // When the resource delta comes in, only the addition of p is notified, 
-                       // but the package p is already opened, thus its children are not recomputed
+                       // When the resource delta comes in, only the addition of p is
+                       // notified,
+                       // but the package p is already opened, thus its children are not
+                       // recomputed
                        // and it appears empty.
                        close(element);
                }
 
                switch (elementType) {
-                       case IJavaElement.PACKAGE_FRAGMENT_ROOT :
-                               // when a root is added, and is on the classpath, the project must be updated
-                               this.projectsToUpdate.add(element.getJavaProject());
-                               break;
-                       case IJavaElement.PACKAGE_FRAGMENT :
-                               // get rid of package fragment cache
-                               JavaProject project = (JavaProject) element.getJavaProject();
-//                             project.resetCaches();
-                               break;
+               case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+                       // when a root is added, and is on the classpath, the project must
+                       // be updated
+                       this.projectsToUpdate.add(element.getJavaProject());
+                       break;
+               case IJavaElement.PACKAGE_FRAGMENT:
+                       // get rid of package fragment cache
+                       //JavaProject project = (JavaProject) element.getJavaProject();
+                       // project.resetCaches();
+                       break;
                }
        }
 
        /**
-        * Generic processing for elements with changed contents:<ul>
+        * Generic processing for elements with changed contents:
+        * <ul>
         * <li>The element is closed such that any subsequent accesses will re-open
         * the element reflecting its new structure.
         * </ul>
@@ -113,7 +121,8 @@ public class ModelUpdater {
        }
 
        /**
-        * Generic processing for a removed element:<ul>
+        * Generic processing for a removed element:
+        * <ul>
         * <li>Close the element, removing its structure from the cache
         * <li>Remove the element from its parent's cache of children
         * <li>Add a REMOVED entry in the delta
@@ -128,34 +137,37 @@ public class ModelUpdater {
                int elementType = element.getElementType();
 
                switch (elementType) {
-                       case IJavaElement.JAVA_MODEL :
-//                             JavaModelManager.getJavaModelManager().getIndexManager().reset();
-                               break;
-                       case IJavaElement.JAVA_PROJECT :
-                               JavaModelManager.getJavaModelManager().removePerProjectInfo(
+               case IJavaElement.JAVA_MODEL:
+                       // JavaModelManager.getJavaModelManager().getIndexManager().reset();
+                       break;
+               case IJavaElement.JAVA_PROJECT:
+                       JavaModelManager.getJavaModelManager().removePerProjectInfo(
                                        (JavaProject) element);
-                               break;
-                       case IJavaElement.PACKAGE_FRAGMENT_ROOT :
-                               this.projectsToUpdate.add(element.getJavaProject());
-                               break;
-                       case IJavaElement.PACKAGE_FRAGMENT :
-                               // get rid of package fragment cache
-                               JavaProject project = (JavaProject) element.getJavaProject();
-//                             project.resetCaches();
-                               break;
+                       break;
+               case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+                       this.projectsToUpdate.add(element.getJavaProject());
+                       break;
+               case IJavaElement.PACKAGE_FRAGMENT:
+                       // get rid of package fragment cache
+                       //JavaProject project = (JavaProject) element.getJavaProject();
+                       // project.resetCaches();
+                       break;
                }
        }
 
        /**
-        * Converts a <code>IResourceDelta</code> rooted in a <code>Workspace</code> into
-        * the corresponding set of <code>IJavaElementDelta</code>, rooted in the
-        * relevant <code>JavaModel</code>s.
+        * Converts a <code>IResourceDelta</code> rooted in a
+        * <code>Workspace</code> into the corresponding set of
+        * <code>IJavaElementDelta</code>, rooted in the relevant
+        * <code>JavaModel</code>s.
         */
        public void processJavaDelta(IJavaElementDelta delta) {
 
-//             if (DeltaProcessor.VERBOSE){
-//                     System.out.println("UPDATING Model with Delta: ["+Thread.currentThread()+":" + delta + "]:");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
-//             }
+               // if (DeltaProcessor.VERBOSE){
+               // System.out.println("UPDATING Model with Delta:
+               // ["+Thread.currentThread()+":" + delta +
+               // "]:");//$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+               // }
 
                try {
                        this.traverseDelta(delta, null, null); // traverse delta
@@ -173,15 +185,16 @@ public class ModelUpdater {
 
        /**
         * Removes the given element from its parents cache of children. If the
-        * element does not have a parent, or the parent is not currently open,
-        * this has no effect. 
+        * element does not have a parent, or the parent is not currently open, this
+        * has no effect.
         */
        protected void removeFromParentInfo(Openable child) {
 
                Openable parent = (Openable) child.getParent();
                if (parent != null && parent.isOpen()) {
                        try {
-                               JavaElementInfo info = (JavaElementInfo)parent.getElementInfo();
+                               JavaElementInfo info = (JavaElementInfo) parent
+                                               .getElementInfo();
                                info.removeChild(child);
                        } catch (JavaModelException e) {
                                // do nothing - we already checked if open
@@ -190,50 +203,49 @@ public class ModelUpdater {
        }
 
        /**
-        * Converts an <code>IResourceDelta</code> and its children into
-        * the corresponding <code>IJavaElementDelta</code>s.
-        * Return whether the delta corresponds to a resource on the classpath.
-        * If it is not a resource on the classpath, it will be added as a non-java
-        * resource by the sender of this method.
+        * Converts an <code>IResourceDelta</code> and its children into the
+        * corresponding <code>IJavaElementDelta</code>s. Return whether the
+        * delta corresponds to a resource on the classpath. If it is not a resource
+        * on the classpath, it will be added as a non-java resource by the sender
+        * of this method.
         */
-       protected void traverseDelta(
-               IJavaElementDelta delta,
-               IPackageFragmentRoot root,
-               IJavaProject project) {
+       protected void traverseDelta(IJavaElementDelta delta,
+                       IPackageFragmentRoot root, IJavaProject project) {
 
                boolean processChildren = true;
 
                Openable element = (Openable) delta.getElement();
                switch (element.getElementType()) {
-                       case IJavaElement.JAVA_PROJECT :
-                               project = (IJavaProject) element;
-                               break;
-                       case IJavaElement.PACKAGE_FRAGMENT_ROOT :
-                               root = (IPackageFragmentRoot) element;
-                               break;
-                       case IJavaElement.COMPILATION_UNIT :
-                               // filter out working copies that are not primary (we don't want to add/remove them to/from the package fragment
-                               CompilationUnit cu = (CompilationUnit)element;
-                               if (cu.isWorkingCopy() && !cu.isPrimary()) {
-                                       return;
-                               }
-                       case IJavaElement.CLASS_FILE :
-                               processChildren = false;
-                               break;
+               case IJavaElement.JAVA_PROJECT:
+                       project = (IJavaProject) element;
+                       break;
+               case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+                       root = (IPackageFragmentRoot) element;
+                       break;
+               case IJavaElement.COMPILATION_UNIT:
+                       // filter out working copies that are not primary (we don't want to
+                       // add/remove them to/from the package fragment
+                       CompilationUnit cu = (CompilationUnit) element;
+                       if (cu.isWorkingCopy() && !cu.isPrimary()) {
+                               return;
+                       }
+               case IJavaElement.CLASS_FILE:
+                       processChildren = false;
+                       break;
                }
 
                switch (delta.getKind()) {
-                       case IJavaElementDelta.ADDED :
-                               elementAdded(element);
-                               break;
-                       case IJavaElementDelta.REMOVED :
-                               elementRemoved(element);
-                               break;
-                       case IJavaElementDelta.CHANGED :
-                               if ((delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0){
-                                       elementChanged(element);
-                               }
-                               break;
+               case IJavaElementDelta.ADDED:
+                       elementAdded(element);
+                       break;
+               case IJavaElementDelta.REMOVED:
+                       elementRemoved(element);
+                       break;
+               case IJavaElementDelta.CHANGED:
+                       if ((delta.getFlags() & IJavaElementDelta.F_CONTENT) != 0) {
+                               elementChanged(element);
+                       }
+                       break;
                }
                if (processChildren) {
                        IJavaElementDelta[] children = delta.getAffectedChildren();