Java Code Examples for org.eclipse.jdt.core.IClasspathEntry#CPE_VARIABLE
The following examples show how to use
org.eclipse.jdt.core.IClasspathEntry#CPE_VARIABLE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaDocLocations.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static URL getLibraryJavadocLocation(IClasspathEntry entry) { if (entry == null) { throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$ } int kind = entry.getEntryKind(); if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) { throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$ } IClasspathAttribute[] extraAttributes = entry.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { return parseURL(attrib.getValue()); } } return null; }
Example 2
Source File: JavaClasspathParser.java From sarl with Apache License 2.0 | 6 votes |
/** * Returns the kind of a <code>PackageFragmentRoot</code> from its <code>String</code> form. * * @param kindStr * - string to test * @return the integer identifier of the type of the specified string: CPE_PROJECT, CPE_VARIABLE, CPE_CONTAINER, etc. */ @SuppressWarnings("checkstyle:equalsavoidnull") private static int kindFromString(String kindStr) { if (kindStr.equalsIgnoreCase("prj")) { //$NON-NLS-1$ return IClasspathEntry.CPE_PROJECT; } if (kindStr.equalsIgnoreCase("var")) { //$NON-NLS-1$ return IClasspathEntry.CPE_VARIABLE; } if (kindStr.equalsIgnoreCase("con")) { //$NON-NLS-1$ return IClasspathEntry.CPE_CONTAINER; } if (kindStr.equalsIgnoreCase("src")) { //$NON-NLS-1$ return IClasspathEntry.CPE_SOURCE; } if (kindStr.equalsIgnoreCase("lib")) { //$NON-NLS-1$ return IClasspathEntry.CPE_LIBRARY; } if (kindStr.equalsIgnoreCase("output")) { //$NON-NLS-1$ return ClasspathEntry.K_OUTPUT; } return -1; }
Example 3
Source File: JavadocContentAccess2.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static String getSourceAttachmentEncoding(IPackageFragmentRoot root) throws JavaModelException { String encoding = ResourcesPlugin.getEncoding(); IClasspathEntry entry = root.getRawClasspathEntry(); if (entry != null) { int kind = entry.getEntryKind(); if (kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_VARIABLE) { IClasspathAttribute[] extraAttributes = entry.getExtraAttributes(); for (int i = 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib = extraAttributes[i]; if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) { return attrib.getValue(); } } } } return encoding; }
Example 4
Source File: PDEClassPathGenerator.java From spotbugs with GNU Lesser General Public License v2.1 | 6 votes |
private static void resolveInWorkspace(IClasspathEntry classpathEntry, Set<String> classPath, Set<IProject> projectOnCp) { int entryKind = classpathEntry.getEntryKind(); switch (entryKind) { case IClasspathEntry.CPE_PROJECT: Set<String> cp = resolveProjectClassPath(classpathEntry.getPath(), projectOnCp); classPath.addAll(cp); break; case IClasspathEntry.CPE_VARIABLE: classpathEntry = JavaCore.getResolvedClasspathEntry(classpathEntry); if (classpathEntry == null) { return; } //$FALL-THROUGH$ case IClasspathEntry.CPE_LIBRARY: String lib = resolveLibrary(classpathEntry.getPath()); if (lib != null) { classPath.add(lib); } break; case IClasspathEntry.CPE_SOURCE: // ??? break; default: break; } }
Example 5
Source File: PackageExplorerContentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected Object internalGetParent(Object element) { if (!fIsFlatLayout && element instanceof IPackageFragment) { return getHierarchicalPackageParent((IPackageFragment) element); } else if (element instanceof IPackageFragmentRoot) { // since we insert logical package containers we have to fix // up the parent for package fragment roots so that they refer // to the container and containers refer to the project IPackageFragmentRoot root= (IPackageFragmentRoot)element; try { IClasspathEntry entry= root.getRawClasspathEntry(); int entryKind= entry.getEntryKind(); if (entryKind == IClasspathEntry.CPE_CONTAINER) { return new ClassPathContainer(root.getJavaProject(), entry); } else if (fShowLibrariesNode && (entryKind == IClasspathEntry.CPE_LIBRARY || entryKind == IClasspathEntry.CPE_VARIABLE)) { return new LibraryContainer(root.getJavaProject()); } } catch (JavaModelException e) { // fall through } } else if (element instanceof PackageFragmentRootContainer) { return ((PackageFragmentRootContainer)element).getJavaProject(); } return super.internalGetParent(element); }
Example 6
Source File: JavaDocLocations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static URL getLibraryJavadocLocation(IClasspathEntry entry) { if (entry == null) { throw new IllegalArgumentException("Entry must not be null"); //$NON-NLS-1$ } int kind= entry.getEntryKind(); if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) { throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE"); //$NON-NLS-1$ } IClasspathAttribute[] extraAttributes= entry.getExtraAttributes(); for (int i= 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib= extraAttributes[i]; if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { return parseURL(attrib.getValue()); } } return null; }
Example 7
Source File: ClasspathEntry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * This function computes the URL of the index location for this classpath entry. It returns null if the URL is * invalid. */ public URL getLibraryIndexLocation() { switch(getEntryKind()) { case IClasspathEntry.CPE_LIBRARY : case IClasspathEntry.CPE_VARIABLE : break; default : return null; } if (this.extraAttributes == null) return null; for (int i= 0; i < this.extraAttributes.length; i++) { IClasspathAttribute attrib= this.extraAttributes[i]; if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { String value = attrib.getValue(); try { return new URL(value); } catch (MalformedURLException e) { return null; } } } return null; }
Example 8
Source File: LibraryContainer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override public IPackageFragmentRoot[] getPackageFragmentRoots() { List<IPackageFragmentRoot> list= new ArrayList<IPackageFragmentRoot>(); try { IPackageFragmentRoot[] roots= getJavaProject().getPackageFragmentRoots(); for (int i= 0; i < roots.length; i++) { IPackageFragmentRoot root= roots[i]; int classpathEntryKind= root.getRawClasspathEntry().getEntryKind(); if (classpathEntryKind == IClasspathEntry.CPE_LIBRARY || classpathEntryKind == IClasspathEntry.CPE_VARIABLE) { list.add(root); } } } catch (JavaModelException e) { // fall through } return list.toArray(new IPackageFragmentRoot[list.size()]); }
Example 9
Source File: BuildPathDialogAccess.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Shows the UI for configuring a javadoc location attribute of the classpath entry. <code>null</code> is returned * if the user cancels the dialog. The dialog does not apply any changes. * * @param shell The parent shell for the dialog. * @param initialEntry The entry to edit. The kind of the classpath entry must be either * <code>IClasspathEntry.CPE_LIBRARY</code> or <code>IClasspathEntry.CPE_VARIABLE</code>. * @return Returns the resulting classpath entry containing a potentially modified javadoc location attribute * The resulting entry can be used to replace the original entry on the classpath. * Note that the dialog does not make any changes on the passed entry nor on the classpath that * contains it. * * @since 3.1 */ public static IClasspathEntry configureJavadocLocation(Shell shell, IClasspathEntry initialEntry) { if (initialEntry == null) { throw new IllegalArgumentException(); } int entryKind= initialEntry.getEntryKind(); if (entryKind != IClasspathEntry.CPE_LIBRARY && entryKind != IClasspathEntry.CPE_VARIABLE) { throw new IllegalArgumentException(); } URL location= JavaUI.getLibraryJavadocLocation(initialEntry); JavadocLocationDialog dialog= new JavadocLocationDialog(shell, BasicElementLabels.getPathLabel(initialEntry.getPath(), false), location); if (dialog.open() == Window.OK) { CPListElement element= CPListElement.createFromExisting(initialEntry, null); URL res= dialog.getResult(); element.setAttribute(CPListElement.JAVADOC, res != null ? res.toExternalForm() : null); return element.getClasspathEntry(); } return null; }
Example 10
Source File: IDEClassPathBlock.java From birt with Eclipse Public License 1.0 | 5 votes |
public boolean isEntryKind( int kind ) { return kind == IClasspathEntry.CPE_LIBRARY || kind == IClasspathEntry.CPE_PROJECT || kind == IClasspathEntry.CPE_VARIABLE || kind == IClasspathEntry.CPE_CONTAINER; }
Example 11
Source File: JavaUtils.java From developer-studio with Apache License 2.0 | 5 votes |
public static IPackageFragmentRoot[] getReferencedVariablesForProject(IProject project) throws JavaModelException{ IJavaProject p = JavaCore.create(project); IPackageFragmentRoot[] packageFragmentRoots = p.getPackageFragmentRoots(); ArrayList<IPackageFragmentRoot> jarClassPaths = new ArrayList<IPackageFragmentRoot>(); for (IPackageFragmentRoot packageFragmentRoot : packageFragmentRoots) { if (packageFragmentRoot.getRawClasspathEntry().getEntryKind()==IClasspathEntry.CPE_VARIABLE){ jarClassPaths.add(packageFragmentRoot); } } return jarClassPaths.toArray(new IPackageFragmentRoot[]{}); }
Example 12
Source File: DialogPackageExplorer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public boolean select(Viewer viewer, Object parentElement, Object element) { try { if (element instanceof IFile) { IFile file= (IFile) element; if (file.getName().equals(".classpath") || file.getName().equals(".project")) //$NON-NLS-1$//$NON-NLS-2$ return false; } else if (element instanceof IPackageFragmentRoot) { IClasspathEntry cpe= ((IPackageFragmentRoot)element).getRawClasspathEntry(); if (cpe == null || cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER || cpe.getEntryKind() == IClasspathEntry.CPE_LIBRARY || cpe.getEntryKind() == IClasspathEntry.CPE_VARIABLE) return false; } else if (element instanceof PackageFragmentRootContainer) { return false; } else if (element instanceof IPackageFragment) { IPackageFragment fragment= (IPackageFragment)element; if (fragment.isDefaultPackage() && !fragment.hasChildren()) return false; } else if (element instanceof IFolder) { IFolder folder= (IFolder)element; if (folder.getName().startsWith(".")) //$NON-NLS-1$ return false; } } catch (JavaModelException e) { JavaPlugin.log(e); } /*if (element instanceof IPackageFragmentRoot) { IPackageFragmentRoot root= (IPackageFragmentRoot)element; if (root.getElementName().endsWith(".jar") || root.getElementName().endsWith(".zip")) //$NON-NLS-1$ //$NON-NLS-2$ return false; }*/ return /*super.select(viewer, parentElement, element) &&*/ fOutputFolderFilter.select(viewer, parentElement, element); }
Example 13
Source File: ClasspathModifier.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static void insertAtEndOfCategory(CPListElement entry, List<CPListElement> existingEntries) { int length= existingEntries.size(); CPListElement[] elements= existingEntries.toArray(new CPListElement[length]); int i= 0; while (i < length && elements[i].getClasspathEntry().getEntryKind() != entry.getClasspathEntry().getEntryKind()) { i++; } if (i < length) { i++; while (i < length && elements[i].getClasspathEntry().getEntryKind() == entry.getClasspathEntry().getEntryKind()) { i++; } existingEntries.add(i, entry); return; } switch (entry.getClasspathEntry().getEntryKind()) { case IClasspathEntry.CPE_SOURCE: existingEntries.add(0, entry); break; case IClasspathEntry.CPE_CONTAINER: case IClasspathEntry.CPE_LIBRARY: case IClasspathEntry.CPE_PROJECT: case IClasspathEntry.CPE_VARIABLE: default: existingEntries.add(entry); break; } }
Example 14
Source File: CPListElement.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean isDeprecated() { if (fEntryKind != IClasspathEntry.CPE_VARIABLE) { return false; } if (fPath.segmentCount() > 0) { return JavaCore.getClasspathVariableDeprecationMessage(fPath.segment(0)) != null; } return false; }
Example 15
Source File: IDEClassPathBlock.java From birt with Eclipse Public License 1.0 | 5 votes |
private int getType( IDECPListElement element ) { int kind = element.getEntryKind( ); if ( kind == IClasspathEntry.CPE_VARIABLE ) { return VAR_TYPE; } else if ( kind == IClasspathEntry.CPE_PROJECT ) { return PROJECT_TYPE; } else if ( kind == IClasspathEntry.CPE_LIBRARY ) { IResource resource = element.getResource( ); if ( resource instanceof IFile ) { return JAR_TYPE; } if ( resource instanceof IContainer ) { return FOL_TYPE; } IPath path = element.getPath( ); File file = path.toFile( ); if ( file.isFile( ) ) { return EXTJAR_TYPE; } else { return ADDFOL_TYPE; } } return UNKNOW_TYPE; }
Example 16
Source File: IDEClassPathBlock.java From birt with Eclipse Public License 1.0 | 5 votes |
private static IDECPListElement createCPVariableElement( IPath path ) { IDECPListElement elem = new IDECPListElement( IClasspathEntry.CPE_VARIABLE, path, null ); IPath resolvedPath = JavaCore.getResolvedVariablePath( path ); elem.setIsMissing( ( resolvedPath == null ) || !resolvedPath.toFile( ).exists( ) ); return elem; }
Example 17
Source File: IDEClassPathBlock.java From birt with Eclipse Public License 1.0 | 4 votes |
private void editElementEntry( IDECPListElement elem ) { IDECPListElement[] res = null; switch ( elem.getEntryKind( ) ) { case IClasspathEntry.CPE_LIBRARY : IResource resource = elem.getResource( ); if ( resource == null ) { File file = elem.getPath( ).toFile( ); if ( file.isDirectory( ) ) { res = openExternalClassFolderDialog( elem ); } else { res = openExtJarFileDialog( elem ); } } else if ( resource.getType( ) == IResource.FILE ) { res = openJarFileDialog( elem ); } break; case IClasspathEntry.CPE_VARIABLE : res = openVariableSelectionDialog( elem ); break; } if ( res != null && res.length > 0 ) { IDECPListElement curr = res[0]; curr.setExported( elem.isExported( ) ); // curr.setAttributesFromExisting(elem); fLibrariesList.replaceElement( elem, curr ); if ( elem.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE ) { fLibrariesList.refresh( ); } } }
Example 18
Source File: IDECPListElement.java From birt with Eclipse Public License 1.0 | 4 votes |
private IClasspathEntry newClasspathEntry( ) { IClasspathAttribute[] extraAttributes = new IClasspathAttribute[0]; switch ( fEntryKind ) { case IClasspathEntry.CPE_SOURCE : return JavaCore.newSourceEntry( fPath, null, null, null, extraAttributes ); case IClasspathEntry.CPE_LIBRARY : { return JavaCore.newLibraryEntry( fPath, null, null, null, extraAttributes, isExported( ) ); } case IClasspathEntry.CPE_PROJECT : { return JavaCore.newProjectEntry( fPath, null, false, extraAttributes, isExported( ) ); } case IClasspathEntry.CPE_CONTAINER : { return JavaCore.newContainerEntry( fPath, null, extraAttributes, isExported( ) ); } case IClasspathEntry.CPE_VARIABLE : { return JavaCore.newVariableEntry( fPath, null, null, null, extraAttributes, isExported( ) ); } default : return null; } }
Example 19
Source File: IDEReportClasspathResolver.java From birt with Eclipse Public License 1.0 | 4 votes |
private List<String> getAllClassPathFromEntries(List<IClasspathEntry> list) { List<String> retValue = new ArrayList(); IWorkspace space = ResourcesPlugin.getWorkspace( ); IWorkspaceRoot root = space.getRoot( ); for (int i=0; i<list.size( ); i++) { IClasspathEntry curr = list.get( i ); boolean inWorkSpace = true; if ( space == null || space.getRoot( ) == null ) { inWorkSpace = false; } IPath path = curr.getPath( ); if (curr.getEntryKind( ) == IClasspathEntry.CPE_VARIABLE) { path = JavaCore.getClasspathVariable( path.segment( 0 ) ); } else { path = JavaCore.getResolvedClasspathEntry( curr ).getPath( ); } if (curr.getEntryKind( ) == IClasspathEntry.CPE_PROJECT) { if (root.findMember( path ) instanceof IProject) { List<String> strs = getProjectClasspath( (IProject)root.findMember( path ),false, true ); for (int j=0; j<strs.size( ); j++) { addToList( retValue, strs.get( j ) ); } } } else { if ( root.findMember( path ) == null ) { inWorkSpace = false; } if ( inWorkSpace ) { String absPath = getFullPath( path, root.findMember( path ).getProject( ) ); //retValue.add( absPath ); addToList( retValue, absPath ); } else { //retValue.add( path.toFile( ).getAbsolutePath( )); addToList( retValue, path.toFile( ).getAbsolutePath( ) ); } } //strs.add( JavaCore.getResolvedClasspathEntry( entry ).getPath( ).toFile( ).getAbsolutePath( ) ); } return retValue; }
Example 20
Source File: CPListElement.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public static CPListElement create(Object parent, IClasspathEntry curr, boolean newElement, IJavaProject project) { IPath path= curr.getPath(); IWorkspaceRoot root= ResourcesPlugin.getWorkspace().getRoot(); // get the resource IResource res= null; boolean isMissing= false; IPath linkTarget= null; switch (curr.getEntryKind()) { case IClasspathEntry.CPE_CONTAINER: try { isMissing= project != null && (JavaCore.getClasspathContainer(path, project) == null); } catch (JavaModelException e) { isMissing= true; } break; case IClasspathEntry.CPE_VARIABLE: IPath resolvedPath= JavaCore.getResolvedVariablePath(path); isMissing= root.findMember(resolvedPath) == null && !resolvedPath.toFile().exists(); break; case IClasspathEntry.CPE_LIBRARY: res= root.findMember(path); if (res == null) { if (!ArchiveFileFilter.isArchivePath(path, true)) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK() && root.getProject(path.segment(0)).exists()) { res= root.getFolder(path); } } IPath rawPath= path; if (project != null) { IPackageFragmentRoot[] roots= project.findPackageFragmentRoots(curr); if (roots.length == 1) rawPath= roots[0].getPath(); } isMissing= !rawPath.toFile().exists(); // look for external JARs and folders } else if (res.isLinked()) { linkTarget= res.getLocation(); } break; case IClasspathEntry.CPE_SOURCE: path= path.removeTrailingSeparator(); res= root.findMember(path); if (res == null) { if (root.getWorkspace().validatePath(path.toString(), IResource.FOLDER).isOK()) { res= root.getFolder(path); } isMissing= true; } else if (res.isLinked()) { linkTarget= res.getLocation(); } break; case IClasspathEntry.CPE_PROJECT: res= root.findMember(path); isMissing= (res == null); break; } CPListElement elem= new CPListElement(parent, project, curr.getEntryKind(), path, newElement, res, linkTarget); elem.setExported(curr.isExported()); elem.setAttribute(SOURCEATTACHMENT, curr.getSourceAttachmentPath()); elem.setAttribute(OUTPUT, curr.getOutputLocation()); elem.setAttribute(EXCLUSION, curr.getExclusionPatterns()); elem.setAttribute(INCLUSION, curr.getInclusionPatterns()); elem.setAttribute(ACCESSRULES, curr.getAccessRules()); elem.setAttribute(COMBINE_ACCESSRULES, new Boolean(curr.combineAccessRules())); IClasspathAttribute[] extraAttributes= curr.getExtraAttributes(); for (int i= 0; i < extraAttributes.length; i++) { IClasspathAttribute attrib= extraAttributes[i]; CPListElementAttribute attribElem= elem.findAttributeElement(attrib.getName()); if (attribElem == null) { elem.createAttributeElement(attrib.getName(), attrib.getValue(), false); } else { attribElem.setValue(attrib.getValue()); } } elem.setIsMissing(isMissing); return elem; }