*******************************************************************************/
package net.sourceforge.phpdt.internal.core;
+import java.util.HashMap;
+
import net.sourceforge.phpdt.core.IClasspathEntry;
import net.sourceforge.phpdt.core.IJavaProject;
import net.sourceforge.phpdt.core.IPackageFragmentRoot;
+import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.core.compiler.CharOperation;
+import net.sourceforge.phpdt.internal.core.util.Util;
import net.sourceforge.phpdt.internal.corext.Assert;
-import net.sourceforge.phpeclipse.PHPCore;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
switch (kind) {
case IClasspathEntry.CPE_PROJECT :
- return PHPCore.newProjectEntry(path, isExported);
+ return JavaCore.newProjectEntry(path, isExported);
// case IClasspathEntry.CPE_LIBRARY :
// return JavaCore.newLibraryEntry(
// must be an entry in this project or specify another project
String projSegment = path.segment(0);
if (projSegment != null && projSegment.equals(project.getElementName())) { // this project
- return PHPCore.newSourceEntry(path, exclusionPatterns, outputLocation);
+ return JavaCore.newSourceEntry(path, exclusionPatterns, outputLocation);
} else { // another project
- return PHPCore.newProjectEntry(path, isExported);
+ return JavaCore.newProjectEntry(path, isExported);
}
// case IClasspathEntry.CPE_VARIABLE :
// isExported);
case IClasspathEntry.CPE_CONTAINER :
- return PHPCore.newContainerEntry(
+ return JavaCore.newContainerEntry(
path,
isExported);
*/
public IClasspathEntry getResolvedEntry() {
- return PHPCore.getResolvedClasspathEntry(this);
+ return JavaCore.getResolvedClasspathEntry(this);
+ }
+ /**
+ * Returns the XML encoding of the class path.
+ */
+ public void elementEncode(XMLWriter writer, IPath projectPath, boolean indent, boolean newLine) {
+ HashMap parameters = new HashMap();
+
+ parameters.put("kind", ClasspathEntry.kindToString(this.entryKind));//$NON-NLS-1$
+
+ IPath xmlPath = this.path;
+ if (this.entryKind != IClasspathEntry.CPE_VARIABLE && this.entryKind != IClasspathEntry.CPE_CONTAINER) {
+ // translate to project relative from absolute (unless a device path)
+ if (xmlPath.isAbsolute()) {
+ if (projectPath != null && projectPath.isPrefixOf(xmlPath)) {
+ if (xmlPath.segment(0).equals(projectPath.segment(0))) {
+ xmlPath = xmlPath.removeFirstSegments(1);
+ xmlPath = xmlPath.makeRelative();
+ } else {
+ xmlPath = xmlPath.makeAbsolute();
+ }
+ }
+ }
+ }
+ parameters.put("path", String.valueOf(xmlPath));//$NON-NLS-1$
+
+ if (this.sourceAttachmentPath != null) {
+ xmlPath = this.sourceAttachmentPath;
+ // translate to project relative from absolute
+ if (this.entryKind != IClasspathEntry.CPE_VARIABLE && projectPath != null && projectPath.isPrefixOf(xmlPath)) {
+ if (xmlPath.segment(0).equals(projectPath.segment(0))) {
+ xmlPath = xmlPath.removeFirstSegments(1);
+ xmlPath = xmlPath.makeRelative();
+ }
+ }
+ parameters.put("sourcepath", String.valueOf(xmlPath));//$NON-NLS-1$
+ }
+ if (this.sourceAttachmentRootPath != null) {
+ parameters.put("rootpath", String.valueOf(this.sourceAttachmentRootPath));//$NON-NLS-1$
+ }
+ if (this.isExported) {
+ parameters.put("exported", "true");//$NON-NLS-1$//$NON-NLS-2$
+ }
+// if (this.inclusionPatterns != null && this.inclusionPatterns.length > 0) {
+// StringBuffer includeRule = new StringBuffer(10);
+// for (int i = 0, max = this.inclusionPatterns.length; i < max; i++){
+// if (i > 0) includeRule.append('|');
+// includeRule.append(this.inclusionPatterns[i]);
+// }
+// parameters.put("including", String.valueOf(includeRule));//$NON-NLS-1$
+// }
+ if (this.exclusionPatterns != null && this.exclusionPatterns.length > 0) {
+ StringBuffer excludeRule = new StringBuffer(10);
+ for (int i = 0, max = this.exclusionPatterns.length; i < max; i++){
+ if (i > 0) excludeRule.append('|');
+ excludeRule.append(this.exclusionPatterns[i]);
+ }
+ parameters.put("excluding", String.valueOf(excludeRule));//$NON-NLS-1$
+ }
+
+ if (this.specificOutputLocation != null) {
+ IPath outputLocation = this.specificOutputLocation.removeFirstSegments(1);
+ outputLocation = outputLocation.makeRelative();
+ parameters.put("output", String.valueOf(outputLocation));//$NON-NLS-1$
+ }
+
+ writer.printTag("classpathentry", parameters, indent, newLine, true);//$NON-NLS-1$
}
}