X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPBuilder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPBuilder.java deleted file mode 100644 index a4a7be9..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/PHPBuilder.java +++ /dev/null @@ -1,242 +0,0 @@ -package net.sourceforge.phpeclipse.builder; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; -import java.util.Map; - -import net.sourceforge.phpdt.core.IJavaModelMarker; -import net.sourceforge.phpdt.internal.core.JavaProject; -import net.sourceforge.phpdt.internal.core.util.SimpleLookupTable; -import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.phpeditor.PHPParserAction; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; - -/** - * Builder for .php files. - * - * - * @see org.eclipse.core.resources.IncrementalProjectBuilder - * @see org.eclipse.core.resources.IResourceDelta - */ -public class PHPBuilder extends IncrementalProjectBuilder { - IProject currentProject; - JavaProject javaProject; - IWorkspaceRoot workspaceRoot; - // NameEnvironment nameEnvironment; - SimpleLookupTable binaryLocationsPerProject; - // maps a project to its binary resources (output folders, class folders, zip/jar files) - State lastState; - -// BuildNotifier notifier; - - private final static int TOTAL_WORK = 100; - - public static IMarker[] getProblemsFor(IResource resource) { - try { - if (resource != null && resource.exists()) - return resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - } // assume there are no problems - return new IMarker[0]; - } - - public static IMarker[] getTasksFor(IResource resource) { - try { - if (resource != null && resource.exists()) - return resource.findMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - } // assume there are no tasks - return new IMarker[0]; - } - - // public static void finishedBuilding(IResourceChangeEvent event) { - // BuildNotifier.resetProblemCounters(); - // } - - public static void removeProblemsFor(IResource resource) { - try { - if (resource != null && resource.exists()) - resource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - } // assume there were no problems - } - - public static void removeTasksFor(IResource resource) { - try { - if (resource != null && resource.exists()) - resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE); - } catch (CoreException e) { - } // assume there were no problems - } - - public static void removeProblemsAndTasksFor(IResource resource) { - try { - if (resource != null && resource.exists()) { - resource.deleteMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE); - resource.deleteMarkers(IJavaModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE); - } - } catch (CoreException e) { - } // assume there were no problems - } - public static State readState(IProject project, DataInputStream in) throws IOException { - return State.read(project, in); - } - - public static void writeState(Object state, DataOutputStream out) throws IOException { - ((State) state).write(out); - } - - /** - * Constructor - */ - public PHPBuilder() { - } - - /** - * - */ - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { - monitor.beginTask("Parsing files", TOTAL_WORK); - this.currentProject = getProject(); - if (currentProject == null || !currentProject.isAccessible()) - return new IProject[0]; - - if (kind == IncrementalProjectBuilder.FULL_BUILD) { - IResourceDelta delta = getDelta(getProject()); - - processFull(getProject(), monitor); - - } else { // INCREMENTAL_BUILD or AUTO_BUILD - - IResourceDelta delta = getDelta(getProject()); - if (delta != null) { - delta.accept(new ParserVisitor(getProject(), monitor)); - } - - } - monitor.done(); - return null; - } - - /** - * Performs a FULL_BUILD by visiting all nodes in the resource - * tree under the specified project. - * - * @param iProject - */ - public void processFull(final IProject iProject, final IProgressMonitor monitor) { - final IdentifierIndexManager indexManager = PHPeclipsePlugin.getDefault().getIndexManager(iProject); - // Create resource visitor logic - IResourceVisitor myVisitor = new IResourceVisitor() { - public boolean visit(IResource resource) throws CoreException { - if (resource.getType() == IResource.FILE) { - if (monitor.isCanceled()) { - throw new OperationCanceledException(); - } - if ((resource.getFileExtension() != null) && PHPFileUtil.isPHPFile((IFile) resource)) { - monitor.worked(1); - monitor.subTask("Parsing: " + resource.getFullPath()); - // check for parsing errors - PHPParserAction.parseFile((IFile) resource); - // update indexfile for the project: - JavaProject nature = (JavaProject) iProject.getNature(PHPeclipsePlugin.PHP_NATURE_ID); - indexManager.addFile((IFile) resource); - } - } - - return true; - } - }; - - // Process the project using the visitor just created - try { - - // if (iProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { - // thePHPProject = new PHPProject(); - // thePHPProject.setProject(iProject); - // } - indexManager.initialize(); - iProject.accept(myVisitor); - indexManager.writeFile(); - } catch (CoreException e) { - e.printStackTrace(); - } - - } - - /** - * Sets initialization data for this builder. - *

- * This method is part of the IExecutableExtension - * interface. - *

- *

- * Subclasses are free to extend this method to pick up - * initialization parameters from the plug-in plug-in manifest - * (plugin.xml) file, - * but should be sure to invoke this method on their superclass. - *

- * For example, the following method looks for a boolean-valued - * parameter named "trace": - *

-   *     public void setInitializationData(IConfigurationElement cfig, 
-   *             String propertyName, Object data) 
-   * 		        throws CoreException {
-   *         super.setInitializationData(cfig, propertyName, data);
-   *         if (data instanceof Hashtable) { 
-   *             Hashtable args = (Hashtable) data; 
-   *             String traceValue = (String) args.get("trace"); 
-   *             TRACING = (traceValue!=null && traceValue.equals("true"));
-   *         }
-   *     }
-   * 
- *

- */ - public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { - super.setInitializationData(config, propertyName, data); - - } - - /** - * Informs this builder that it is being started by the build management - * infrastructure. By the time this method is run, the builder's project - * is available and setInitializationData has been called. - * The default implementation should be called by all overriding methods. - * - * @see #setInitializationData - */ - protected void startupOnInitialize() { - // traceMsg("Parse Builder Initialize - startupOnInitialize()"); - } - - /** - * Write trace statements. - * System.out.println with prefix tagging used for simplicity. - */ - // private void traceMsg(String msg) { - // if (PHPeclipsePlugin.DEBUG | traceEnabled) - // System.out.println( - // buildMode - // + "<" - // + getProject() - // + "> " - // + "\t\t\t" - // + buildMark - // + msg); - // } - -} \ No newline at end of file