new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / DeltaProcessor.java
index ac3dd0f..45ffede 100644 (file)
@@ -17,11 +17,14 @@ import java.util.HashSet;
 import java.util.Map;
 
 import net.sourceforge.phpdt.core.ElementChangedEvent;
+import net.sourceforge.phpdt.core.IClasspathEntry;
 import net.sourceforge.phpdt.core.IJavaElement;
+import net.sourceforge.phpdt.core.IJavaModel;
 import net.sourceforge.phpdt.core.IJavaProject;
-import net.sourceforge.phpdt.core.JavaCore;
 import net.sourceforge.phpdt.core.JavaModelException;
 import net.sourceforge.phpdt.internal.ui.util.PHPFileUtil;
+import net.sourceforge.phpeclipse.PHPCore;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
@@ -31,8 +34,10 @@ import org.eclipse.core.resources.IResourceChangeListener;
 import org.eclipse.core.resources.IResourceDelta;
 import org.eclipse.core.resources.IResourceDeltaVisitor;
 import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
 
 
 /**
@@ -224,7 +229,7 @@ public class DeltaProcessor implements IResourceChangeListener {
         * to update.
         */
        void addToProjectsToUpdateWithDependents(IProject project) {
-               this.projectsToUpdate.add(JavaCore.create(project));
+               this.projectsToUpdate.add(PHPCore.create(project));
 //             this.addDependentProjects(project.getFullPath(), this.projectsToUpdate);
        }
        
@@ -1061,75 +1066,75 @@ public class DeltaProcessor implements IResourceChangeListener {
                return file.lastModified() + file.length();
        }
 
-//     public void initializeRoots() {
-//             // remember roots infos as old roots infos
-//             this.oldRoots = this.roots == null ? new HashMap() : this.roots;
-//             this.oldOtherRoots = this.otherRoots == null ? new HashMap() : this.otherRoots;
-//             
-//             // recompute root infos only if necessary
-//             if (!rootsAreStale) return;
-//
-//             this.roots = new HashMap();
-//             this.otherRoots = new HashMap();
-//             this.sourceAttachments = new HashMap();
-//             
-//             IJavaModel model = this.manager.getJavaModel();
-//             IJavaProject[] projects;
-//             try {
-//                     projects = model.getJavaProjects();
-//             } catch (JavaModelException e) {
-//                     // nothing can be done
-//                     return;
-//             }
-//             for (int i = 0, length = projects.length; i < length; i++) {
-//                     IJavaProject project = projects[i];
-//                     IClasspathEntry[] classpath;
-//                     try {
-//                             classpath = project.getResolvedClasspath(true);
-//                     } catch (JavaModelException e) {
-//                             // continue with next project
-//                             continue;
-//                     }
-//                     for (int j= 0, classpathLength = classpath.length; j < classpathLength; j++) {
-//                             IClasspathEntry entry = classpath[j];
-//                             if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
-//                             
-                               // root path
-//                             IPath path = entry.getPath();
-//                             if (this.roots.get(path) == null) {
-//                                     this.roots.put(path, new RootInfo(project, path, ((ClasspathEntry)entry).fullExclusionPatternChars()));
-//                             } else {
-//                                     ArrayList rootList = (ArrayList)this.otherRoots.get(path);
-//                                     if (rootList == null) {
-//                                             rootList = new ArrayList();
-//                                             this.otherRoots.put(path, rootList);
-//                                     }
-//                                     rootList.add(new RootInfo(project, path, ((ClasspathEntry)entry).fullExclusionPatternChars()));
-//                             }
-//                             
-//                             // source attachment path
-//                             if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue;
-//                             QualifiedName qName = new QualifiedName(JavaCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$;
-//                             String propertyString = null;
-//                             try {
-//                                     propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
-//                             } catch (CoreException e) {
-//                                     continue;
-//                             }
-//                             IPath sourceAttachmentPath;
+       public void initializeRoots() {
+               // remember roots infos as old roots infos
+               this.oldRoots = this.roots == null ? new HashMap() : this.roots;
+               this.oldOtherRoots = this.otherRoots == null ? new HashMap() : this.otherRoots;
+               
+               // recompute root infos only if necessary
+               if (!rootsAreStale) return;
+
+               this.roots = new HashMap();
+               this.otherRoots = new HashMap();
+               this.sourceAttachments = new HashMap();
+               
+               IJavaModel model = this.manager.getJavaModel();
+               IJavaProject[] projects;
+               try {
+                       projects = model.getJavaProjects();
+               } catch (JavaModelException e) {
+                       // nothing can be done
+                       return;
+               }
+               for (int i = 0, length = projects.length; i < length; i++) {
+                       IJavaProject project = projects[i];
+                       IClasspathEntry[] classpath;
+                       try {
+                               classpath = project.getResolvedClasspath(true);
+                       } catch (JavaModelException e) {
+                               // continue with next project
+                               continue;
+                       }
+                       for (int j= 0, classpathLength = classpath.length; j < classpathLength; j++) {
+                               IClasspathEntry entry = classpath[j];
+                               if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) continue;
+                               
+//                              root path
+                               IPath path = entry.getPath();
+                               if (this.roots.get(path) == null) {
+                                       this.roots.put(path, new RootInfo(project, path, ((ClasspathEntry)entry).fullExclusionPatternChars()));
+                               } else {
+                                       ArrayList rootList = (ArrayList)this.otherRoots.get(path);
+                                       if (rootList == null) {
+                                               rootList = new ArrayList();
+                                               this.otherRoots.put(path, rootList);
+                                       }
+                                       rootList.add(new RootInfo(project, path, ((ClasspathEntry)entry).fullExclusionPatternChars()));
+                               }
+                               
+                               // source attachment path
+                               if (entry.getEntryKind() != IClasspathEntry.CPE_LIBRARY) continue;
+                               QualifiedName qName = new QualifiedName(PHPCore.PLUGIN_ID, "sourceattachment: " + path.toOSString()); //$NON-NLS-1$;
+                               String propertyString = null;
+                               try {
+                                       propertyString = ResourcesPlugin.getWorkspace().getRoot().getPersistentProperty(qName);
+                               } catch (CoreException e) {
+                                       continue;
+                               }
+                               IPath sourceAttachmentPath;
 //                             if (propertyString != null) {
 //                                     int index= propertyString.lastIndexOf(JarPackageFragmentRoot.ATTACHMENT_PROPERTY_DELIMITER);
 //                                     sourceAttachmentPath = (index < 0) ?  new Path(propertyString) : new Path(propertyString.substring(0, index));
 //                             } else {
-//                                     sourceAttachmentPath = entry.getSourceAttachmentPath();
-//                             }
-//                             if (sourceAttachmentPath != null) {
-//                                     this.sourceAttachments.put(sourceAttachmentPath, path);
+                                       sourceAttachmentPath = entry.getSourceAttachmentPath();
 //                             }
-//                     }
-//             }
-//             this.rootsAreStale = false;
-//     }
+                               if (sourceAttachmentPath != null) {
+                                       this.sourceAttachments.put(sourceAttachmentPath, path);
+                               }
+                       }
+               }
+               this.rootsAreStale = false;
+       }
 
        /*
         * Returns whether a given delta contains some information relevant to the JavaModel,
@@ -1664,7 +1669,7 @@ public class DeltaProcessor implements IResourceChangeListener {
                                case IResourceChangeEvent.PRE_DELETE :
                                        try {
                                                if(resource.getType() == IResource.PROJECT 
-                                                       && ((IProject) resource).hasNature(JavaCore.NATURE_ID)) {
+                                                       && ((IProject) resource).hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
                                                // TODO khartlage temp-del
 //                                                     this.deleting((IProject)resource);
                                                }