use of org.eclipse.jdt.core.IClasspathAttribute in project che by eclipse.
the class JavadocContentAccess2 method getSourceAttachmentEncoding.
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;
}
use of org.eclipse.jdt.core.IClasspathAttribute in project che by eclipse.
the class JavaDocLocations method getLibraryJavadocLocation.
public static URL getLibraryJavadocLocation(IClasspathEntry entry) {
if (entry == null) {
//$NON-NLS-1$
throw new IllegalArgumentException("Entry must not be null");
}
int kind = entry.getEntryKind();
if (kind != IClasspathEntry.CPE_LIBRARY && kind != IClasspathEntry.CPE_VARIABLE) {
//$NON-NLS-1$
throw new IllegalArgumentException("Entry must be of kind CPE_LIBRARY or CPE_VARIABLE");
}
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;
}
use of org.eclipse.jdt.core.IClasspathAttribute in project che by eclipse.
the class JREContainer method buildClasspathAttributes.
private static IClasspathAttribute[] buildClasspathAttributes(final IVMInstallType vm, final LibraryLocation lib, final boolean overrideJavaDoc) {
List<IClasspathAttribute> classpathAttributes = new LinkedList<IClasspathAttribute>();
// process the javadoc location
URL javadocLocation = lib.getJavadocLocation();
if (overrideJavaDoc && javadocLocation == null) {
//vm.getJavadocLocation();
javadocLocation = null;
}
if (javadocLocation != null) {
IClasspathAttribute javadocCPAttribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, javadocLocation.toExternalForm());
classpathAttributes.add(javadocCPAttribute);
}
// process the index location
URL indexLocation = lib.getIndexLocation();
if (indexLocation != null) {
IClasspathAttribute indexCPLocation = JavaCore.newClasspathAttribute(IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME, indexLocation.toExternalForm());
classpathAttributes.add(indexCPLocation);
}
return classpathAttributes.toArray(new IClasspathAttribute[classpathAttributes.size()]);
}
use of org.eclipse.jdt.core.IClasspathAttribute in project che by eclipse.
the class JREContainer method computeClasspathEntries.
/**
* Computes the classpath entries associated with a VM - one entry per library
* in the context of the given path and project.
*
* @param vm the VM
* @param project the project the resolution is for
* @param environmentId execution environment the resolution is for, or <code>null</code>
* @return classpath entries
*/
private static IClasspathEntry[] computeClasspathEntries(IVMInstallType vm, IJavaProject project, String environmentId) {
//vm.getLibraryLocations();
LibraryLocation[] libs = null;
boolean overrideJavaDoc = false;
if (libs == null) {
libs = getLibraryLocations(vm);
overrideJavaDoc = true;
}
IAccessRule[][] rules = null;
// if (environmentId != null) {
// compute access rules for execution environment
IExecutionEnvironment environment = JavaRuntime.getEnvironment(environmentId);
if (environment != null) {
rules = environment.getAccessRules(vm, libs, project);
}
// }
RuleKey key = null;
if (vm != null && rules != null && environmentId != null) {
key = new RuleKey(vm, environmentId);
RuleEntry entry = fgClasspathEntriesWithRules.get(key);
if (entry != null && entry.equals(rules)) {
return entry.getClasspathEntries();
}
}
List<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(libs.length);
for (int i = 0; i < libs.length; i++) {
if (!libs[i].getSystemLibraryPath().isEmpty()) {
IPath sourcePath = libs[i].getSystemLibrarySourcePath();
if (sourcePath.isEmpty()) {
sourcePath = null;
}
IPath rootPath = libs[i].getPackageRootPath();
if (rootPath.isEmpty()) {
rootPath = null;
}
// construct the classpath attributes for this library location
IClasspathAttribute[] attributes = JREContainer.buildClasspathAttributes(vm, libs[i], overrideJavaDoc);
IAccessRule[] libRules = null;
if (rules != null) {
libRules = rules[i];
} else {
libRules = EMPTY_RULES;
}
entries.add(JavaCore.newLibraryEntry(libs[i].getSystemLibraryPath(), sourcePath, rootPath, libRules, attributes, false));
}
}
IClasspathEntry[] cpEntries = entries.toArray(new IClasspathEntry[entries.size()]);
if (key != null && rules != null) {
fgClasspathEntriesWithRules.put(key, new RuleEntry(rules, cpEntries));
}
return cpEntries;
}
use of org.eclipse.jdt.core.IClasspathAttribute in project che by eclipse.
the class JavaProject method copyFromOldChainedEntry.
private void copyFromOldChainedEntry(ClasspathEntry resolvedEntry, ClasspathEntry chainedEntry) {
IPath path = chainedEntry.getSourceAttachmentPath();
if (path != null) {
resolvedEntry.sourceAttachmentPath = path;
}
path = chainedEntry.getSourceAttachmentRootPath();
if (path != null) {
resolvedEntry.sourceAttachmentRootPath = path;
}
IClasspathAttribute[] attributes = chainedEntry.getExtraAttributes();
if (attributes != null) {
resolvedEntry.extraAttributes = attributes;
}
}
Aggregations