Java Code Examples for org.eclipse.jdt.core.IClasspathAttribute#getValue()
The following examples show how to use
org.eclipse.jdt.core.IClasspathAttribute#getValue() .
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: ProjectCommand.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
private static boolean isTestClasspathEntry(IClasspathEntry entry) { if (entry.getEntryKind() != ClasspathEntry.CPE_SOURCE) { return false; } if (entry.isTest()) { return true; } for (final IClasspathAttribute attribute : entry.getExtraAttributes()) { String attributeName = attribute.getName(); // attribute name could be "maven.scope" for Maven, "gradle_scope" or "gradle_used_by_scope" for Gradle if (attributeName.contains("scope")) { // the attribute value could be "test" or "integrationTest" return attribute.getValue() != null && attribute.getValue().toLowerCase().contains(TEST_SCOPE_VALUE); } } return false; }
Example 2
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 3
Source File: JavadocContentAccess2.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.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: SourceAttachmentBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public static String getSourceAttachmentEncoding(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.SOURCE_ATTACHMENT_ENCODING.equals(attrib.getName())) { return attrib.getValue(); } } return null; }
Example 5
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 6
Source File: SourceAttachmentCommand.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static String getSourceAttachmentEncoding(IClasspathEntry entry) { if (entry != null && entry.getExtraAttributes() != null) { for (IClasspathAttribute attribute : entry.getExtraAttributes()) { if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attribute.getName())) { return attribute.getValue(); } } } return null; }
Example 7
Source File: BuildPathSupport.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Finds a javadoc location for a new archive in the existing classpaths. * @param elem The new classpath entry * @return A javadoc location found in a similar classpath entry or <code>null</code>. */ public static String guessJavadocLocation(CPListElement elem) { if (elem.getEntryKind() == IClasspathEntry.CPE_CONTAINER) { return null; } IJavaProject currProject= elem.getJavaProject(); // can be null try { // try if the jar itself contains the source IJavaModel jmodel= JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); IJavaProject[] jprojects= jmodel.getJavaProjects(); for (int i= 0; i < jprojects.length; i++) { IJavaProject curr= jprojects[i]; if (!curr.equals(currProject)) { IClasspathEntry[] entries= curr.getRawClasspath(); for (int k= 0; k < entries.length; k++) { IClasspathEntry entry= entries[k]; if (entry.getEntryKind() == elem.getEntryKind() && entry.getPath().equals(elem.getPath())) { IClasspathAttribute[] attributes= entry.getExtraAttributes(); for (int n= 0; n < attributes.length; n++) { IClasspathAttribute attrib= attributes[n]; if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) { return attrib.getValue(); } } } } } } } catch (JavaModelException e) { JavaPlugin.log(e.getStatus()); } return null; }
Example 8
Source File: ClasspathEntry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public String getSourceAttachmentEncoding() { for (int i = 0, length = this.extraAttributes.length; i < length; i++) { IClasspathAttribute attribute = this.extraAttributes[i]; if (IClasspathAttribute.SOURCE_ATTACHMENT_ENCODING.equals(attribute.getName())) return attribute.getValue(); } return null; }
Example 9
Source File: SerializableAttribute.java From google-cloud-eclipse with Apache License 2.0 | 4 votes |
SerializableAttribute(IClasspathAttribute attribute) { name = attribute.getName(); value = attribute.getValue(); }