Search in sources :

Example 6 with IExecutionEnvironmentsManager

use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project eclipse.jdt.ls by eclipse.

the class JDTUtils method setCompatibleVMs.

public static void setCompatibleVMs(String id) {
    // update all environments compatible to use the test JRE
    IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
    IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
    for (IExecutionEnvironment environment : environments) {
        IVMInstall[] compatibleVMs = environment.getCompatibleVMs();
        for (IVMInstall compatibleVM : compatibleVMs) {
            if (id.equals(compatibleVM.getVMInstallType().getId()) && compatibleVM.getVMInstallType().findVMInstall(compatibleVM.getId()) != null && !compatibleVM.equals(environment.getDefaultVM()) && // Fugly way to ensure the lowest VM version is set:
            (environment.getDefaultVM() == null || compatibleVM.getId().compareTo(environment.getDefaultVM().getId()) < 0)) {
                environment.setDefaultVM(compatibleVM);
            }
        }
    }
}
Also used : IExecutionEnvironment(org.eclipse.jdt.launching.environments.IExecutionEnvironment) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IExecutionEnvironmentsManager(org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager)

Example 7 with IExecutionEnvironmentsManager

use of org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager in project eclipse.jdt.ls by eclipse.

the class ProjectsManager method getWorkspaceInfo.

private String getWorkspaceInfo() {
    StringBuilder b = new StringBuilder();
    b.append("Projects:\n");
    for (IProject project : getWorkspaceRoot().getProjects()) {
        b.append(project.getName()).append(": ").append(project.getLocation().toOSString()).append('\n');
        if (ProjectUtils.isJavaProject(project)) {
            IJavaProject javaProject = JavaCore.create(project);
            try {
                b.append("  resolved classpath:\n");
                IClasspathEntry[] cpEntries = javaProject.getRawClasspath();
                for (IClasspathEntry cpe : cpEntries) {
                    b.append("  ").append(cpe.getPath().toString()).append('\n');
                    if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER) {
                        IPackageFragmentRoot[] roots = javaProject.findPackageFragmentRoots(cpe);
                        for (IPackageFragmentRoot root : roots) {
                            b.append("    ").append(root.getPath().toString()).append('\n');
                        }
                    }
                }
            } catch (CoreException e) {
            // ignore
            }
        } else {
            b.append("  non-Java project\n");
        }
    }
    b.append("Java Runtimes:\n");
    IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
    b.append("  default: ");
    if (defaultVMInstall != null) {
        b.append(defaultVMInstall.getInstallLocation().toString());
    } else {
        b.append("-");
    }
    IExecutionEnvironmentsManager eem = JavaRuntime.getExecutionEnvironmentsManager();
    for (IExecutionEnvironment ee : eem.getExecutionEnvironments()) {
        IVMInstall[] vms = ee.getCompatibleVMs();
        b.append("  ").append(ee.getDescription()).append(": ");
        if (vms.length > 0) {
            b.append(vms[0].getInstallLocation().toString());
        } else {
            b.append("-");
        }
        b.append("\n");
    }
    return b.toString();
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IExecutionEnvironment(org.eclipse.jdt.launching.environments.IExecutionEnvironment) CoreException(org.eclipse.core.runtime.CoreException) IVMInstall(org.eclipse.jdt.launching.IVMInstall) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IProject(org.eclipse.core.resources.IProject) IExecutionEnvironmentsManager(org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot)

Aggregations

IExecutionEnvironment (org.eclipse.jdt.launching.environments.IExecutionEnvironment)7 IExecutionEnvironmentsManager (org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager)7 IVMInstall (org.eclipse.jdt.launching.IVMInstall)5 CoreException (org.eclipse.core.runtime.CoreException)2 IVMInstall2 (org.eclipse.jdt.launching.IVMInstall2)2 IProject (org.eclipse.core.resources.IProject)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 Status (org.eclipse.core.runtime.Status)1 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)1