Parser detects wrong include files now
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / builder / PHPBuilder.java
index 575bb44..81fd788 100644 (file)
@@ -17,21 +17,21 @@ import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+
 import net.sourceforge.phpdt.core.IClasspathEntry;
 import net.sourceforge.phpdt.core.IJavaModelMarker;
+import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.core.compiler.CharOperation;
 import net.sourceforge.phpdt.internal.core.JavaModel;
 import net.sourceforge.phpdt.internal.core.JavaModelManager;
 import net.sourceforge.phpdt.internal.core.JavaProject;
-import net.sourceforge.phpdt.internal.core.Util;
 import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable;
+import net.sourceforge.phpdt.internal.core.util.Util;
 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
-import net.sourceforge.phpeclipse.PHPCore;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
-import net.sourceforge.phpeclipse.phpeditor.PHPParserAction;
-import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.resources.IProject;
@@ -45,11 +45,12 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.OperationCanceledException;
+
 public class PHPBuilder extends IncrementalProjectBuilder {
   IProject currentProject;
   JavaProject javaProject;
   IWorkspaceRoot workspaceRoot;
-  NameEnvironment nameEnvironment;
+  NameEnvironment nameEnvironment; 
   SimpleLookupTable binaryLocationsPerProject; // maps a project to its binary
   // resources (output folders,
   // class folders, zip/jar files)
@@ -58,7 +59,7 @@ public class PHPBuilder extends IncrementalProjectBuilder {
   char[][] extraResourceFileFilters;
   String[] extraResourceFolderFilters;
   public static final String CLASS_EXTENSION = "class"; //$NON-NLS-1$
-  public static boolean DEBUG = true;
+  public static boolean DEBUG = false;
   /**
    * A list of project names that have been built. This list is used to reset
    * the JavaModel.existingExternalFiles cache when a build cycle begins so
@@ -86,6 +87,22 @@ public class PHPBuilder extends IncrementalProjectBuilder {
   public static void finishedBuilding(IResourceChangeEvent event) {
     BuildNotifier.resetProblemCounters();
   }
+  /**
+   * Hook allowing to initialize some static state before a complete build iteration.
+   * This hook is invoked during PRE_AUTO_BUILD notification
+   */
+  public static void buildStarting() {
+       // do nothing
+       // TODO (philippe) is it still needed?
+  }
+
+  /**
+   * Hook allowing to reset some static state after a complete build iteration.
+   * This hook is invoked during POST_AUTO_BUILD notification
+   */
+  public static void buildFinished() {
+       BuildNotifier.resetProblemCounters();
+  }
   public static void removeProblemsFor(IResource resource) {
     try {
       if (resource != null && resource.exists())
@@ -217,6 +234,8 @@ public class PHPBuilder extends IncrementalProjectBuilder {
       marker.setAttribute(IMarker.MESSAGE, Util.bind("build.missingSourceFile",
           e.missingSourceFile)); //$NON-NLS-1$
       marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+    } catch (Exception e) {
+      e.printStackTrace();
     } finally {
       if (!ok)
         // If the build failed, clear the previously built state, forcing a
@@ -532,7 +551,7 @@ public class PHPBuilder extends IncrementalProjectBuilder {
     return false;
   }
   private void initializeBuilder() throws CoreException {
-    this.javaProject = (JavaProject) PHPCore.create(currentProject);
+    this.javaProject = (JavaProject) JavaCore.create(currentProject);
     this.workspaceRoot = currentProject.getWorkspace().getRoot();
     // Flush the existing external files cache if this is the beginning of a
     // build cycle
@@ -546,7 +565,7 @@ public class PHPBuilder extends IncrementalProjectBuilder {
     this.nameEnvironment = new NameEnvironment(workspaceRoot, javaProject,
         binaryLocationsPerProject);
     String filterSequence = javaProject.getOption(
-        PHPCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true);
+        JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER, true);
     char[][] filters = filterSequence != null && filterSequence.length() > 0
         ? CharOperation.splitAndTrimOn(',', filterSequence.toCharArray())
         : null;
@@ -591,8 +610,8 @@ public class PHPBuilder extends IncrementalProjectBuilder {
     return false;
   }
   private boolean isWorthBuilding() throws CoreException {
-    boolean abortBuilds = PHPCore.ABORT.equals(javaProject.getOption(
-        PHPCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true));
+    boolean abortBuilds = JavaCore.ABORT.equals(javaProject.getOption(
+        JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH, true));
     if (!abortBuilds)
       return true;
     // Abort build only if there are classpath errors
@@ -609,7 +628,7 @@ public class PHPBuilder extends IncrementalProjectBuilder {
     //      IMarker marker =
     // currentProject.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
     //      marker.setAttribute(IMarker.MESSAGE,
-    // Util.bind("build.abortDueToClasspathProblems")); //$NON-NLS-1$
+    // ProjectPrefUtil.bind("build.abortDueToClasspathProblems")); //$NON-NLS-1$
     //      marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
     //      return false;
     //    }
@@ -622,10 +641,10 @@ public class PHPBuilder extends IncrementalProjectBuilder {
       if (getLastState(p) == null) {
         // The prereq project has no build state: if this prereq project has a
         // 'warning' cycle marker then allow build (see bug id 23357)
-        JavaProject prereq = (JavaProject) PHPCore.create(p);
+        JavaProject prereq = (JavaProject) JavaCore.create(p);
         if (prereq.hasCycleMarker()
-            && PHPCore.WARNING.equals(javaProject.getOption(
-                PHPCore.CORE_CIRCULAR_CLASSPATH, true)))
+            && JavaCore.WARNING.equals(javaProject.getOption(
+                JavaCore.CORE_CIRCULAR_CLASSPATH, true)))
           continue;
         if (DEBUG)
           System.out.println("Aborted build because prereq project "
@@ -686,10 +705,10 @@ public class PHPBuilder extends IncrementalProjectBuilder {
     JavaModelManager.getJavaModelManager().setLastBuiltState(currentProject,
         state);
   }
-  /**
-   * String representation for debugging purposes
-   */
-  public String toString() {
+  /** 
+   * String representation for debugging purposes 
+   */ 
+  public String toString() { 
     return currentProject == null ? "JavaBuilder for unknown project" //$NON-NLS-1$
         : "JavaBuilder for " + currentProject.getName(); //$NON-NLS-1$
   }