Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompletionHandlerTest.testCompletion_Lambda fails randomly #3263

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3461,7 +3461,7 @@ public void testCompletion_Lambda() throws Exception {
assertNotNull(lambda);
assertTrue(lambda.getTextEdit().getLeft().getNewText().matches("\\$\\{1:\\w+\\} -> \\$\\{0\\}"));

assertEquals(lambda.getLabel(), "(Object arg0) ->");
assertEquals("(Object arg0) ->", lambda.getLabel());
assertNull(lambda.getLabelDetails().getDetail());
assertEquals(lambda.getLabelDetails().getDescription(), "void");
}
Expand Down
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 @@ -137,6 +143,22 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
public static void initJVMs() {
JobHelpers.waitForLookupJDKToolchainsJob(600000);
CorePlugin.publishedGradleVersions().getVersions();
// see https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/3261
IVMInstallType[] vmInstallTypes = JavaRuntime.getVMInstallTypes();
rgrunber marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}
}
}
}
}

@Before
Expand Down
Loading