X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java index 513ad3d..ac51e61 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/core/SetClasspathOperation.java @@ -10,12 +10,9 @@ *******************************************************************************/ package net.sourceforge.phpdt.internal.core; -import java.io.File; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; -import java.util.Map; import net.sourceforge.phpdt.core.IClasspathEntry; import net.sourceforge.phpdt.core.IJavaElement; @@ -23,18 +20,15 @@ import net.sourceforge.phpdt.core.IJavaElementDelta; import net.sourceforge.phpdt.core.IJavaModel; import net.sourceforge.phpdt.core.IJavaModelStatus; import net.sourceforge.phpdt.core.IJavaProject; -import net.sourceforge.phpdt.core.IPackageFragment; import net.sourceforge.phpdt.core.IPackageFragmentRoot; import net.sourceforge.phpdt.core.JavaModelException; -import net.sourceforge.phpdt.internal.compiler.util.ObjectVector; +import net.sourceforge.phpdt.internal.core.util.Util; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -48,11 +42,13 @@ public class SetClasspathOperation extends JavaModelOperation { IClasspathEntry[] oldResolvedPath, newResolvedPath; IClasspathEntry[] newRawPath; - boolean canChangeResource; + boolean canChangeResources; boolean needCycleCheck; boolean needValidation; boolean needSave; IPath newOutputLocation; + JavaProject project; + boolean identicalRoots; public static final IClasspathEntry[] ReuseClasspath = new IClasspathEntry[0]; public static final IClasspathEntry[] UpdateClasspath = new IClasspathEntry[0]; @@ -63,7 +59,7 @@ public class SetClasspathOperation extends JavaModelOperation { * When executed, this operation sets the classpath of the given project. */ public SetClasspathOperation( - IJavaProject project, + JavaProject project, IClasspathEntry[] oldResolvedPath, IClasspathEntry[] newRawPath, IPath newOutputLocation, @@ -75,9 +71,10 @@ public class SetClasspathOperation extends JavaModelOperation { this.oldResolvedPath = oldResolvedPath; this.newRawPath = newRawPath; this.newOutputLocation = newOutputLocation; - this.canChangeResource = canChangeResource; + this.canChangeResources = canChangeResource; this.needValidation = needValidation; this.needSave = needSave; + this.project = project; } /** @@ -219,7 +216,6 @@ public class SetClasspathOperation extends JavaModelOperation { // } // return fragments; // } - /** * Sets the classpath of the pre-specified project. */ @@ -236,12 +232,11 @@ public class SetClasspathOperation extends JavaModelOperation { JavaModelException originalException = null; try { - JavaProject project = getProject(); if (this.newRawPath == UpdateClasspath) this.newRawPath = project.getRawClasspath(); if (this.newRawPath != ReuseClasspath){ updateClasspath(); -// project.updatePackageFragmentRoots(); - JavaModelManager.getJavaModelManager().deltaProcessor.addForRefresh(project); + project.updatePackageFragmentRoots(); + JavaModelManager.getJavaModelManager().getDeltaProcessor().addForRefresh(project); } } catch(JavaModelException e){ @@ -256,11 +251,23 @@ public class SetClasspathOperation extends JavaModelOperation { } catch(JavaModelException e){ if (originalException != null) throw originalException; throw e; + } finally { + // ensures the project is getting rebuilt if only variable is modified + if (!this.identicalRoots && this.canChangeResources) { + try { + this.project.getProject().touch(this.progressMonitor); + } catch (CoreException e) { + if (JavaModelManager.CP_RESOLVE_VERBOSE){ + Util.verbose("CPContainer INIT - FAILED to touch project: "+ this.project.getElementName(), System.err); //$NON-NLS-1$ + e.printStackTrace(); + } + } + } } } done(); } - + /** * Generates the delta of removed/added/reordered roots. * Use three deltas in case the same root is removed/added/reordered (for @@ -526,12 +533,12 @@ public class SetClasspathOperation extends JavaModelOperation { * otherwise false. Subclasses must override. */ public boolean isReadOnly() { - return !this.canChangeResource; + return !this.canChangeResources; } protected void saveClasspathIfNecessary() throws JavaModelException { - if (!this.canChangeResource || !this.needSave) return; + if (!this.canChangeResources || !this.needSave) return; IClasspathEntry[] classpathForSave; JavaProject project = getProject(); @@ -586,7 +593,7 @@ public class SetClasspathOperation extends JavaModelOperation { // resolve new path (asking for marker creation if problems) if (this.newResolvedPath == null) { - this.newResolvedPath = project.getResolvedClasspath(true, this.canChangeResource); + this.newResolvedPath = project.getResolvedClasspath(true, this.canChangeResources); } // if (this.oldResolvedPath != null) { @@ -628,8 +635,8 @@ public class SetClasspathOperation extends JavaModelOperation { project.setRawClasspath( UpdateClasspath, SetClasspathOperation.ReuseOutputLocation, - this.fMonitor, - this.canChangeResource, + this.progressMonitor, + this.canChangeResources, project.getResolvedClasspath(true), false, // updating only - no validation false); // updating only - no need to save @@ -650,7 +657,7 @@ public class SetClasspathOperation extends JavaModelOperation { protected void updateCycleMarkersIfNecessary(IClasspathEntry[] newResolvedPath) { if (!this.needCycleCheck) return; - if (!this.canChangeResource) return; + if (!this.canChangeResources) return; try { JavaProject project = getProject(); @@ -694,7 +701,7 @@ public class SetClasspathOperation extends JavaModelOperation { // while (iter.hasNext()){ // IPackageFragment frag= (IPackageFragment)iter.next(); // ((IPackageFragmentRoot)frag.getParent()).close(); -// if (!Util.isExcluded(frag)) { +// if (!ProjectPrefUtil.isExcluded(frag)) { // delta.added(frag); // deltaToFire = true; // } @@ -706,7 +713,7 @@ public class SetClasspathOperation extends JavaModelOperation { // while (iter.hasNext()){ // IPackageFragment frag= (IPackageFragment)iter.next(); // ((IPackageFragmentRoot)frag.getParent()).close(); -// if (!Util.isExcluded(frag)) { +// if (!ProjectPrefUtil.isExcluded(frag)) { // delta.removed(frag); // deltaToFire = true; // } @@ -728,7 +735,7 @@ public class SetClasspathOperation extends JavaModelOperation { */ protected void updateProjectReferencesIfNecessary() throws JavaModelException { - if (!this.canChangeResource) return; + if (!this.canChangeResources) return; if (this.newRawPath == ReuseClasspath || this.newRawPath == UpdateClasspath) return; JavaProject jproject = getProject(); @@ -790,7 +797,7 @@ public class SetClasspathOperation extends JavaModelOperation { } description.setReferencedProjects(requiredProjectArray); - project.setDescription(description, this.fMonitor); + project.setDescription(description, this.progressMonitor); } catch(CoreException e){ throw new JavaModelException(e);