Search in sources :

Example 6 with IClasspathAttribute

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;
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry)

Example 7 with IClasspathAttribute

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;
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute)

Example 8 with IClasspathAttribute

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()]);
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) LinkedList(java.util.LinkedList) URL(java.net.URL)

Example 9 with IClasspathAttribute

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;
}
Also used : IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) ArrayList(java.util.ArrayList) IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IExecutionEnvironment(org.eclipse.che.jdt.core.launching.environments.IExecutionEnvironment) IAccessRule(org.eclipse.jdt.core.IAccessRule)

Example 10 with IClasspathAttribute

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;
    }
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) IPath(org.eclipse.core.runtime.IPath)

Aggregations

IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)52 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)37 IPath (org.eclipse.core.runtime.IPath)26 ArrayList (java.util.ArrayList)17 IJavaProject (org.eclipse.jdt.core.IJavaProject)16 Path (org.eclipse.core.runtime.Path)11 HashMap (java.util.HashMap)9 CoreException (org.eclipse.core.runtime.CoreException)9 IAccessRule (org.eclipse.jdt.core.IAccessRule)9 File (java.io.File)6 LinkedHashMap (java.util.LinkedHashMap)6 IProject (org.eclipse.core.resources.IProject)6 Map (java.util.Map)5 IFolder (org.eclipse.core.resources.IFolder)5 Bundle (org.osgi.framework.Bundle)5 Iterator (java.util.Iterator)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 JavaModelException (org.eclipse.jdt.core.JavaModelException)4 URL (java.net.URL)3 IClasspathContainer (org.eclipse.jdt.core.IClasspathContainer)3