import javax.xml.parsers.SAXParserFactory;
import net.sourceforge.phpdt.core.IClasspathEntry;
+import net.sourceforge.phpdt.core.ICompilationUnit;
import net.sourceforge.phpdt.core.IJavaElement;
import net.sourceforge.phpdt.core.IJavaModelMarker;
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.JavaCore;
import net.sourceforge.phpdt.core.JavaModelException;
+import net.sourceforge.phpdt.core.WorkingCopyOwner;
import net.sourceforge.phpdt.internal.codeassist.ISearchableNameEnvironment;
import net.sourceforge.phpdt.internal.compiler.util.ObjectVector;
+import net.sourceforge.phpdt.internal.core.util.Util;
import net.sourceforge.phpdt.internal.corext.Assert;
import net.sourceforge.phpeclipse.LoadPathEntry;
-import net.sourceforge.phpeclipse.PHPCore;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import org.apache.xerces.dom.DocumentImpl;
-import org.apache.xml.serialize.Method;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.Serializer;
-import org.apache.xml.serialize.SerializerFactory;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.core.runtime.QualifiedName;
-import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
* The platform project this <code>IJavaProject</code> is based on
*/
- protected IProject fProject;
+ protected IProject project;
protected List fLoadPathEntries;
protected boolean fScratched;
/**
* Constructor needed for <code>IProject.getNature()</code> and <code>IProject.addNature()</code>.
*
- * @see #setProject
+ * @see #setProject(IProject)
*/
public JavaProject() {
- super(JAVA_PROJECT, null, null);
+ super(null, null);
}
- public JavaProject(IProject project, IJavaElement parent) {
- super(JAVA_PROJECT, parent, project.getName());
- fProject = project;
+ public JavaProject(IProject project, JavaElement parent) {
+ super(parent, project.getName());
+ this.project = project;
}
public void addLoadPathEntry(IProject anotherPHPProject) {
fScratched = true;
public void configure() throws CoreException {
// get project description and then the associated build commands
- IProjectDescription desc = fProject.getDescription();
+ IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
// determine if builder already associated
System.arraycopy(commands, 0, newCommands, 1, commands.length);
newCommands[0] = command;
desc.setBuildSpec(newCommands);
- fProject.setDescription(desc, null);
+ project.setDescription(desc, null);
}
}
}
protected IFile getLoadPathEntriesFile() {
- return fProject.getFile(".loadpath");
+ return project.getFile(".loadpath");
}
protected String getLoadPathXML() {
setJavaCommand(description, command);
}
}
+ /**
+ * @see Openable
+ */
+ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException {
+
+ // check whether the java project can be opened
+ if (!underlyingResource.isAccessible()) {
+ throw newNotPresentException();
+ }
+
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot wRoot = workspace.getRoot();
+ // cannot refresh cp markers on opening (emulate cp check on startup) since can create deadlocks (see bug 37274)
+// IClasspathEntry[] resolvedClasspath = getResolvedClasspath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+
+// // compute the pkg fragment roots
+// info.setChildren(computePackageFragmentRoots(resolvedClasspath, false));
+//
+// // remember the timestamps of external libraries the first time they are looked up
+// for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
+// IClasspathEntry entry = resolvedClasspath[i];
+// if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+// IPath path = entry.getPath();
+// Object target = JavaModel.getTarget(wRoot, path, true);
+// if (target instanceof java.io.File) {
+// Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaState.externalTimeStamps;
+// if (externalTimeStamps.get(path) == null) {
+// long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target);
+// externalTimeStamps.put(path, new Long(timestamp));
+// }
+// }
+// }
+// }
- protected void closing(Object info) throws JavaModelException {
+ return true;
+ }
+ protected void closing(Object info) {
- // forget source attachment recommendations
- IPackageFragmentRoot[] roots = this.getPackageFragmentRoots();
-// for (int i = 0; i < roots.length; i++) {
-// if (roots[i] instanceof JarPackageFragmentRoot){
-// ((JarPackageFragmentRoot) roots[i]).setSourceAttachmentProperty(null);
+// // forget source attachment recommendations
+// Object[] children = ((JavaElementInfo)info).children;
+// for (int i = 0, length = children.length; i < length; i++) {
+// Object child = children[i];
+// if (child instanceof JarPackageFragmentRoot){
+// ((JarPackageFragmentRoot)child).setSourceAttachmentProperty(null);
// }
// }
super.closing(info);
}
+// protected void closing(Object info) throws JavaModelException {
+//
+// // forget source attachment recommendations
+// IPackageFragmentRoot[] roots = this.getPackageFragmentRoots();
+//// for (int i = 0; i < roots.length; i++) {
+//// if (roots[i] instanceof JarPackageFragmentRoot){
+//// ((JarPackageFragmentRoot) roots[i]).setSourceAttachmentProperty(null);
+//// }
+//// }
+//
+// super.closing(info);
+// }
if (member != null && member.getType() == IResource.PROJECT){ // double check if bound to project (23977)
IProject projRsc = (IProject) member;
if (JavaProject.hasJavaNature(projRsc)) {
- JavaProject project = (JavaProject) PHPCore.create(projRsc);
+ JavaProject project = (JavaProject) JavaCore.create(projRsc);
project.computeExpandedClasspath(
initialProject,
ignoreUnresolvedVariable,
}
} 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);
IProject requiredProjectRsc = (IProject) member;
if (JavaProject.hasJavaNature(requiredProjectRsc)){ // special builder binary output
rootIDs.add(rootID);
- JavaProject requiredProject = (JavaProject)PHPCore.create(requiredProjectRsc);
+ JavaProject requiredProject = (JavaProject)JavaCore.create(requiredProjectRsc);
requiredProject.computePackageFragmentRoots(
requiredProject.getResolvedClasspath(true),
accumulatedRoots,
switch (innerMostEntry.getEntryKind()) {
case IClasspathEntry.CPE_SOURCE:
// .class files are not visible in source folders
- return true; //!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 !Util.isJavaFileName(fullPath.lastSegment());
+ return !net.sourceforge.phpdt.internal.compiler.util.Util.isJavaFileName(fullPath.lastSegment());
}
}
if (innerMostOutput != null) {
case IJavaModelStatusConstants.CLASSPATH_CYCLE :
isCycleProblem = true;
- if (PHPCore.ERROR.equals(getOption(PHPCore.CORE_CIRCULAR_CLASSPATH, true))) {
+ if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) {
severity = IMarker.SEVERITY_ERROR;
} else {
severity = IMarker.SEVERITY_WARNING;
default:
IPath path = status.getPath();
if (path != null) arguments = new String[] { path.toString() };
- if (PHPCore.ERROR.equals(getOption(PHPCore.CORE_INCOMPLETE_CLASSPATH, true))) {
+ if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true))) {
severity = IMarker.SEVERITY_ERROR;
} else {
severity = IMarker.SEVERITY_WARNING;
/**
* Returns a new element info for this element.
*/
- protected OpenableElementInfo createElementInfo() {
-
+ protected Object createElementInfo() {
return new JavaProjectElementInfo();
}
+
+
+ /*
+ * Returns a new search name environment for this project. This name environment first looks in the given working copies.
+ */
+// public ISearchableNameEnvironment newSearchableNameEnvironment(ICompilationUnit[] workingCopies) throws JavaModelException {
+// return new SearchableEnvironment(this, workingCopies);
+// }
+ /*
+ * Returns a new search name environment for this project. This name environment first looks in the working copies
+ * of the given owner.
+ */
+ public ISearchableNameEnvironment newSearchableNameEnvironment(WorkingCopyOwner owner) throws JavaModelException {
+ return new SearchableEnvironment(this, owner);
+ }
/**
* Reads and decode an XML classpath string
*/
protected IClasspathEntry[] defaultClasspath() throws JavaModelException {
return new IClasspathEntry[] {
- PHPCore.newSourceEntry(getProject().getFullPath())};
+ JavaCore.newSourceEntry(getProject().getFullPath())};
}
/**
* 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$
}
/**
* Returns the XML String encoding of the class path.
*/
- protected String encodeClasspath(IClasspathEntry[] classpath, IPath outputLocation, boolean useLineSeparator) throws JavaModelException {
-
- Document document = new DocumentImpl();
- Element cpElement = document.createElement("classpath"); //$NON-NLS-1$
- document.appendChild(cpElement);
-
- for (int i = 0; i < classpath.length; ++i) {
- cpElement.appendChild(((ClasspathEntry)classpath[i]).elementEncode(document, getProject().getFullPath()));
- }
-
- if (outputLocation != null) {
- outputLocation = outputLocation.removeFirstSegments(1);
- outputLocation = outputLocation.makeRelative();
- Element oElement = document.createElement("classpathentry"); //$NON-NLS-1$
- oElement.setAttribute("kind", ClasspathEntry.kindToString(ClasspathEntry.K_OUTPUT)); //$NON-NLS-1$
- oElement.setAttribute("path", outputLocation.toString()); //$NON-NLS-1$
- cpElement.appendChild(oElement);
- }
-
- // produce a String output
+ protected String encodeClasspath(IClasspathEntry[] classpath, IPath outputLocation, boolean indent) throws JavaModelException {
try {
ByteArrayOutputStream s = new ByteArrayOutputStream();
- OutputFormat format = new OutputFormat();
- if (useLineSeparator) {
- format.setIndenting(true);
- format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
- } else {
- format.setPreserveSpace(true);
- }
- Serializer serializer =
- SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
- new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$
- format);
- serializer.asDOMSerializer().serialize(document);
- return s.toString("UTF8"); //$NON-NLS-1$
+ OutputStreamWriter writer = new OutputStreamWriter(s, "UTF8"); //$NON-NLS-1$
+ XMLWriter xmlWriter = new XMLWriter(writer);
+
+ xmlWriter.startTag("classpath", indent); //$NON-NLS-1$
+ for (int i = 0; i < classpath.length; ++i) {
+ ((ClasspathEntry)classpath[i]).elementEncode(xmlWriter, this.project.getFullPath(), indent, true);
+ }
+
+ if (outputLocation != null) {
+ outputLocation = outputLocation.removeFirstSegments(1);
+ outputLocation = outputLocation.makeRelative();
+ HashMap parameters = new HashMap();
+ parameters.put("kind", ClasspathEntry.kindToString(ClasspathEntry.K_OUTPUT));//$NON-NLS-1$
+ parameters.put("path", String.valueOf(outputLocation));//$NON-NLS-1$
+ xmlWriter.printTag("classpathentry", parameters, indent, true, true);//$NON-NLS-1$
+ }
+
+ xmlWriter.endTag("classpath", indent);//$NON-NLS-1$
+ writer.flush();
+ writer.close();
+ return s.toString("UTF8");//$NON-NLS-1$
} catch (IOException e) {
throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
}
}
+ /**
+ * Returns the XML String encoding of the class path.
+ */
+// protected String encodeClasspath(IClasspathEntry[] classpath, IPath outputLocation, boolean useLineSeparator) throws JavaModelException {
+//
+// Document document = new DocumentImpl();
+// Element cpElement = document.createElement("classpath"); //$NON-NLS-1$
+// document.appendChild(cpElement);
+//
+// for (int i = 0; i < classpath.length; ++i) {
+// cpElement.appendChild(((ClasspathEntry)classpath[i]).elementEncode(document, getProject().getFullPath()));
+// }
+//
+// if (outputLocation != null) {
+// outputLocation = outputLocation.removeFirstSegments(1);
+// outputLocation = outputLocation.makeRelative();
+// Element oElement = document.createElement("classpathentry"); //$NON-NLS-1$
+// oElement.setAttribute("kind", ClasspathEntry.kindToString(ClasspathEntry.K_OUTPUT)); //$NON-NLS-1$
+// oElement.setAttribute("path", outputLocation.toString()); //$NON-NLS-1$
+// cpElement.appendChild(oElement);
+// }
+//
+// // produce a String output
+// try {
+// ByteArrayOutputStream s = new ByteArrayOutputStream();
+// OutputFormat format = new OutputFormat();
+// if (useLineSeparator) {
+// format.setIndenting(true);
+// format.setLineSeparator(System.getProperty("line.separator")); //$NON-NLS-1$
+// } else {
+// format.setPreserveSpace(true);
+// }
+// Serializer serializer =
+// SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(
+// new OutputStreamWriter(s, "UTF8"), //$NON-NLS-1$
+// format);
+// serializer.asDOMSerializer().serialize(document);
+// return s.toString("UTF8"); //$NON-NLS-1$
+// } catch (IOException e) {
+// throw new JavaModelException(e, IJavaModelStatusConstants.IO_EXCEPTION);
+// }
+// }
/**
* Returns true if this handle represents the same Java project
JavaProject other = (JavaProject) o;
return getProject().equals(other.getProject())
- && fOccurrenceCount == other.fOccurrenceCount;
+ && occurrenceCount == other.occurrenceCount;
}
public boolean exists() {
- if (!hasJavaNature(fProject)) return false;
+ if (!hasJavaNature(project)) return false;
return super.exists();
}
}
}
- /**
- * @see Openable
- */
- protected boolean generateInfos(
- OpenableElementInfo info,
- IProgressMonitor pm,
- Map newElements,
- IResource underlyingResource) throws JavaModelException {
-
- boolean validInfo = false;
- try {
- if (getProject().isOpen()) {
- // put the info now, because computing the roots requires it
- JavaModelManager.getJavaModelManager().putInfo(this, info);
-
- // compute the pkg fragment roots
- updatePackageFragmentRoots();
-
- // remember the timestamps of external libraries the first time they are looked up
- IClasspathEntry[] resolvedClasspath = getResolvedClasspath(true/*ignore unresolved variable*/);
- for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
- IClasspathEntry entry = resolvedClasspath[i];
- if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
- IPath path = entry.getPath();
- Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
- if (target instanceof java.io.File) {
- Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaProcessor.externalTimeStamps;
- if (externalTimeStamps.get(path) == null) {
- long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target);
- externalTimeStamps.put(path, new Long(timestamp));
- }
- }
- }
- }
-
- // only valid if reaches here
- validInfo = true;
- }
- } finally {
- if (!validInfo)
- JavaModelManager.getJavaModelManager().removeInfo(this);
- }
- return validInfo;
- }
+// /**
+// * @see Openable
+// */
+// protected boolean generateInfos(
+// OpenableElementInfo info,
+// IProgressMonitor pm,
+// Map newElements,
+// IResource underlyingResource) throws JavaModelException {
+//
+// boolean validInfo = false;
+// try {
+// if (getProject().isOpen()) {
+// // put the info now, because computing the roots requires it
+// JavaModelManager.getJavaModelManager().putInfo(this, info);
+//
+// // compute the pkg fragment roots
+// updatePackageFragmentRoots();
+//
+// // remember the timestamps of external libraries the first time they are looked up
+// IClasspathEntry[] resolvedClasspath = getResolvedClasspath(true/*ignore unresolved variable*/);
+// for (int i = 0, length = resolvedClasspath.length; i < length; i++) {
+// IClasspathEntry entry = resolvedClasspath[i];
+// if (entry.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+// IPath path = entry.getPath();
+// Object target = JavaModel.getTarget(ResourcesPlugin.getWorkspace().getRoot(), path, true);
+// if (target instanceof java.io.File) {
+// Map externalTimeStamps = JavaModelManager.getJavaModelManager().deltaProcessor.externalTimeStamps;
+// if (externalTimeStamps.get(path) == null) {
+// long timestamp = DeltaProcessor.getTimeStamp((java.io.File)target);
+// externalTimeStamps.put(path, new Long(timestamp));
+// }
+// }
+// }
+// }
+//
+// // only valid if reaches here
+// validInfo = true;
+// }
+// } finally {
+// if (!validInfo)
+// JavaModelManager.getJavaModelManager().removeInfo(this);
+// }
+// return validInfo;
+// }
/**
* @see IJavaProject
}
return null;
}
-
+ /**
+ * @see IJavaElement
+ */
+ public int getElementType() {
+ return JAVA_PROJECT;
+ }
/**
* This is a helper method returning the expanded classpath for the project, as a list of classpath entries,
* where all classpath variable entries have been resolved and substituted with their final target entries.
return nameLookup;
}
}
+ /*
+ * Returns a new name lookup. This name lookup first looks in the given working copies.
+ */
+ public NameLookup newNameLookup(ICompilationUnit[] workingCopies) throws JavaModelException {
+
+ JavaProjectElementInfo info = getJavaProjectElementInfo();
+ // lock on the project info to avoid race condition while computing the pkg fragment roots and package fragment caches
+// synchronized(info){
+// return new NameLookup(info.getAllPackageFragmentRoots(this), info.getAllPackageFragments(this), workingCopies);
+// }
+ return null;
+ }
+
+ /*
+ * Returns a new name lookup. This name lookup first looks in the working copies of the given owner.
+ */
+ public NameLookup newNameLookup(WorkingCopyOwner owner) throws JavaModelException {
+
+ JavaModelManager manager = JavaModelManager.getJavaModelManager();
+ ICompilationUnit[] workingCopies = owner == null ? null : manager.getWorkingCopies(owner, true/*add primary WCs*/);
+ return newNameLookup(workingCopies);
+ }
//
// /**
// * Returns an array of non-java resources contained in the receiver.
Preferences preferences = getPreferences();
if (preferences == null || preferences.isDefault(optionName)) {
- return inheritJavaCoreOptions ? PHPCore.getOption(optionName) : null;
+ return inheritJavaCoreOptions ? JavaCore.getOption(optionName) : null;
}
return preferences.getString(optionName).trim();
}
public Map getOptions(boolean inheritJavaCoreOptions) {
// initialize to the defaults from JavaCore options pool
- Map options = inheritJavaCoreOptions ? PHPCore.getOptions() : new Hashtable(5);
+ Map options = inheritJavaCoreOptions ? JavaCore.getOptions() : new Hashtable(5);
Preferences preferences = getPreferences();
if (preferences == null) return options; // cannot do better (non-Java project)
*/
public IPath getOutputLocation() throws JavaModelException {
- JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project);
IPath outputLocation = perProjectInfo.outputLocation;
if (outputLocation != null) return outputLocation;
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);
switch (resource.getType()) {
case IResource.FILE:
-// if (Util.isArchiveFileName(resource.getName())) {
+// if (ProjectPrefUtil.isArchiveFileName(resource.getName())) {
// return new JarPackageFragmentRoot(resource, this);
// } else {
return null;
*/
public IProject getProject() {
- return fProject;
+ 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);
}
*/
public IClasspathEntry[] getRawClasspath() throws JavaModelException {
- JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
+ JavaModelManager.PerProjectInfo perProjectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project);
IClasspathEntry[] classpath = perProjectInfo.classpath;
if (classpath != null) return classpath;
classpath = this.readClasspathFile(false/*don't create markers*/, true/*log problems*/);
throws JavaModelException {
JavaModelManager manager = JavaModelManager.getJavaModelManager();
- JavaModelManager.PerProjectInfo perProjectInfo = manager.getPerProjectInfoCheckExistence(fProject);
+ JavaModelManager.PerProjectInfo perProjectInfo = manager.getPerProjectInfoCheckExistence(project);
// reuse cache if not needing to refresh markers or checking bound variables
if (ignoreUnresolvedEntry && !generateMarkerOnError && perProjectInfo != null){
if (perProjectInfo != null){
if (perProjectInfo.classpath == null // .classpath file could not be read
&& generateMarkerOnError
- && JavaProject.hasJavaNature(fProject)) {
+ && JavaProject.hasJavaNature(project)) {
this.createClasspathProblemMarker(new JavaModelStatus(
IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT,
Util.bind("classpath.cannotReadClasspathFile", this.getElementName()))); //$NON-NLS-1$
case IClasspathEntry.CPE_VARIABLE :
- IClasspathEntry resolvedEntry = PHPCore.getResolvedClasspathEntry(rawEntry);
+ IClasspathEntry resolvedEntry = JavaCore.getResolvedClasspathEntry(rawEntry);
if (resolvedEntry == null) {
if (!ignoreUnresolvedEntry) throw new JavaModelException(status);
} else {
}
public int hashCode() {
- return fProject.hashCode();
+ return project.hashCode();
}
/**
return this.isOnClasspath(path);
}
-
+ private IPath getPluginWorkingLocation() {
+ return this.project.getWorkingLocation(JavaCore.PLUGIN_ID);
+ }
/*
* load preferences from a shareable format (VCM-wise)
*/
Preferences preferences = new Preferences();
// File prefFile = getProject().getLocation().append(PREF_FILENAME).toFile();
- IPath projectMetaLocation = getProject().getPluginWorkingLocation(PHPCore.getPlugin().getDescriptor());
+ IPath projectMetaLocation = getPluginWorkingLocation();
if (projectMetaLocation != null) {
File prefFile = projectMetaLocation.append(PREF_FILENAME).toFile();
if (prefFile.exists()) { // load preferences from file
// 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);
// 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);
// return op.getResult();
// }
- /**
- * Open project if resource isn't closed
- */
- protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
-
- if (!this.fProject.isOpen()) {
- throw newNotPresentException();
- } else {
- super.openWhenClosed(pm);
- }
- }
+// /**
+// * Open project if resource isn't closed
+// */
+// protected void openWhenClosed(IProgressMonitor pm) throws JavaModelException {
+//
+// if (!this.fProject.isOpen()) {
+// throw newNotPresentException();
+// } else {
+// super.openWhenClosed(pm);
+// }
+// }
public String[] projectPrerequisites(IClasspathEntry[] entries)
throws JavaModelException {
}
}
+
/**
* 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
// 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(PHPCore.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
}
}
}
-
/**
* Update the Java command in the build spec (replace existing one if present,
* add one first if none).
}
/**
- * 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) {
-
- fProject = project;
- fParent = JavaModelManager.getJavaModelManager().getJavaModel();
- fName = project.getName();
- }
-
- /**
* @see IJavaProject
*/
public void setRawClasspath(
protected void setRawClasspath0(IClasspathEntry[] rawEntries)
throws JavaModelException {
- JavaModelManager.PerProjectInfo info = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(fProject);
+ JavaModelManager.PerProjectInfo info = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(project);
synchronized (info) {
if (rawEntries != null) {
if (cycleParticipants.contains(project.getPath())){
IMarker cycleMarker = project.getCycleMarker();
- String circularCPOption = project.getOption(PHPCore.CORE_CIRCULAR_CLASSPATH, true);
- int circularCPSeverity = PHPCore.ERROR.equals(circularCPOption) ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING;
+ String circularCPOption = project.getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true);
+ int circularCPSeverity = JavaCore.ERROR.equals(circularCPOption) ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING;
if (cycleMarker != null) {
// update existing cycle marker if needed
try {
if (!traversed.contains(prereqProjectPath)) {
IResource member = workspaceRoot.findMember(prereqProjectPath);
if (member != null && member.getType() == IResource.PROJECT){
- JavaProject project = (JavaProject)PHPCore.create((IProject)member);
+ JavaProject project = (JavaProject)JavaCore.create((IProject)member);
project.updateCycleParticipants(null, prereqChain, cycleParticipants, workspaceRoot, traversed);
}
}