/** * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code> * for the given path. This method is fully equivalent to calling * {@link #newVariableEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) * newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], false)}. * * @param variablePath the path of the binary archive; first segment is the * name of a classpath variable * @param variableSourceAttachmentPath the path of the corresponding source archive, * or <code>null</code> if none; if present, the first segment is the * name of a classpath variable (not necessarily the same variable * as the one that begins <code>variablePath</code>) * @param sourceAttachmentRootPath the location of the root of the source files within the source archive * or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code> * @return a new library classpath entry */ public static IClasspathEntry newVariableEntry( IPath variablePath, IPath variableSourceAttachmentPath, IPath sourceAttachmentRootPath) { return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false); }
/** * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code> * for the given path. This method is fully equivalent to calling * {@link #newVariableEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) * newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], false)}. * * @param variablePath the path of the binary archive; first segment is the * name of a classpath variable * @param variableSourceAttachmentPath the path of the corresponding source archive, * or <code>null</code> if none; if present, the first segment is the * name of a classpath variable (not necessarily the same variable * as the one that begins <code>variablePath</code>) * @param sourceAttachmentRootPath the location of the root of the source files within the source archive * or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code> * @return a new library classpath entry */ public static IClasspathEntry newVariableEntry( IPath variablePath, IPath variableSourceAttachmentPath, IPath sourceAttachmentRootPath) { return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false); }
/** * Creates and returns a new non-exported classpath entry of kind <code>CPE_VARIABLE</code> * for the given path. This method is fully equivalent to calling * {@link #newVariableEntry(IPath, IPath, IPath, IAccessRule[], IClasspathAttribute[], boolean) * newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, new IAccessRule[0], new IClasspathAttribute[0], false)}. * * @param variablePath the path of the binary archive; first segment is the * name of a classpath variable * @param variableSourceAttachmentPath the path of the corresponding source archive, * or <code>null</code> if none; if present, the first segment is the * name of a classpath variable (not necessarily the same variable * as the one that begins <code>variablePath</code>) * @param sourceAttachmentRootPath the location of the root of the source files within the source archive * or <code>null</code> if <code>variableSourceAttachmentPath</code> is also <code>null</code> * @return a new library classpath entry */ public static IClasspathEntry newVariableEntry( IPath variablePath, IPath variableSourceAttachmentPath, IPath sourceAttachmentRootPath) { return newVariableEntry(variablePath, variableSourceAttachmentPath, sourceAttachmentRootPath, false); }
private static IClasspathEntry getJREVariableEntry() { return JavaCore.newVariableEntry(new Path("JRE_LIB"), new Path("JRE_SRC"), new Path("JRE_SRCROOT")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
private static IClasspathEntry getJREVariableEntry() { return JavaCore.newVariableEntry(new Path("JRE_LIB"), new Path("JRE_SRC"), new Path("JRE_SRCROOT")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
/** * Creates and returns a classpath entry describing * the JRE_LIB classpath variable. * * @return a new IClasspathEntry that describes the JRE_LIB classpath variable */ public static IClasspathEntry getJREVariableEntry() { return JavaCore.newVariableEntry( new Path(JRELIB_VARIABLE), new Path(JRESRC_VARIABLE), new Path(JRESRCROOT_VARIABLE) ); }
/** * Creates and returns a classpath entry describing * the JRE_LIB classpath variable. * * @return a new IClasspathEntry that describes the JRE_LIB classpath variable */ public static IClasspathEntry getJREVariableEntry() { return JavaCore.newVariableEntry( new Path(JRELIB_VARIABLE), new Path(JRESRC_VARIABLE), new Path(JRESRCROOT_VARIABLE) ); }
private static IClasspathEntry getJREVariableEntry() { return JavaCore.newVariableEntry(new Path("JRE_LIB"), new Path("JRE_SRC"), new Path("JRE_SRCROOT")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ }
/** * Returns a new runtime classpath entry for the classpath * variable with the given path. * * @param path variable path; first segment is the name of the variable; * trailing segments are appended to the resolved variable value * @return runtime classpath entry * @since 2.0 */ public static IRuntimeClasspathEntry newVariableRuntimeClasspathEntry(IPath path) { return newRuntimeClasspathEntry(JavaCore.newVariableEntry(path, null, null)); }
/** * Returns a new runtime classpath entry for the classpath * variable with the given path. * * @param path variable path; first segment is the name of the variable; * trailing segments are appended to the resolved variable value * @return runtime classpath entry * @since 2.0 */ public static IRuntimeClasspathEntry newVariableRuntimeClasspathEntry(IPath path) { return newRuntimeClasspathEntry(JavaCore.newVariableEntry(path, null, null)); }
/** * Adds a variable entry with source attachment to a IJavaProject if the path can be resolved. */ private void addVariableEntry(IJavaProject jproject, IPath path, IPath sourceAttachPath, IPath sourceAttachRoot, IProgressMonitor monitor) throws JavaModelException { IClasspathEntry cpe = JavaCore.newVariableEntry(path, sourceAttachPath, sourceAttachRoot); addToClasspath(jproject, cpe, monitor); }
/** * Obtains the {@link IClasspathEntry} of the input variable and path. * * @param variable * Name of variable. * @param path * Path from variable. * @return {@link IClasspathEntry} for the variable or <code>null</code> if * fails to create. */ public static IClasspathEntry createClasspathEntry(String variable, String path) { // Create the path IPath variablePath = new Path(variable).append(path); // Return the variable class path entry return JavaCore.newVariableEntry(variablePath, null, null); }
public boolean addVariableJarToClasspathEntriesWithAttachments(String fullPath, String srcPath, String srcRoot) { IJavaProject javaProject = getJavaProject(); if (javaProject == null) return false; IClasspathEntry[] entry = new IClasspathEntry[1]; entry[0] = JavaCore.newVariableEntry(new Path(fullPath), new Path(srcPath), new Path(srcRoot)); addToClasspathEntries(entry); return true; }
public boolean addVariableJarToClasspathEntries(String fullPath) { IJavaProject javaProject = getJavaProject(); if (javaProject == null) return false; IClasspathEntry[] entry = new IClasspathEntry[1]; entry[0] = JavaCore.newVariableEntry(new Path(fullPath), null, null); addToClasspathEntries(entry); return true; }
public IClasspathEntry[] newClasspathEntriesForArchive() { if( !archiveURI.equals("")){ String resourcePath = ""; try { resourcePath = ModuleURIUtil.getArchiveName(archiveURI); } catch (UnresolveableURIException e) { Logger.getLogger().logError(e); } IPath resPath = new Path(resourcePath); if (!resPath.isAbsolute()) resPath = resPath.makeAbsolute(); java.io.File file = new java.io.File(resourcePath); if( file.exists() || J2EEPlugin.getWorkspace().getRoot().exists(new Path(resourcePath))){ return new IClasspathEntry[]{JavaCore.newLibraryEntry( resPath, null, null, true)}; }else{ return new IClasspathEntry[]{JavaCore.newVariableEntry( resPath, null, null)}; } } return new IClasspathEntry[0]; }
private static IClasspathEntry createNewClasspathEntry(int kind, IPath path, IPath sourceAttach, IPath sourceAttachRoot){ switch(kind){ case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(path, sourceAttach, sourceAttachRoot); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(path); case IClasspathEntry.CPE_SOURCE: return JavaCore.newSourceEntry(path); case IClasspathEntry.CPE_VARIABLE: return JavaCore.newVariableEntry(path, sourceAttach, sourceAttachRoot); case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(path); default: Assert.isTrue(false); return null; } }
private static IClasspathEntry newClasspathEntry(IClasspathEntry entry, SourceAttachmentAttribute changedAttributes) { IPath filePath = StringUtils.isNotBlank(changedAttributes.sourceAttachmentPath) ? Path.fromOSString(changedAttributes.sourceAttachmentPath).makeAbsolute() : null; IPath sourceAttachmentPath = (filePath != null && filePath.segmentCount() == 0) ? null : filePath; IClasspathAttribute newSourceEncodingAttribute = StringUtils.isNotBlank(changedAttributes.sourceAttachmentEncoding) ? JavaCore.newClasspathAttribute(IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING, changedAttributes.sourceAttachmentEncoding) : null; List<IClasspathAttribute> newAttributes = updateElements(entry.getExtraAttributes(), newSourceEncodingAttribute, (attribute) -> { return attribute.getName() == IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING; }); switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), sourceAttachmentPath, null, entry.getAccessRules(), newAttributes.toArray(new IClasspathAttribute[0]), entry.isExported()); case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), newAttributes.toArray(new IClasspathAttribute[0]), entry.isExported()); case IClasspathEntry.CPE_VARIABLE: return JavaCore.newVariableEntry(entry.getPath(), sourceAttachmentPath, null, entry.getAccessRules(), newAttributes.toArray(new IClasspathAttribute[0]), entry.isExported()); default: return null; } }
protected void ensureClasspathEntryIsExported(List cp, IClasspathEntry entry) { if (entry.isExported()) return; int index = getIndex(cp, entry); IClasspathEntry newEntry = null; switch (entry.getEntryKind()) { case IClasspathEntry.CPE_PROJECT : newEntry = JavaCore.newProjectEntry(entry.getPath(), true); break; case IClasspathEntry.CPE_LIBRARY : newEntry = JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), true); break; case IClasspathEntry.CPE_VARIABLE : newEntry = JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath()); default : break; } if (entry != null) cp.set(index, newEntry); }
/** * 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); }
private static IClasspathEntry addAttributes(IClasspathEntry entry, IClasspathAttribute[] extraAttributes) { switch (entry.getEntryKind()) { case IClasspathEntry.CPE_LIBRARY: return JavaCore.newLibraryEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_PROJECT: return JavaCore.newProjectEntry(entry.getPath(), entry.getAccessRules(), entry.combineAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_CONTAINER: return JavaCore.newContainerEntry(entry.getPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); case IClasspathEntry.CPE_VARIABLE: return JavaCore.newVariableEntry(entry.getPath(), entry.getSourceAttachmentPath(), entry.getSourceAttachmentRootPath(), entry.getAccessRules(), extraAttributes, entry.isExported()); default: return entry; // other kinds are not handled } }