Parser detects wrong include files now
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / JavaProject.java
index 21777c4..f803855 100644 (file)
@@ -54,15 +54,6 @@ import net.sourceforge.phpdt.internal.corext.Assert;
 import net.sourceforge.phpeclipse.LoadPathEntry;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
 import org.eclipse.core.resources.ICommand;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IFolder;
@@ -80,9 +71,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Preferences;
 import org.eclipse.core.runtime.QualifiedName;
-import net.sourceforge.phpdt.internal.core.ClasspathEntry;
-import net.sourceforge.phpdt.internal.core.XMLWriter;
-import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -591,7 +579,7 @@ public class JavaProject
                                                }
                                        } else {
                                                // external target - only JARs allowed
-//                                             if (((java.io.File)target).isFile() && (Util.isArchiveFileName(entryPath.lastSegment()))) {
+//                                             if (((java.io.File)target).isFile() && (ProjectPrefUtil.isArchiveFileName(entryPath.lastSegment()))) {
 //                                                     accumulatedRoots.add(
 //                                                             new JarPackageFragmentRoot(entryPath, this));
 //                                                     rootIDs.add(rootID);
@@ -712,7 +700,7 @@ public class JavaProject
                        switch (innerMostEntry.getEntryKind()) {
                                case IClasspathEntry.CPE_SOURCE:
                                        // .class files are not visible in source folders 
-                                       return true; //!net.sourceforge.phpdt.internal.compiler.util.Util.isClassFileName(fullPath.lastSegment());
+                                       return true; //!net.sourceforge.phpdt.internal.compiler.util.ProjectPrefUtil.isClassFileName(fullPath.lastSegment());
                                case IClasspathEntry.CPE_LIBRARY:
                                        // .java files are not visible in library folders
                                        return !net.sourceforge.phpdt.internal.compiler.util.Util.isJavaFileName(fullPath.lastSegment());
@@ -915,7 +903,7 @@ public class JavaProject
         * This is the project bin folder
         */
        protected IPath defaultOutputLocation() throws JavaModelException {
-               return getProject().getFullPath().append("bin"); //$NON-NLS-1$
+               return null; //getProject().getFullPath().append("bin"); //$NON-NLS-1$
        }
 
        /**
@@ -1504,7 +1492,7 @@ public class JavaProject
                        default:
                                // a path ending with .jar/.zip is still ambiguous and could still resolve to a source/lib folder 
                                // thus will try to guess based on existing resource
-//                             if (Util.isArchiveFileName(path.lastSegment())) {
+//                             if (ProjectPrefUtil.isArchiveFileName(path.lastSegment())) {
 //                                     IResource resource = getProject().getWorkspace().getRoot().findMember(path); 
 //                                     if (resource != null && resource.getType() == IResource.FOLDER){
 //                                             return getPackageFragmentRoot(resource);
@@ -1533,7 +1521,7 @@ public class JavaProject
 
                switch (resource.getType()) {
                        case IResource.FILE:
-//                             if (Util.isArchiveFileName(resource.getName())) {
+//                             if (ProjectPrefUtil.isArchiveFileName(resource.getName())) {
 //                                     return new JarPackageFragmentRoot(resource, this);
 //                             } else {
                                        return null;
@@ -1657,7 +1645,19 @@ public class JavaProject
 
                return project;
        }
-       
+       /**
+        * Sets the underlying kernel project of this Java project,
+        * and fills in its parent and name.
+        * Called by IProject.getNature().
+        *
+        * @see IProjectNature#setProject(IProject)
+        */
+       public void setProject(IProject project) {
+
+               this.project = project;
+               this.parent = JavaModelManager.getJavaModelManager().getJavaModel();
+               this.name = project.getName();
+       }
        protected IProject getProject(String name) {
                return PHPeclipsePlugin.getWorkspace().getRoot().getProject(name);
        }
@@ -2075,7 +2075,9 @@ public class JavaProject
                return this.isOnClasspath(path);
        }
 
-
+       private IPath getPluginWorkingLocation() {
+               return this.project.getWorkingLocation(JavaCore.PLUGIN_ID);
+       }       
        /*
         * load preferences from a shareable format (VCM-wise)
         */
@@ -2084,7 +2086,7 @@ public class JavaProject
                Preferences preferences = new Preferences();
                
 //             File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile();
-               IPath projectMetaLocation = getProject().getPluginWorkingLocation(JavaCore.getPlugin().getDescriptor());
+               IPath projectMetaLocation = getPluginWorkingLocation();
                if (projectMetaLocation != null) {
                        File prefFile = projectMetaLocation.append(PREF_FILENAME).toFile();
                        if (prefFile.exists()) { // load preferences from file
@@ -2124,7 +2126,7 @@ public class JavaProject
 //             throws JavaModelException {
 //
 //             if (region == null) {
-//                     throw new IllegalArgumentException(Util.bind("hierarchy.nullRegion"));//$NON-NLS-1$
+//                     throw new IllegalArgumentException(ProjectPrefUtil.bind("hierarchy.nullRegion"));//$NON-NLS-1$
 //             }
 //             CreateTypeHierarchyOperation op =
 //                     new CreateTypeHierarchyOperation(null, region, this, true);
@@ -2142,10 +2144,10 @@ public class JavaProject
 //             throws JavaModelException {
 //
 //             if (type == null) {
-//                     throw new IllegalArgumentException(Util.bind("hierarchy.nullFocusType"));//$NON-NLS-1$
+//                     throw new IllegalArgumentException(ProjectPrefUtil.bind("hierarchy.nullFocusType"));//$NON-NLS-1$
 //             }
 //             if (region == null) {
-//                     throw new IllegalArgumentException(Util.bind("hierarchy.nullRegion"));//$NON-NLS-1$
+//                     throw new IllegalArgumentException(ProjectPrefUtil.bind("hierarchy.nullRegion"));//$NON-NLS-1$
 //             }
 //             CreateTypeHierarchyOperation op =
 //                     new CreateTypeHierarchyOperation(type, region, this, true);
@@ -2276,13 +2278,13 @@ public class JavaProject
                }
        }
 
+
        /**
         * Save project custom preferences to shareable file (.jprefs)
         */
        private void savePreferences(Preferences preferences) {
                
-               IProject project = getProject();
-               if (!JavaProject.hasJavaNature(project)) return; // ignore
+               if (!JavaProject.hasJavaNature(this.project)) return; // ignore
                
                if (preferences == null || (!preferences.needsSaving() && preferences.propertyNames().length != 0)) {
                        // nothing to save
@@ -2292,8 +2294,8 @@ public class JavaProject
                // preferences need to be saved
                // the preferences file is located in the plug-in's state area
                // at a well-known name (.jprefs)
-//             File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile();
-               File prefFile = project.getPluginWorkingLocation(JavaCore.getPlugin().getDescriptor()).append(PREF_FILENAME).toFile();
+//             File prefFile = this.project.getLocation().append(PREF_FILENAME).toFile();
+               File prefFile = getPluginWorkingLocation().append(PREF_FILENAME).toFile();
                if (preferences.propertyNames().length == 0) {
                        // there are no preference settings
                        // rather than write an empty file, just delete any existing file
@@ -2320,7 +2322,6 @@ public class JavaProject
                        }
                }
        }
-
        /**
         * Update the Java command in the build spec (replace existing one if present,
         * add one first if none).
@@ -2403,20 +2404,6 @@ public class JavaProject
        }
 
        /**
-        * Sets the underlying kernel project of this Java project,
-        * and fills in its parent and name.
-        * Called by IProject.getNature().
-        *
-        * @see IProjectNature#setProject
-        */
-       public void setProject(IProject project) {
-
-               project = project;
-               parent = JavaModelManager.getJavaModelManager().getJavaModel();
-               name = project.getName();
-       }
-
-       /**
         * @see IJavaProject
         */
        public void setRawClasspath(