/** * Returns a runtime classpath entry that corresponds to the given * classpath entry. The classpath entry may not be of type <code>CPE_SOURCE</code> * or <code>CPE_CONTAINER</code>. * * @param entry a classpath entry * @return runtime classpath entry * @since 2.0 */ private static IRuntimeClasspathEntry newRuntimeClasspathEntry(IClasspathEntry entry) { return new RuntimeClasspathEntry(entry); }
@Override public IPath getExternalAnnotationsPath() { IClasspathEntry entry = getClasspathEntry(); if (null != entry) { String s = findClasspathAttribute(entry.getExtraAttributes(), IClasspathAttribute.EXTERNAL_ANNOTATION_PATH); if (null != s) { return new Path(s); } } return null; }
@Override public void setSourceAttachmentRootPath(IPath path) { if (path != null && path.isEmpty()) { path = null; } updateClasspathEntry(getPath(), getSourceAttachmentPath(), path, getExternalAnnotationsPath()); }
/** * @see IRuntimeClasspathEntry#setSourceAttachmentPath(IPath) */ @Override public void setSourceAttachmentPath(IPath path) { if (path != null && path.isEmpty()) { path = null; } updateClasspathEntry(getPath(), path, getSourceAttachmentRootPath(), getExternalAnnotationsPath()); }
/** * @see IRuntimeClasspathEntry#getSourceAttachmentRootPath() */ @Override public IPath getSourceAttachmentRootPath() { IClasspathEntry entry = getClasspathEntry(); IPath path = entry != null ? getClasspathEntry().getSourceAttachmentRootPath() : null; if (path == null && getSourceAttachmentPath() != null) { return Path.EMPTY; } return path; }
Element node = doc.createElement("runtimeClasspathEntry"); //$NON-NLS-1$ doc.appendChild(node); node.setAttribute("type", (new Integer(getType())).toString()); //$NON-NLS-1$ node.setAttribute("path", (new Integer(getClasspathProperty())).toString()); //$NON-NLS-1$ switch (getType()) { case PROJECT : node.setAttribute("projectName", getPath().lastSegment()); //$NON-NLS-1$ break; case ARCHIVE : IResource res = getResource(); if (res == null) { node.setAttribute("externalArchive", getPath().toString()); //$NON-NLS-1$ } else { node.setAttribute("internalArchive", res.getFullPath().toString()); //$NON-NLS-1$ case VARIABLE : case CONTAINER : node.setAttribute("containerPath", getPath().toString()); //$NON-NLS-1$ break; if (getSourceAttachmentPath() != null) { node.setAttribute("sourceAttachmentPath", getSourceAttachmentPath().toString()); //$NON-NLS-1$ if (getSourceAttachmentRootPath() != null) { node.setAttribute("sourceRootPath", getSourceAttachmentRootPath().toString()); //$NON-NLS-1$ if (getExternalAnnotationsPath() != null) { node.setAttribute("externalAnnotationsPath", getExternalAnnotationsPath().toString()); //$NON-NLS-1$
if (obj instanceof IRuntimeClasspathEntry) { IRuntimeClasspathEntry r = (IRuntimeClasspathEntry)obj; if (getType() == r.getType() && getClasspathProperty() == r.getClasspathProperty()) { if (getType() == IRuntimeClasspathEntry.CONTAINER) { String id = getPath().segment(0); ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(id); IJavaProject javaProject1 = getJavaProject(); IJavaProject javaProject2 = r.getJavaProject(); if (initializer == null || javaProject1 == null || javaProject2 == null) { return getPath().equals(r.getPath()); Object comparisonID1 = initializer.getComparisonID(getPath(), javaProject1); Object comparisonID2 = initializer.getComparisonID(r.getPath(), javaProject2); return comparisonID1.equals(comparisonID2); } else if (getPath() != null && getPath().equals(r.getPath())) { IPath sa1 = getSourceAttachmentPath(); IPath root1 = getSourceAttachmentRootPath(); IPath sa2 = r.getSourceAttachmentPath(); IPath root2 = r.getSourceAttachmentRootPath(); return equal(sa1, sa2) && equal(root1, root2);
setType(Integer.parseInt(root.getAttribute("type"))); //$NON-NLS-1$ } catch (NumberFormatException e) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry_type_2, e); setClasspathProperty(Integer.parseInt(root.getAttribute("path"))); //$NON-NLS-1$ } catch (NumberFormatException e) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry_location_3, e); switch (getType()) { case PROJECT : String name = root.getAttribute("projectName"); //$NON-NLS-1$ if (isEmpty(name)) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry___missing_project_name_4, null); } else { IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); setClasspathEntry(JavaCore.newProjectEntry(proj.getFullPath())); if (isEmpty(path)) { if (isEmpty(path)) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry___missing_archive_path_5, null); } else { setClasspathEntry(createLibraryEntry(sourcePath, rootPath, path)); setClasspathEntry(createLibraryEntry(sourcePath, rootPath, path)); if (isEmpty(var)) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry___missing_variable_name_6, null); } else {
/** * Returns a runtime classpath entry for the given container path with the given * classpath property to be resolved in the context of the given Java project. * * @param path container path * @param classpathProperty the type of entry - one of <code>USER_CLASSES</code>, * <code>BOOTSTRAP_CLASSES</code>, or <code>STANDARD_CLASSES</code> * @param project Java project context used for resolution, or <code>null</code> * if to be resolved in the context of the launch configuration this entry * is referenced in * @return runtime classpath entry * @exception CoreException if unable to construct a runtime classpath entry * @since 3.0 */ public static IRuntimeClasspathEntry newRuntimeContainerClasspathEntry(IPath path, int classpathProperty, IJavaProject project) throws CoreException { RuntimeClasspathEntry entry = new RuntimeClasspathEntry(JavaCore.newContainerEntry(path), classpathProperty); entry.setJavaProject(project); return entry; }
/** * Creates a new underlying classpath entry for this runtime classpath entry * with the given paths, due to a change in source attachment. * @param path the path * @param sourcePath the source path * @param rootPath the root path */ protected void updateClasspathEntry(IPath path, IPath sourcePath, IPath rootPath, IPath annotationsPath) { IClasspathEntry entry = null; IClasspathEntry original = getClasspathEntry(); switch (getType()) { case ARCHIVE: IClasspathAttribute[] extraAttributes = original.getExtraAttributes(); if (annotationsPath != null) { extraAttributes = setClasspathAttribute(extraAttributes, IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, annotationsPath.toPortableString()); } entry = JavaCore.newLibraryEntry(path, sourcePath, rootPath, original.getAccessRules(), extraAttributes, original.isExported()); break; case VARIABLE: entry = JavaCore.newVariableEntry(path, sourcePath, rootPath); break; default: return; } setClasspathEntry(entry); }
/** * Returns the resolved classpath entry associated with this runtime * entry, resolving if required. * @return the resolved {@link IClasspathEntry} */ protected IClasspathEntry getResolvedClasspathEntry() { if (fResolvedEntry == null) { fResolvedEntry = JavaCore.getResolvedClasspathEntry(getClasspathEntry()); } return fResolvedEntry; }
Element node = doc.createElement("runtimeClasspathEntry"); //$NON-NLS-1$ doc.appendChild(node); node.setAttribute("type", (new Integer(getType())).toString()); //$NON-NLS-1$ node.setAttribute("path", (new Integer(getClasspathProperty())).toString()); //$NON-NLS-1$ switch (getType()) { case PROJECT : node.setAttribute("projectName", getPath().lastSegment()); //$NON-NLS-1$ break; case ARCHIVE : IResource res = getResource(); if (res == null) { node.setAttribute("externalArchive", getPath().toString()); //$NON-NLS-1$ } else { node.setAttribute("internalArchive", res.getFullPath().toString()); //$NON-NLS-1$ case VARIABLE : case CONTAINER : node.setAttribute("containerPath", getPath().toString()); //$NON-NLS-1$ break; if (getSourceAttachmentPath() != null) { node.setAttribute("sourceAttachmentPath", getSourceAttachmentPath().toString()); //$NON-NLS-1$ if (getSourceAttachmentRootPath() != null) { node.setAttribute("sourceRootPath", getSourceAttachmentRootPath().toString()); //$NON-NLS-1$ if (getExternalAnnotationsPath() != null) { node.setAttribute("externalAnnotationsPath", getExternalAnnotationsPath().toString()); //$NON-NLS-1$
if (obj instanceof IRuntimeClasspathEntry) { IRuntimeClasspathEntry r = (IRuntimeClasspathEntry)obj; if (getType() == r.getType() && getClasspathProperty() == r.getClasspathProperty()) { if (getType() == IRuntimeClasspathEntry.CONTAINER) { String id = getPath().segment(0); ClasspathContainerInitializer initializer = JavaCore.getClasspathContainerInitializer(id); IJavaProject javaProject1 = getJavaProject(); IJavaProject javaProject2 = r.getJavaProject(); if (initializer == null || javaProject1 == null || javaProject2 == null) { return getPath().equals(r.getPath()); Object comparisonID1 = initializer.getComparisonID(getPath(), javaProject1); Object comparisonID2 = initializer.getComparisonID(r.getPath(), javaProject2); return comparisonID1.equals(comparisonID2); } else if (getPath() != null && getPath().equals(r.getPath())) { IPath sa1 = getSourceAttachmentPath(); IPath root1 = getSourceAttachmentRootPath(); IPath sa2 = r.getSourceAttachmentPath(); IPath root2 = r.getSourceAttachmentRootPath(); return equal(sa1, sa2) && equal(root1, root2);
setType(Integer.parseInt(root.getAttribute("type"))); //$NON-NLS-1$ } catch (NumberFormatException e) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry_type_2, e); setClasspathProperty(Integer.parseInt(root.getAttribute("path"))); //$NON-NLS-1$ } catch (NumberFormatException e) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry_location_3, e); switch (getType()) { case PROJECT : String name = root.getAttribute("projectName"); //$NON-NLS-1$ if (isEmpty(name)) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry___missing_project_name_4, null); } else { IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(name); setClasspathEntry(JavaCore.newProjectEntry(proj.getFullPath())); if (isEmpty(path)) { if (isEmpty(path)) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry___missing_archive_path_5, null); } else { setClasspathEntry(createLibraryEntry(sourcePath, rootPath, path)); setClasspathEntry(createLibraryEntry(sourcePath, rootPath, path)); if (isEmpty(var)) { abort(LaunchingMessages.RuntimeClasspathEntry_Unable_to_recover_runtime_class_path_entry___missing_variable_name_6, null); } else {
/** * Returns a new runtime classpath entry for the given archive(possibly external). * * @param path * absolute path to an archive * @param classpathProperty * the type of entry - one of <code>USER_CLASSES</code>, <code>BOOTSTRAP_CLASSES</code>,<code>STANDARD_CLASSES</code>, * <code>MODULE_PATH</code>, <code>CLASS_PATH</code> or <code>PATCH_MODULE</code> * @param javaProject * the javaProject to be returned by {@link IRuntimeClasspathEntry#getJavaProject()}, required for PATCH_MODULE * @return runtime classpath entry * @since 3.10 */ public static IRuntimeClasspathEntry newArchiveRuntimeClasspathEntry(IPath path, int classpathProperty, IJavaProject javaProject) { RuntimeClasspathEntry entry = new RuntimeClasspathEntry(JavaCore.newLibraryEntry(path, null, null), classpathProperty); entry.setJavaProject(javaProject); return entry; }
/** * @see IRuntimeClasspathEntry#setSourceAttachmentPath(IPath) */ @Override public void setSourceAttachmentPath(IPath path) { if (path != null && path.isEmpty()) { path = null; } updateClasspathEntry(getPath(), path, getSourceAttachmentRootPath(), getExternalAnnotationsPath()); }
/** * Creates a new underlying classpath entry for this runtime classpath entry * with the given paths, due to a change in source attachment. * @param path the path * @param sourcePath the source path * @param rootPath the root path */ protected void updateClasspathEntry(IPath path, IPath sourcePath, IPath rootPath, IPath annotationsPath) { IClasspathEntry entry = null; IClasspathEntry original = getClasspathEntry(); switch (getType()) { case ARCHIVE: IClasspathAttribute[] extraAttributes = original.getExtraAttributes(); if (annotationsPath != null) { extraAttributes = setClasspathAttribute(extraAttributes, IClasspathAttribute.EXTERNAL_ANNOTATION_PATH, annotationsPath.toPortableString()); } entry = JavaCore.newLibraryEntry(path, sourcePath, rootPath, original.getAccessRules(), extraAttributes, original.isExported()); break; case VARIABLE: entry = JavaCore.newVariableEntry(path, sourcePath, rootPath); break; default: return; } setClasspathEntry(entry); }
/** * @see IRuntimeClasspathEntry#getSourceAttachmentRootPath() */ @Override public IPath getSourceAttachmentRootPath() { IClasspathEntry entry = getClasspathEntry(); IPath path = entry != null ? getClasspathEntry().getSourceAttachmentRootPath() : null; if (path == null && getSourceAttachmentPath() != null) { return Path.EMPTY; } return path; }
/** * @see IRuntimeClasspathEntry#getPath() */ @Override public IPath getPath() { IClasspathEntry entry = getClasspathEntry(); return entry != null ? entry.getPath() : fInvalidPath; }
/** The runtime class path entry for the bundle. * * @return the runtime classpath entry. */ public IRuntimeClasspathEntry getRuntimeClassPathEntry() { if (this.classpathEntry != null && this.runtimeClasspathEntry == null) { this.runtimeClasspathEntry = new RuntimeClasspathEntry(this.classpathEntry); } return this.runtimeClasspathEntry; }