Skip to content

Commit

Permalink
CompletionHandlerTest.testCompletion_Lambda fails randomly
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza committed Sep 3, 2024
1 parent 67ff3b0 commit f5e1e28
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,20 @@

public class JavaFXTest extends AbstractProjectsManagerBasedTest {

private static final String VERSION_1_8 = "1.8";
private static final String JAVA_SE_8 = "JavaSE-1.8";
private static final String JAVA_SE_17 = "JavaSE-17";

/**
* Test musts run with the -Djdkfx8.home=/path/to/jdk8+fx System property, or it
* will be skipped.
* Test requires Java 8 in toolchains.xml
*/
@Test
public void testJavaFX() throws Exception {
IVMInstall defaultJRE = JavaRuntime.getDefaultVMInstall();
String name = "java8fx";
IProject project = null;
IExecutionEnvironment java8env = JVMConfigurator.getExecutionEnvironment(JAVA_SE_8);
IVMInstall oldJavaVm = java8env.getDefaultVM();
try {
IExecutionEnvironment java8env = JVMConfigurator.getExecutionEnvironment(JAVA_SE_8);
IVMInstall java8vm = null;
IVMInstall java8DefaultVm = null;
if (java8env != null) {
Expand Down Expand Up @@ -89,6 +88,7 @@ public void testJavaFX() throws Exception {
if (environment != null) {
environment.setDefaultVM(defaultJRE);
}
java8env.setDefaultVM(oldJavaVm);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
import org.eclipse.jdt.core.WorkingCopyOwner;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.core.manipulation.CoreASTProvider;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
import org.eclipse.jdt.ls.core.internal.DocumentAdapter;
import org.eclipse.jdt.ls.core.internal.JDTUtils;
import org.eclipse.jdt.ls.core.internal.JavaClientConnection.JavaLanguageClient;
Expand All @@ -76,6 +81,7 @@
import org.eclipse.jdt.ls.core.internal.ProjectUtils;
import org.eclipse.jdt.ls.core.internal.ResourceUtils;
import org.eclipse.jdt.ls.core.internal.SimpleLogListener;
import org.eclipse.jdt.ls.core.internal.TestVMType;
import org.eclipse.jdt.ls.core.internal.WorkspaceHelper;
import org.eclipse.jdt.ls.core.internal.handlers.BundleUtils;
import org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager;
Expand Down Expand Up @@ -173,6 +179,22 @@ public IBuffer createBuffer(ICompilationUnit workingCopy) {
return DocumentAdapter.Null;
}
});
// see https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/3261
IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
for (IVMInstallType vmInstallType : vmInstallTypes) {
if (vmInstallType instanceof TestVMType) {
for (IVMInstall vm : vmInstallType.getVMInstalls()) {
IExecutionEnvironmentsManager manager = JavaRuntime.getExecutionEnvironmentsManager();
IExecutionEnvironment[] environments = manager.getExecutionEnvironments();
for (IExecutionEnvironment environment : environments) {
if (environment.isStrictlyCompatible(vm)) {
environment.setDefaultVM(vm);
break;
}
}
}
}
}
}

protected void initPreferences(Preferences preferences) throws IOException {
Expand Down

0 comments on commit f5e1e28

Please sign in to comment.