Fixed NullPointerException (problems == null) may occur
authoraxelcl <axelcl>
Thu, 21 Apr 2005 20:23:20 +0000 (20:23 +0000)
committeraxelcl <axelcl>
Thu, 21 Apr 2005 20:23:20 +0000 (20:23 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/AbstractImageBuilder.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/builder/IncrementalImageBuilder.java

index d60ea71..e1858c7 100644 (file)
@@ -87,52 +87,52 @@ public abstract class AbstractImageBuilder implements ICompilerRequestor {
 
     SourceFile compilationUnit = (SourceFile) result.getCompilationUnit(); // go directly back to the sourceFile
     if (!workQueue.isCompiled(compilationUnit)) {
-//      try {
-        workQueue.finished(compilationUnit);
-        try {
-                       updateProblemsFor(compilationUnit, result); // record compilation problems before potentially adding duplicate errors
-                       updateTasksFor(compilationUnit, result); // record tasks 
-               } catch (CoreException e) {
-                       throw internalException(e);
-               } 
-               
-        // String typeLocator = compilationUnit.typeLocator();
-        //                     ClassFile[] classFiles = result.getClassFiles();
-        //                     int length = classFiles.length;
-        //                     ArrayList duplicateTypeNames = null;
-        //                     ArrayList definedTypeNames = new ArrayList(length);
-        //                     for (int i = 0; i < length; i++) {
-        //                             ClassFile classFile = classFiles[i];
-        //                             char[][] compoundName = classFile.getCompoundName();
-        //                             char[] typeName = compoundName[compoundName.length - 1];
-        //                             boolean isNestedType = CharOperation.contains('$', typeName);
-        //
-        //                             // Look for a possible collision, if one exists, report an error but do not write the class file
-        //                             if (isNestedType) {
-        //                                     String qualifiedTypeName = new String(classFile.outerMostEnclosingClassFile().fileName());
-        //                                     if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator))
-        //                                             continue;
-        //                             } else {
-        //                                     String qualifiedTypeName = new String(classFile.fileName()); // the qualified type name "p1/p2/A"
-        //                                     if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) {
-        //                                             if (duplicateTypeNames == null)
-        //                                                     duplicateTypeNames = new ArrayList();
-        //                                             duplicateTypeNames.add(compoundName);
-        //                                             createErrorFor(compilationUnit.resource, ProjectPrefUtil.bind("build.duplicateClassFile", new String(typeName)));
-        // //$NON-NLS-1$
-        //                                             continue;
-        //                                     }
-        //                                     newState.recordLocatorForType(qualifiedTypeName, typeLocator);
-        //                             }
-        //                             definedTypeNames.add(writeClassFile(classFile, compilationUnit.sourceLocation.binaryFolder, !isNestedType));
-        //                     }
-
-        //                     finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames);
-        notifier.compiled(compilationUnit);
-//      } catch (CoreException e) {
-//        Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$
-//        createErrorFor(compilationUnit.resource, Util.bind("build.inconsistentClassFile")); //$NON-NLS-1$
-//      }
+      //      try {
+      workQueue.finished(compilationUnit);
+      try {
+        updateProblemsFor(compilationUnit, result); // record compilation problems before potentially adding duplicate errors
+        updateTasksFor(compilationUnit, result); // record tasks
+      } catch (CoreException e) {
+        throw internalException(e);
+      }
+
+      // String typeLocator = compilationUnit.typeLocator();
+      //                       ClassFile[] classFiles = result.getClassFiles();
+      //                       int length = classFiles.length;
+      //                       ArrayList duplicateTypeNames = null;
+      //                       ArrayList definedTypeNames = new ArrayList(length);
+      //                       for (int i = 0; i < length; i++) {
+      //                               ClassFile classFile = classFiles[i];
+      //                               char[][] compoundName = classFile.getCompoundName();
+      //                               char[] typeName = compoundName[compoundName.length - 1];
+      //                               boolean isNestedType = CharOperation.contains('$', typeName);
+      //
+      //                               // Look for a possible collision, if one exists, report an error but do not write the class file
+      //                               if (isNestedType) {
+      //                                       String qualifiedTypeName = new String(classFile.outerMostEnclosingClassFile().fileName());
+      //                                       if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator))
+      //                                               continue;
+      //                               } else {
+      //                                       String qualifiedTypeName = new String(classFile.fileName()); // the qualified type name "p1/p2/A"
+      //                                       if (newState.isDuplicateLocator(qualifiedTypeName, typeLocator)) {
+      //                                               if (duplicateTypeNames == null)
+      //                                                       duplicateTypeNames = new ArrayList();
+      //                                               duplicateTypeNames.add(compoundName);
+      //                                               createErrorFor(compilationUnit.resource, ProjectPrefUtil.bind("build.duplicateClassFile", new String(typeName)));
+      // //$NON-NLS-1$
+      //                                               continue;
+      //                                       }
+      //                                       newState.recordLocatorForType(qualifiedTypeName, typeLocator);
+      //                               }
+      //                               definedTypeNames.add(writeClassFile(classFile, compilationUnit.sourceLocation.binaryFolder, !isNestedType));
+      //                       }
+
+      //                       finishedWith(typeLocator, result, compilationUnit.getMainTypeName(), definedTypeNames, duplicateTypeNames);
+      notifier.compiled(compilationUnit);
+      //      } catch (CoreException e) {
+      //        Util.log(e, "JavaBuilder handling CoreException"); //$NON-NLS-1$
+      //        createErrorFor(compilationUnit.resource, Util.bind("build.inconsistentClassFile")); //$NON-NLS-1$
+      //      }
     }
   }
 
@@ -361,13 +361,12 @@ public abstract class AbstractImageBuilder implements ICompilerRequestor {
 
       /*
        * Do NOT want to populate the Java Model just to find the matching Java element. Also cannot query compilation units located
-       * in folders with invalid package names such as 'a/b.c.d/e'.
-       *  // compute a user-friendly location IJavaElement element = JavaCore.create(resource); if (element instanceof
-       * net.sourceforge.phpdt.core.ICompilationUnit) { // try to find a finer grain element
-       * net.sourceforge.phpdt.core.ICompilationUnit unit = (net.sourceforge.phpdt.core.ICompilationUnit) element; IJavaElement
-       * fragment = unit.getElementAt(problem.getSourceStart()); if (fragment != null) element = fragment; } String location = null;
-       * if (element instanceof JavaElement) location = ((JavaElement) element).readableName(); if (location != null)
-       * marker.setAttribute(IMarker.LOCATION, location);
+       * in folders with invalid package names such as 'a/b.c.d/e'. // compute a user-friendly location IJavaElement element =
+       * JavaCore.create(resource); if (element instanceof net.sourceforge.phpdt.core.ICompilationUnit) { // try to find a finer
+       * grain element net.sourceforge.phpdt.core.ICompilationUnit unit = (net.sourceforge.phpdt.core.ICompilationUnit) element;
+       * IJavaElement fragment = unit.getElementAt(problem.getSourceStart()); if (fragment != null) element = fragment; } String
+       * location = null; if (element instanceof JavaElement) location = ((JavaElement) element).readableName(); if (location !=
+       * null) marker.setAttribute(IMarker.LOCATION, location);
        */
 
       //               if (missingClassFile != null)
@@ -414,10 +413,12 @@ public abstract class AbstractImageBuilder implements ICompilerRequestor {
     if (problems == null || problems.length == 0)
       return;
     //axelcl start insert - calculate line numbers
-    for (int i = 0; i < problems.length; i++) {
-      if (problems[i].getSourceLineNumber() == 1) {
-        problems[i].setSourceLineNumber(ProblemHandler
-            .searchLineNumber(result.lineSeparatorPositions, problems[i].getSourceStart()));
+    if (problems != null) {
+      for (int i = 0; i < problems.length; i++) {
+        if (problems[i].getSourceLineNumber() == 1) {
+          problems[i].setSourceLineNumber(ProblemHandler.searchLineNumber(result.lineSeparatorPositions, problems[i]
+              .getSourceStart()));
+        }
       }
     }
     //axelcl end insert
index 61db63d..6365697 100644 (file)
@@ -9,6 +9,7 @@
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
 package net.sourceforge.phpdt.internal.core.builder;
+
 import java.util.ArrayList;
 
 import net.sourceforge.phpdt.core.compiler.IProblem;
@@ -24,18 +25,27 @@ import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+
 /**
  * The incremental image builder
  */
 public class IncrementalImageBuilder extends AbstractImageBuilder {
   protected ArrayList sourceFiles;
+
   protected ArrayList previousSourceFiles;
+
   protected ArrayList qualifiedStrings;
+
   protected ArrayList simpleStrings;
+
   protected SimpleLookupTable secondaryTypesToRemove;
+
   protected boolean hasStructuralChanges;
+
   protected int compileLoop;
+
   public static int MaxCompileLoop = 5; // perform a full build if it takes
+
   // more than ? incremental compile
   // loops
   protected IncrementalImageBuilder(PHPBuilder javaBuilder) {
@@ -49,6 +59,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     this.hasStructuralChanges = false;
     this.compileLoop = 0;
   }
+
   public boolean build(SimpleLookupTable deltas) {
     // initialize builder
     // walk this project's deltas, find changed source files
@@ -66,56 +77,55 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     try {
       resetCollections();
       notifier.subTask(Util.bind("build.analyzingDeltas")); //$NON-NLS-1$
-      IResourceDelta sourceDelta = (IResourceDelta) deltas
-          .get(javaBuilder.currentProject);
+      IResourceDelta sourceDelta = (IResourceDelta) deltas.get(javaBuilder.currentProject);
       if (sourceDelta != null) {
         sourceDelta.accept(new ParserVisitor(javaBuilder.currentProject, notifier.monitor));
-        
+
         if (!findSourceFiles(sourceDelta))
           return false;
       }
       notifier.updateProgressDelta(0.10f);
-//      Object[] keyTable = deltas.keyTable;
-//      Object[] valueTable = deltas.valueTable;
-////      final IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
-////          .getIndexManager(javaBuilder.currentProject);
-//      for (int i = 0, l = valueTable.length; i < l; i++) {
-//        IResourceDelta delta = (IResourceDelta) valueTable[i];
-//        if (delta != null) {
-//          IResource resource = delta.getResource();
-//          int resourceType = resource.getType();
-//          if (resourceType == IResource.FILE) {
-//            switch (delta.getKind()) {
-//              case IResourceDelta.ADDED :
-//                if ((resource.getFileExtension() != null)
-//                    && PHPFileUtil.isPHPFile((IFile) resource)) {
-//                  // update indexfile for the project:
-////                  indexManager.addFile((IFile) resource);
-//                }
-//                break;
-//              case IResourceDelta.CHANGED :
-//                if ((resource.getFileExtension() != null)
-//                    && PHPFileUtil.isPHPFile((IFile) resource)) {
-//                  // update indexfile for the project:
-////                  indexManager.changeFile((IFile) resource);
-//                }
-//                break;
-//              case IResourceDelta.REMOVED :
-//                if ((resource.getFileExtension() != null)
-//                    && PHPFileUtil.isPHPFile((IFile) resource)) {
-//                  // update indexfile for the project:
-////                  indexManager.removeFile((IFile) resource);
-//                }
-//                break;
-//            }
-//          }
-//          //                         ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[])
-//          // javaBuilder.binaryLocationsPerProject.get(keyTable[i]);
-//          //                         if (classFoldersAndJars != null)
-//          //                                 if (!findAffectedSourceFiles(delta, classFoldersAndJars)) return
-//          // false;
-//        }
-//      }
+      //      Object[] keyTable = deltas.keyTable;
+      //      Object[] valueTable = deltas.valueTable;
+      //// final IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault()
+      //// .getIndexManager(javaBuilder.currentProject);
+      //      for (int i = 0, l = valueTable.length; i < l; i++) {
+      //        IResourceDelta delta = (IResourceDelta) valueTable[i];
+      //        if (delta != null) {
+      //          IResource resource = delta.getResource();
+      //          int resourceType = resource.getType();
+      //          if (resourceType == IResource.FILE) {
+      //            switch (delta.getKind()) {
+      //              case IResourceDelta.ADDED :
+      //                if ((resource.getFileExtension() != null)
+      //                    && PHPFileUtil.isPHPFile((IFile) resource)) {
+      //                  // update indexfile for the project:
+      //// indexManager.addFile((IFile) resource);
+      //                }
+      //                break;
+      //              case IResourceDelta.CHANGED :
+      //                if ((resource.getFileExtension() != null)
+      //                    && PHPFileUtil.isPHPFile((IFile) resource)) {
+      //                  // update indexfile for the project:
+      //// indexManager.changeFile((IFile) resource);
+      //                }
+      //                break;
+      //              case IResourceDelta.REMOVED :
+      //                if ((resource.getFileExtension() != null)
+      //                    && PHPFileUtil.isPHPFile((IFile) resource)) {
+      //                  // update indexfile for the project:
+      //// indexManager.removeFile((IFile) resource);
+      //                }
+      //                break;
+      //            }
+      //          }
+      //          // ClasspathLocation[] classFoldersAndJars = (ClasspathLocation[])
+      //          // javaBuilder.binaryLocationsPerProject.get(keyTable[i]);
+      //          // if (classFoldersAndJars != null)
+      //          // if (!findAffectedSourceFiles(delta, classFoldersAndJars)) return
+      //          // false;
+      //        }
+      //      }
       notifier.updateProgressDelta(0.10f);
       notifier.subTask(Util.bind("build.analyzingSources")); //$NON-NLS-1$
       addAffectedSourceFiles();
@@ -125,8 +135,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
       while (sourceFiles.size() > 0) { // added to in acceptResult
         if (++this.compileLoop > MaxCompileLoop) {
           if (PHPBuilder.DEBUG)
-            System.out
-                .println("ABORTING incremental build... exceeded loop count"); //$NON-NLS-1$
+            System.out.println("ABORTING incremental build... exceeded loop count"); //$NON-NLS-1$
           return false;
         }
         notifier.checkCancel();
@@ -134,11 +143,10 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
         sourceFiles.toArray(allSourceFiles);
         resetCollections();
         workQueue.addAll(allSourceFiles);
-        notifier.setProgressPerCompilationUnit(increment
-            / allSourceFiles.length);
+        notifier.setProgressPerCompilationUnit(increment / allSourceFiles.length);
         increment = increment / 2;
         compile(allSourceFiles);
-//        removeSecondaryTypes();
+        //        removeSecondaryTypes();
         addAffectedSourceFiles();
       }
       if (this.hasStructuralChanges && javaBuilder.javaProject.hasCycleMarker())
@@ -147,8 +155,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
       // abort the incremental build and let the batch builder handle the
       // problem
       if (PHPBuilder.DEBUG)
-        System.out.println("ABORTING incremental build... cannot find "
-            + e.qualifiedTypeName + //$NON-NLS-1$
+        System.out.println("ABORTING incremental build... cannot find " + e.qualifiedTypeName + //$NON-NLS-1$
             ". Could have been renamed inside its existing source file."); //$NON-NLS-1$
       return false;
     } catch (CoreException e) {
@@ -158,56 +165,58 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     }
     return true;
   }
+
   protected void addAffectedSourceFiles() {
     if (qualifiedStrings.isEmpty() && simpleStrings.isEmpty())
       return;
     // the qualifiedStrings are of the form 'p1/p2' & the simpleStrings are
     // just 'X'
-//    char[][][] qualifiedNames = ReferenceCollection
-//        .internQualifiedNames(qualifiedStrings);
+    //    char[][][] qualifiedNames = ReferenceCollection
+    //        .internQualifiedNames(qualifiedStrings);
     // if a well known qualified name was found then we can skip over these
-//    if (qualifiedNames.length < qualifiedStrings.size())
-//      qualifiedNames = null;
-//    char[][] simpleNames = ReferenceCollection.internSimpleNames(simpleStrings);
+    //    if (qualifiedNames.length < qualifiedStrings.size())
+    //      qualifiedNames = null;
+    //    char[][] simpleNames = ReferenceCollection.internSimpleNames(simpleStrings);
     // if a well known name was found then we can skip over these
-//    if (simpleNames.length < simpleStrings.size())
-//      simpleNames = null;
-//    Object[] keyTable = newState.references.keyTable;
-//    Object[] valueTable = newState.references.valueTable;
-//    next : for (int i = 0, l = valueTable.length; i < l; i++) {
-//      ReferenceCollection refs = (ReferenceCollection) valueTable[i];
-//      if (refs != null && refs.includes(qualifiedNames, simpleNames)) {
-//        String typeLocator = (String) keyTable[i];
-//        IFile file = javaBuilder.currentProject.getFile(typeLocator);
-//        if (file.exists()) {
-//          ClasspathMultiDirectory md = sourceLocations[0];
-//          if (sourceLocations.length > 1) {
-//            IPath sourceFileFullPath = file.getFullPath();
-//            for (int j = 0, m = sourceLocations.length; j < m; j++) {
-//              if (sourceLocations[j].sourceFolder.getFullPath().isPrefixOf(
-//                  sourceFileFullPath)) {
-//                md = sourceLocations[j];
-//                if (md.exclusionPatterns == null
-//                    || !ProjectPrefUtil.isExcluded(file, md.exclusionPatterns))
-//                  break;
-//              }
-//            }
-//          }
-//          SourceFile sourceFile = new SourceFile(file, md, encoding);
-//          if (sourceFiles.contains(sourceFile))
-//            continue next;
-//          if (compiledAllAtOnce && previousSourceFiles != null
-//              && previousSourceFiles.contains(sourceFile))
-//            continue next; // can skip previously compiled files since already
-//          // saw hierarchy related problems
-//          if (PHPBuilder.DEBUG)
-//            System.out.println("  adding affected source file " + typeLocator); //$NON-NLS-1$
-//          //                         // update indexfile for the project:
-//          sourceFiles.add(sourceFile);
-//        }
-//      }
-//    }
+    //    if (simpleNames.length < simpleStrings.size())
+    //      simpleNames = null;
+    //    Object[] keyTable = newState.references.keyTable;
+    //    Object[] valueTable = newState.references.valueTable;
+    //    next : for (int i = 0, l = valueTable.length; i < l; i++) {
+    //      ReferenceCollection refs = (ReferenceCollection) valueTable[i];
+    //      if (refs != null && refs.includes(qualifiedNames, simpleNames)) {
+    //        String typeLocator = (String) keyTable[i];
+    //        IFile file = javaBuilder.currentProject.getFile(typeLocator);
+    //        if (file.exists()) {
+    //          ClasspathMultiDirectory md = sourceLocations[0];
+    //          if (sourceLocations.length > 1) {
+    //            IPath sourceFileFullPath = file.getFullPath();
+    //            for (int j = 0, m = sourceLocations.length; j < m; j++) {
+    //              if (sourceLocations[j].sourceFolder.getFullPath().isPrefixOf(
+    //                  sourceFileFullPath)) {
+    //                md = sourceLocations[j];
+    //                if (md.exclusionPatterns == null
+    //                    || !ProjectPrefUtil.isExcluded(file, md.exclusionPatterns))
+    //                  break;
+    //              }
+    //            }
+    //          }
+    //          SourceFile sourceFile = new SourceFile(file, md, encoding);
+    //          if (sourceFiles.contains(sourceFile))
+    //            continue next;
+    //          if (compiledAllAtOnce && previousSourceFiles != null
+    //              && previousSourceFiles.contains(sourceFile))
+    //            continue next; // can skip previously compiled files since already
+    //          // saw hierarchy related problems
+    //          if (PHPBuilder.DEBUG)
+    //            System.out.println(" adding affected source file " + typeLocator); //$NON-NLS-1$
+    //          // // update indexfile for the project:
+    //          sourceFiles.add(sourceFile);
+    //        }
+    //      }
+    //    }
   }
+
   protected void addDependentsOf(IPath path, boolean hasStructuralChanges) {
     if (hasStructuralChanges) {
       newState.tagAsStructurallyChanged();
@@ -230,6 +239,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
       simpleStrings.add(typeName);
     }
   }
+
   protected void cleanUp() {
     super.cleanUp();
     this.sourceFiles = null;
@@ -240,6 +250,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     this.hasStructuralChanges = false;
     this.compileLoop = 0;
   }
+
   //protected boolean findAffectedSourceFiles(IResourceDelta delta,
   // ClasspathLocation[] classFoldersAndJars) {
   //   for (int i = 0, l = classFoldersAndJars.length; i < l; i++) {
@@ -277,52 +288,48 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
   //   }
   //   return true;
   //}
-  protected void findAffectedSourceFiles(IResourceDelta binaryDelta,
-      int segmentCount) {
+  protected void findAffectedSourceFiles(IResourceDelta binaryDelta, int segmentCount) {
     // When a package becomes a type or vice versa, expect 2 deltas,
     // one on the folder & one on the class file
     IResource resource = binaryDelta.getResource();
     switch (resource.getType()) {
-      case IResource.FOLDER :
-        switch (binaryDelta.getKind()) {
-          case IResourceDelta.ADDED :
-          case IResourceDelta.REMOVED :
-            IPath packagePath = resource.getFullPath().removeFirstSegments(
-                segmentCount);
-            String packageName = packagePath.toString();
-            if (binaryDelta.getKind() == IResourceDelta.ADDED) {
-              // see if any known source file is from the same package...
-              // classpath already includes new package
-//              if (!newState.isKnownPackage(packageName)) {
-//                if (PHPBuilder.DEBUG)
-//                  System.out.println("Found added package " + packageName); //$NON-NLS-1$
-//                addDependentsOf(packagePath, false);
-//                return;
-//              }
-              if (PHPBuilder.DEBUG)
-                System.out.println("Skipped dependents of added package "
-                    + packageName); //$NON-NLS-1$
-            } else {
-              // see if the package still exists on the classpath
-              //                                               if (!nameEnvironment.isPackage(packageName)) {
-              //                                                       if (JavaBuilder.DEBUG)
-              //                                                               System.out.println("Found removed package " + packageName);
-              // //$NON-NLS-1$
-              //                                                       addDependentsOf(packagePath, false);
-              //                                                       return;
-              //                                               }
-              if (PHPBuilder.DEBUG)
-                System.out.println("Skipped dependents of removed package "
-                    + packageName); //$NON-NLS-1$
-            }
-          // fall thru & traverse the sub-packages and .class files
-          case IResourceDelta.CHANGED :
-            IResourceDelta[] children = binaryDelta.getAffectedChildren();
-            for (int i = 0, l = children.length; i < l; i++)
-              findAffectedSourceFiles(children[i], segmentCount);
+    case IResource.FOLDER:
+      switch (binaryDelta.getKind()) {
+      case IResourceDelta.ADDED:
+      case IResourceDelta.REMOVED:
+        IPath packagePath = resource.getFullPath().removeFirstSegments(segmentCount);
+        String packageName = packagePath.toString();
+        if (binaryDelta.getKind() == IResourceDelta.ADDED) {
+          // see if any known source file is from the same package...
+          // classpath already includes new package
+          //              if (!newState.isKnownPackage(packageName)) {
+          //                if (PHPBuilder.DEBUG)
+          //                  System.out.println("Found added package " + packageName); //$NON-NLS-1$
+          //                addDependentsOf(packagePath, false);
+          //                return;
+          //              }
+          if (PHPBuilder.DEBUG)
+            System.out.println("Skipped dependents of added package " + packageName); //$NON-NLS-1$
+        } else {
+          // see if the package still exists on the classpath
+          //                                           if (!nameEnvironment.isPackage(packageName)) {
+          //                                                   if (JavaBuilder.DEBUG)
+          //                                                           System.out.println("Found removed package " + packageName);
+          // //$NON-NLS-1$
+          //                                                   addDependentsOf(packagePath, false);
+          //                                                   return;
+          //                                           }
+          if (PHPBuilder.DEBUG)
+            System.out.println("Skipped dependents of removed package " + packageName); //$NON-NLS-1$
         }
-        return;
-      case IResource.FILE :
+      // fall thru & traverse the sub-packages and .class files
+      case IResourceDelta.CHANGED:
+        IResourceDelta[] children = binaryDelta.getAffectedChildren();
+        for (int i = 0, l = children.length; i < l; i++)
+          findAffectedSourceFiles(children[i], segmentCount);
+      }
+      return;
+    case IResource.FILE:
     //                 if (ProjectPrefUtil.isClassFileName(resource.getName())) {
     //                         IPath typePath =
     // resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
@@ -346,6 +353,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     //                 }
     }
   }
+
   protected boolean findSourceFiles(IResourceDelta delta) throws CoreException {
     for (int i = 0, l = sourceLocations.length; i < l; i++) {
       ClasspathMultiDirectory md = sourceLocations[i];
@@ -358,13 +366,11 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
           if (!isExcludedFromProject(children[j].getFullPath()))
             findSourceFiles(children[j], md, segmentCount);
       } else {
-        IResourceDelta sourceDelta = delta.findMember(md.sourceFolder
-            .getProjectRelativePath());
+        IResourceDelta sourceDelta = delta.findMember(md.sourceFolder.getProjectRelativePath());
         if (sourceDelta != null) {
           if (sourceDelta.getKind() == IResourceDelta.REMOVED) {
             if (PHPBuilder.DEBUG)
-              System.out
-                  .println("ABORTING incremental build... found removed source folder"); //$NON-NLS-1$
+              System.out.println("ABORTING incremental build... found removed source folder"); //$NON-NLS-1$
             return false; // removed source folder should not make it here, but
             // handle anyways (ADDED is supported)
           }
@@ -378,300 +384,291 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     }
     return true;
   }
-  protected void findSourceFiles(IResourceDelta sourceDelta,
-      ClasspathMultiDirectory md, int segmentCount) throws CoreException {
+
+  protected void findSourceFiles(IResourceDelta sourceDelta, ClasspathMultiDirectory md, int segmentCount) throws CoreException {
     // When a package becomes a type or vice versa, expect 2 deltas,
     // one on the folder & one on the source file
     IResource resource = sourceDelta.getResource();
-    if (md.exclusionPatterns != null
-        && Util.isExcluded(resource, md.exclusionPatterns))
+    if (md.exclusionPatterns != null && Util.isExcluded(resource, md.exclusionPatterns))
       return;
     switch (resource.getType()) {
-      case IResource.FOLDER :
-        switch (sourceDelta.getKind()) {
-          case IResourceDelta.ADDED :
-            IPath addedPackagePath = resource.getFullPath()
-                .removeFirstSegments(segmentCount);
-           // createFolder(addedPackagePath, md.binaryFolder); // ensure package
-            // exists in the
-            // output folder
-            // add dependents even when the package thinks it exists to be on
-            // the safe side
-            if (PHPBuilder.DEBUG)
-              System.out.println("Found added package " + addedPackagePath); //$NON-NLS-1$
-            addDependentsOf(addedPackagePath, true);
-          // fall thru & collect all the source files
-          case IResourceDelta.CHANGED :
-            IResourceDelta[] children = sourceDelta.getAffectedChildren();
-            for (int i = 0, l = children.length; i < l; i++)
-              findSourceFiles(children[i], md, segmentCount);
-            return;
-          case IResourceDelta.REMOVED :
-            IPath removedPackagePath = resource.getFullPath()
-                .removeFirstSegments(segmentCount);
-            if (sourceLocations.length > 1) {
-              for (int i = 0, l = sourceLocations.length; i < l; i++) {
-                if (sourceLocations[i].sourceFolder.getFolder(
-                    removedPackagePath).exists()) {
-                  // only a package fragment was removed, same as removing
-                  // multiple source files
-//                  createFolder(removedPackagePath, md.binaryFolder); // ensure
-                  // package
-                  // exists
-                  // in the
-                  // output
-                  // folder
-                  IResourceDelta[] removedChildren = sourceDelta
-                      .getAffectedChildren();
-                  for (int j = 0, m = removedChildren.length; j < m; j++)
-                    findSourceFiles(removedChildren[j], md, segmentCount);
-                  return;
-                } 
-              }
-            }
-//            IFolder removedPackageFolder = md.binaryFolder
-//                .getFolder(removedPackagePath);
-//            if (removedPackageFolder.exists())
-//              removedPackageFolder.delete(IResource.FORCE, null);
-            // add dependents even when the package thinks it does not exist to
-            // be on the safe side
-            if (PHPBuilder.DEBUG)
-              System.out.println("Found removed package " + removedPackagePath); //$NON-NLS-1$
-            addDependentsOf(removedPackagePath, true);
-            newState.removePackage(sourceDelta);
-        }
+    case IResource.FOLDER:
+      switch (sourceDelta.getKind()) {
+      case IResourceDelta.ADDED:
+        IPath addedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
+        // createFolder(addedPackagePath, md.binaryFolder); // ensure package
+        // exists in the
+        // output folder
+        // add dependents even when the package thinks it exists to be on
+        // the safe side
+        if (PHPBuilder.DEBUG)
+          System.out.println("Found added package " + addedPackagePath); //$NON-NLS-1$
+        addDependentsOf(addedPackagePath, true);
+      // fall thru & collect all the source files
+      case IResourceDelta.CHANGED:
+        IResourceDelta[] children = sourceDelta.getAffectedChildren();
+        for (int i = 0, l = children.length; i < l; i++)
+          findSourceFiles(children[i], md, segmentCount);
         return;
-      case IResource.FILE :
-        String resourceName = resource.getName();
-        if (net.sourceforge.phpdt.internal.compiler.util.Util.isJavaFileName(resourceName)) {
-          IPath typePath = resource.getFullPath().removeFirstSegments(
-              segmentCount).removeFileExtension();
-          String typeLocator = resource.getProjectRelativePath().toString();
-          switch (sourceDelta.getKind()) {
-            case IResourceDelta.ADDED :
-              if (PHPBuilder.DEBUG)
-                System.out.println("Compile this added source file "
-                    + typeLocator); //$NON-NLS-1$
-              sourceFiles.add(new SourceFile((IFile) resource, md, encoding));
-              String typeName = typePath.toString();
-//              if (!newState.isDuplicateLocator(typeName, typeLocator)) { // adding
-//                // dependents
-//                // results
-//                // in
-//                // 2
-//                // duplicate
-//                // errors
-//                if (PHPBuilder.DEBUG)
-//                  System.out.println("Found added source file " + typeName); //$NON-NLS-1$
-//                addDependentsOf(typePath, true);
-//              }
-              return;
-            case IResourceDelta.REMOVED :
-//              char[][] definedTypeNames = newState
-//                  .getDefinedTypeNamesFor(typeLocator);
-//              if (definedTypeNames == null) { // defined a single type matching
-//                // typePath
-//                removeClassFile(typePath, md.binaryFolder);
-//                if ((sourceDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
-//                  // remove problems and tasks for a compilation unit that is
-//                  // being moved (to another package or renamed)
-//                  // if the target file is a compilation unit, the new cu will
-//                  // be recompiled
-//                  // if the target file is a non-java resource, then markers
-//                  // are removed
-//                  // see bug 2857
-//                  IResource movedFile = javaBuilder.workspaceRoot
-//                      .getFile(sourceDelta.getMovedToPath());
-//                  PHPBuilder.removeProblemsAndTasksFor(movedFile);
-//                }
-//              } else {
-                if (PHPBuilder.DEBUG)
-                  System.out.println("Found removed source file "
-                      + typePath.toString()); //$NON-NLS-1$
-                addDependentsOf(typePath, true); // add dependents of the
-                // source file since it may be
-                // involved in a name
-                // collision
-//                if (definedTypeNames.length > 0) { // skip it if it failed to
-//                  // successfully define a
-//                  // type
-//                  IPath packagePath = typePath.removeLastSegments(1);
-//                  for (int i = 0, l = definedTypeNames.length; i < l; i++)
-//                    removeClassFile(packagePath.append(new String(
-//                        definedTypeNames[i])), md.binaryFolder);
-//                }
-//              }
-//              newState.removeLocator(typeLocator);
-              return;
-            case IResourceDelta.CHANGED :
-              if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0)
-                return; // skip it since it really isn't changed
-              if (PHPBuilder.DEBUG)
-                System.out.println("Compile this changed source file "
-                    + typeLocator); //$NON-NLS-1$
-              sourceFiles.add(new SourceFile((IFile) resource, md, encoding));
-          }
-          return;
-          //                   } else if (ProjectPrefUtil.isClassFileName(resourceName)) {
-          //                           return; // skip class files
-        } else if (md.hasIndependentOutputFolder) {
-          if (javaBuilder.filterExtraResource(resource))
-            return;
-          // copy all other resource deltas to the output folder
-          IPath resourcePath = resource.getFullPath().removeFirstSegments(
-              segmentCount);
-//          IResource outputFile = md.binaryFolder.getFile(resourcePath);
-          switch (sourceDelta.getKind()) {
-            case IResourceDelta.ADDED :
-//              if (outputFile.exists()) {
-//                if (PHPBuilder.DEBUG)
-//                  System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$
-//                outputFile.delete(IResource.FORCE, null);
-//              }
-              if (PHPBuilder.DEBUG)
-                System.out.println("Copying added file " + resourcePath); //$NON-NLS-1$
-//              createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure
+      case IResourceDelta.REMOVED:
+        IPath removedPackagePath = resource.getFullPath().removeFirstSegments(segmentCount);
+        if (sourceLocations.length > 1) {
+          for (int i = 0, l = sourceLocations.length; i < l; i++) {
+            if (sourceLocations[i].sourceFolder.getFolder(removedPackagePath).exists()) {
+              // only a package fragment was removed, same as removing
+              // multiple source files
+              //                  createFolder(removedPackagePath, md.binaryFolder); // ensure
               // package
               // exists
-              // in
-              // the
+              // in the
               // output
               // folder
-//              resource.copy(outputFile.getFullPath(), IResource.FORCE, null);
-//              outputFile.setDerived(true);
+              IResourceDelta[] removedChildren = sourceDelta.getAffectedChildren();
+              for (int j = 0, m = removedChildren.length; j < m; j++)
+                findSourceFiles(removedChildren[j], md, segmentCount);
               return;
-            case IResourceDelta.REMOVED :
-//              if (outputFile.exists()) {
-//                if (PHPBuilder.DEBUG)
-//                  System.out.println("Deleting removed file " + resourcePath); //$NON-NLS-1$
-//                outputFile.delete(IResource.FORCE, null);
-//              }
-              return;
-            case IResourceDelta.CHANGED :
-              if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0)
-                return; // skip it since it really isn't changed
-//              if (outputFile.exists()) {
-//                if (PHPBuilder.DEBUG)
-//                  System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$
-//                outputFile.delete(IResource.FORCE, null);
-//              }
-              if (PHPBuilder.DEBUG)
-                System.out.println("Copying changed file " + resourcePath); //$NON-NLS-1$
-            //  createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure
-              // package
-              // exists
-              // in
-              // the
-              // output
-              // folder
-//              resource.copy(outputFile.getFullPath(), IResource.FORCE, null);
-//              outputFile.setDerived(true);
+            }
           }
+        }
+        //            IFolder removedPackageFolder = md.binaryFolder
+        //                .getFolder(removedPackagePath);
+        //            if (removedPackageFolder.exists())
+        //              removedPackageFolder.delete(IResource.FORCE, null);
+        // add dependents even when the package thinks it does not exist to
+        // be on the safe side
+        if (PHPBuilder.DEBUG)
+          System.out.println("Found removed package " + removedPackagePath); //$NON-NLS-1$
+        addDependentsOf(removedPackagePath, true);
+        newState.removePackage(sourceDelta);
+      }
+      return;
+    case IResource.FILE:
+      String resourceName = resource.getName();
+      if (net.sourceforge.phpdt.internal.compiler.util.Util.isJavaFileName(resourceName)) {
+        IPath typePath = resource.getFullPath().removeFirstSegments(segmentCount).removeFileExtension();
+        String typeLocator = resource.getProjectRelativePath().toString();
+        switch (sourceDelta.getKind()) {
+        case IResourceDelta.ADDED:
+          if (PHPBuilder.DEBUG)
+            System.out.println("Compile this added source file " + typeLocator); //$NON-NLS-1$
+          sourceFiles.add(new SourceFile((IFile) resource, md, encoding));
+          String typeName = typePath.toString();
+          //              if (!newState.isDuplicateLocator(typeName, typeLocator)) { // adding
+          //                // dependents
+          //                // results
+          //                // in
+          //                // 2
+          //                // duplicate
+          //                // errors
+          //                if (PHPBuilder.DEBUG)
+          //                  System.out.println("Found added source file " + typeName); //$NON-NLS-1$
+          //                addDependentsOf(typePath, true);
+          //              }
+          return;
+        case IResourceDelta.REMOVED:
+          //              char[][] definedTypeNames = newState
+          //                  .getDefinedTypeNamesFor(typeLocator);
+          //              if (definedTypeNames == null) { // defined a single type matching
+          //                // typePath
+          //                removeClassFile(typePath, md.binaryFolder);
+          //                if ((sourceDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
+          //                  // remove problems and tasks for a compilation unit that is
+          //                  // being moved (to another package or renamed)
+          //                  // if the target file is a compilation unit, the new cu will
+          //                  // be recompiled
+          //                  // if the target file is a non-java resource, then markers
+          //                  // are removed
+          //                  // see bug 2857
+          //                  IResource movedFile = javaBuilder.workspaceRoot
+          //                      .getFile(sourceDelta.getMovedToPath());
+          //                  PHPBuilder.removeProblemsAndTasksFor(movedFile);
+          //                }
+          //              } else {
+          if (PHPBuilder.DEBUG)
+            System.out.println("Found removed source file " + typePath.toString()); //$NON-NLS-1$
+          addDependentsOf(typePath, true); // add dependents of the
+          // source file since it may be
+          // involved in a name
+          // collision
+          //                if (definedTypeNames.length > 0) { // skip it if it failed to
+          //                  // successfully define a
+          //                  // type
+          //                  IPath packagePath = typePath.removeLastSegments(1);
+          //                  for (int i = 0, l = definedTypeNames.length; i < l; i++)
+          //                    removeClassFile(packagePath.append(new String(
+          //                        definedTypeNames[i])), md.binaryFolder);
+          //                }
+          //              }
+          //              newState.removeLocator(typeLocator);
           return;
+        case IResourceDelta.CHANGED:
+          if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0)
+            return; // skip it since it really isn't changed
+          if (PHPBuilder.DEBUG)
+            System.out.println("Compile this changed source file " + typeLocator); //$NON-NLS-1$
+          sourceFiles.add(new SourceFile((IFile) resource, md, encoding));
         }
+        return;
+        //                     } else if (ProjectPrefUtil.isClassFileName(resourceName)) {
+        //                             return; // skip class files
+      } else if (md.hasIndependentOutputFolder) {
+        if (javaBuilder.filterExtraResource(resource))
+          return;
+        // copy all other resource deltas to the output folder
+        IPath resourcePath = resource.getFullPath().removeFirstSegments(segmentCount);
+        //          IResource outputFile = md.binaryFolder.getFile(resourcePath);
+        switch (sourceDelta.getKind()) {
+        case IResourceDelta.ADDED:
+          //              if (outputFile.exists()) {
+          //                if (PHPBuilder.DEBUG)
+          //                  System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$
+          //                outputFile.delete(IResource.FORCE, null);
+          //              }
+          if (PHPBuilder.DEBUG)
+            System.out.println("Copying added file " + resourcePath); //$NON-NLS-1$
+            //              createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure
+          // package
+          // exists
+          // in
+          // the
+          // output
+          // folder
+          //              resource.copy(outputFile.getFullPath(), IResource.FORCE, null);
+          //              outputFile.setDerived(true);
+          return;
+        case IResourceDelta.REMOVED:
+          //              if (outputFile.exists()) {
+          //                if (PHPBuilder.DEBUG)
+          //                  System.out.println("Deleting removed file " + resourcePath); //$NON-NLS-1$
+          //                outputFile.delete(IResource.FORCE, null);
+          //              }
+          return;
+        case IResourceDelta.CHANGED:
+          if ((sourceDelta.getFlags() & IResourceDelta.CONTENT) == 0)
+            return; // skip it since it really isn't changed
+            //              if (outputFile.exists()) {
+            //                if (PHPBuilder.DEBUG)
+            //                  System.out.println("Deleting existing file " + resourcePath); //$NON-NLS-1$
+            //                outputFile.delete(IResource.FORCE, null);
+            //              }
+          if (PHPBuilder.DEBUG)
+            System.out.println("Copying changed file " + resourcePath); //$NON-NLS-1$
+        //  createFolder(resourcePath.removeLastSegments(1), md.binaryFolder); // ensure
+        // package
+        // exists
+        // in
+        // the
+        // output
+        // folder
+        //              resource.copy(outputFile.getFullPath(), IResource.FORCE, null);
+        //              outputFile.setDerived(true);
+        }
+        return;
+      }
     }
   }
-  protected void finishedWith(String sourceLocator, CompilationResult result,
-      char[] mainTypeName, ArrayList definedTypeNames,
+
+  protected void finishedWith(String sourceLocator, CompilationResult result, char[] mainTypeName, ArrayList definedTypeNames,
       ArrayList duplicateTypeNames) throws CoreException {
-//    char[][] previousTypeNames = newState.getDefinedTypeNamesFor(sourceLocator);
-//    if (previousTypeNames == null)
-//      previousTypeNames = new char[][]{mainTypeName};
-//    IPath packagePath = null;
-//    next : for (int i = 0, l = previousTypeNames.length; i < l; i++) {
-//      char[] previous = previousTypeNames[i];
-//      for (int j = 0, m = definedTypeNames.size(); j < m; j++)
-//        if (CharOperation.equals(previous, (char[]) definedTypeNames.get(j)))
-//          continue next;
-//      SourceFile sourceFile = (SourceFile) result.getCompilationUnit();
-//      if (packagePath == null) {
-//        int count = sourceFile.sourceLocation.sourceFolder.getFullPath()
-//            .segmentCount();
-//        packagePath = sourceFile.resource.getFullPath().removeFirstSegments(
-//            count).removeLastSegments(1);
-//      }
-//      if (secondaryTypesToRemove == null)
-//        this.secondaryTypesToRemove = new SimpleLookupTable();
-//      ArrayList types = (ArrayList) secondaryTypesToRemove
-//          .get(sourceFile.sourceLocation.binaryFolder);
-//      if (types == null)
-//        types = new ArrayList(definedTypeNames.size());
-//      types.add(packagePath.append(new String(previous)));
-//      secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types);
-//    }
+    //    char[][] previousTypeNames = newState.getDefinedTypeNamesFor(sourceLocator);
+    //    if (previousTypeNames == null)
+    //      previousTypeNames = new char[][]{mainTypeName};
+    //    IPath packagePath = null;
+    //    next : for (int i = 0, l = previousTypeNames.length; i < l; i++) {
+    //      char[] previous = previousTypeNames[i];
+    //      for (int j = 0, m = definedTypeNames.size(); j < m; j++)
+    //        if (CharOperation.equals(previous, (char[]) definedTypeNames.get(j)))
+    //          continue next;
+    //      SourceFile sourceFile = (SourceFile) result.getCompilationUnit();
+    //      if (packagePath == null) {
+    //        int count = sourceFile.sourceLocation.sourceFolder.getFullPath()
+    //            .segmentCount();
+    //        packagePath = sourceFile.resource.getFullPath().removeFirstSegments(
+    //            count).removeLastSegments(1);
+    //      }
+    //      if (secondaryTypesToRemove == null)
+    //        this.secondaryTypesToRemove = new SimpleLookupTable();
+    //      ArrayList types = (ArrayList) secondaryTypesToRemove
+    //          .get(sourceFile.sourceLocation.binaryFolder);
+    //      if (types == null)
+    //        types = new ArrayList(definedTypeNames.size());
+    //      types.add(packagePath.append(new String(previous)));
+    //      secondaryTypesToRemove.put(sourceFile.sourceLocation.binaryFolder, types);
+    //    }
     // super.finishedWith(sourceLocator, result, mainTypeName,
     // definedTypeNames, duplicateTypeNames);
   }
-//  protected void removeClassFile(IPath typePath, IContainer outputFolder)
-//      throws CoreException {
-//    if (typePath.lastSegment().indexOf('$') == -1) { // is not a nested type
-//      newState.removeQualifiedTypeName(typePath.toString());
-//      // add dependents even when the type thinks it does not exist to be on
-//      // the safe side
-//      if (PHPBuilder.DEBUG)
-//        System.out.println("Found removed type " + typePath); //$NON-NLS-1$
-//      addDependentsOf(typePath, true); // when member types are removed, their
-//      // enclosing type is structurally
-//      // changed
-//    }
-//    IFile classFile = outputFolder.getFile(typePath
-//        .addFileExtension(PHPBuilder.CLASS_EXTENSION));
-//    if (classFile.exists()) {
-//      if (PHPBuilder.DEBUG)
-//        System.out.println("Deleting class file of removed type " + typePath); //$NON-NLS-1$
-//      classFile.delete(IResource.FORCE, null);
-//    }
-//  }
-//  protected void removeSecondaryTypes() throws CoreException {
-//    if (secondaryTypesToRemove != null) { // delayed deleting secondary types
-//      // until the end of the compile loop
-//      Object[] keyTable = secondaryTypesToRemove.keyTable;
-//      Object[] valueTable = secondaryTypesToRemove.valueTable;
-//      for (int i = 0, l = keyTable.length; i < l; i++) {
-//        IContainer outputFolder = (IContainer) keyTable[i];
-//        if (outputFolder != null) {
-//          ArrayList paths = (ArrayList) valueTable[i];
-//          for (int j = 0, m = paths.size(); j < m; j++)
-//            removeClassFile((IPath) paths.get(j), outputFolder);
-//        }
-//      }
-//      this.secondaryTypesToRemove = null;
-//      if (previousSourceFiles != null && previousSourceFiles.size() > 1)
-//        this.previousSourceFiles = null; // cannot optimize recompile case when
-//      // a secondary type is deleted
-//    }
-//  }
+
+  //  protected void removeClassFile(IPath typePath, IContainer outputFolder)
+  //      throws CoreException {
+  //    if (typePath.lastSegment().indexOf('$') == -1) { // is not a nested type
+  //      newState.removeQualifiedTypeName(typePath.toString());
+  //      // add dependents even when the type thinks it does not exist to be on
+  //      // the safe side
+  //      if (PHPBuilder.DEBUG)
+  //        System.out.println("Found removed type " + typePath); //$NON-NLS-1$
+  //      addDependentsOf(typePath, true); // when member types are removed, their
+  //      // enclosing type is structurally
+  //      // changed
+  //    }
+  //    IFile classFile = outputFolder.getFile(typePath
+  //        .addFileExtension(PHPBuilder.CLASS_EXTENSION));
+  //    if (classFile.exists()) {
+  //      if (PHPBuilder.DEBUG)
+  //        System.out.println("Deleting class file of removed type " + typePath); //$NON-NLS-1$
+  //      classFile.delete(IResource.FORCE, null);
+  //    }
+  //  }
+  //  protected void removeSecondaryTypes() throws CoreException {
+  //    if (secondaryTypesToRemove != null) { // delayed deleting secondary types
+  //      // until the end of the compile loop
+  //      Object[] keyTable = secondaryTypesToRemove.keyTable;
+  //      Object[] valueTable = secondaryTypesToRemove.valueTable;
+  //      for (int i = 0, l = keyTable.length; i < l; i++) {
+  //        IContainer outputFolder = (IContainer) keyTable[i];
+  //        if (outputFolder != null) {
+  //          ArrayList paths = (ArrayList) valueTable[i];
+  //          for (int j = 0, m = paths.size(); j < m; j++)
+  //            removeClassFile((IPath) paths.get(j), outputFolder);
+  //        }
+  //      }
+  //      this.secondaryTypesToRemove = null;
+  //      if (previousSourceFiles != null && previousSourceFiles.size() > 1)
+  //        this.previousSourceFiles = null; // cannot optimize recompile case when
+  //      // a secondary type is deleted
+  //    }
+  //  }
   protected void resetCollections() {
-    previousSourceFiles = sourceFiles.isEmpty()
-        ? null
-        : (ArrayList) sourceFiles.clone();
+    previousSourceFiles = sourceFiles.isEmpty() ? null : (ArrayList) sourceFiles.clone();
     sourceFiles.clear();
     qualifiedStrings.clear();
     simpleStrings.clear();
     workQueue.clear();
   }
-  protected void updateProblemsFor(SourceFile sourceFile,
-      CompilationResult result) throws CoreException {
+
+  protected void updateProblemsFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
     IMarker[] markers = PHPBuilder.getProblemsFor(sourceFile.resource);
     IProblem[] problems = result.getProblems();
     if (problems == null && markers.length == 0)
       return;
-    
-//  axelcl start insert - calculate line numbers
-    for (int i = 0; i < problems.length; i++) {
-      if (problems[i].getSourceLineNumber() == 1) {
-        problems[i].setSourceLineNumber(ProblemHandler
-            .searchLineNumber(result.lineSeparatorPositions, problems[i].getSourceStart()));
+
+    //  axelcl start insert - calculate line numbers
+    if (problems != null) {
+      for (int i = 0; i < problems.length; i++) {
+        if (problems[i].getSourceLineNumber() == 1) {
+          problems[i].setSourceLineNumber(ProblemHandler.searchLineNumber(result.lineSeparatorPositions, problems[i]
+              .getSourceStart()));
+        }
       }
     }
     //axelcl end insert
-    
+
     notifier.updateProblemCounts(markers, problems);
     PHPBuilder.removeProblemsFor(sourceFile.resource);
     storeProblemsFor(sourceFile, problems);
   }
-  protected void updateTasksFor(SourceFile sourceFile, CompilationResult result)
-      throws CoreException {
+
+  protected void updateTasksFor(SourceFile sourceFile, CompilationResult result) throws CoreException {
     IMarker[] markers = PHPBuilder.getTasksFor(sourceFile.resource);
     IProblem[] tasks = result.getTasks();
     if (tasks == null && markers.length == 0)
@@ -679,6 +676,7 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
     PHPBuilder.removeTasksFor(sourceFile.resource);
     storeTasksFor(sourceFile, tasks);
   }
+
   //protected void writeClassFileBytes(byte[] bytes, IFile file, String
   // qualifiedFileName, boolean isSecondaryType) throws CoreException {
   //   // Before writing out the class file, compare it to the previous file
@@ -741,15 +739,11 @@ public class IncrementalImageBuilder extends AbstractImageBuilder {
   /*
    * Debug helper
    * 
-   * static void dump(IResourceDelta delta) { StringBuffer buffer = new
-   * StringBuffer(); IPath path = delta.getFullPath(); for (int i =
-   * path.segmentCount(); --i > 0;) buffer.append(" "); switch
-   * (delta.getKind()) { case IResourceDelta.ADDED: buffer.append('+'); break;
-   * case IResourceDelta.REMOVED: buffer.append('-'); break; case
-   * IResourceDelta.CHANGED: '); break; case IResourceDelta.NO_CHANGE:
-   * buffer.append('='); break; default: buffer.append('?'); break; }
-   * buffer.append(path); System.out.println(buffer.toString());
-   * IResourceDelta[] children = delta.getAffectedChildren(); for (int i = 0, l =
+   * static void dump(IResourceDelta delta) { StringBuffer buffer = new StringBuffer(); IPath path = delta.getFullPath(); for (int i =
+   * path.segmentCount(); --i > 0;) buffer.append(" "); switch (delta.getKind()) { case IResourceDelta.ADDED: buffer.append('+');
+   * break; case IResourceDelta.REMOVED: buffer.append('-'); break; case IResourceDelta.CHANGED: '); break; case
+   * IResourceDelta.NO_CHANGE: buffer.append('='); break; default: buffer.append('?'); break; } buffer.append(path);
+   * System.out.println(buffer.toString()); IResourceDelta[] children = delta.getAffectedChildren(); for (int i = 0, l =
    * children.length; i < l; i++) dump(children[i]); }
    */
-}
+}
\ No newline at end of file