Search in sources :

Example 1 with IExecutionEnvironment

use of org.eclipse.che.jdt.core.launching.environments.IExecutionEnvironment 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)

Aggregations

ArrayList (java.util.ArrayList)1 IExecutionEnvironment (org.eclipse.che.jdt.core.launching.environments.IExecutionEnvironment)1 IPath (org.eclipse.core.runtime.IPath)1 IAccessRule (org.eclipse.jdt.core.IAccessRule)1 IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1