From b6420887cd53563e6d5249f33b3b8dd31e963256 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 30 Jan 2025 08:50:49 +0100 Subject: [PATCH 1/7] added logging to all waitForBuild --- ...uickDebugSourceInstallingCompilationParticipantTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java index 37f67da35ae..921fcc3b875 100644 --- a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java +++ b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java @@ -38,7 +38,8 @@ public void testIfThereIsAnyStatum() throws Exception { public class Hello { } """); - IResourcesSetupUtil.waitForBuild(); + IResourcesSetupUtil.waitForBuild( + new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("JAVA BUILD")); final IFile source = workbenchTestHelper.createFile("somePackage/Outer.xtend", """ package somePackage @@ -51,7 +52,8 @@ def dosomething() { } } """); - IResourcesSetupUtil.waitForBuild(); + IResourcesSetupUtil.waitForBuild( + new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("XTEND BUILD")); // ensure also JDT builder finished its jobs IResourcesSetupUtil.waitForBuild( From 3efbe0f0902ad72ceef30427a8dc5a72fa153444 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 30 Jan 2025 09:00:56 +0100 Subject: [PATCH 2/7] isAutobuild without parameters, deprecated the old one The boolean enable parameter was not used anyway: it must have been a copy and paste error --- .../ui/testing/util/IResourcesSetupUtil.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/org.eclipse.xtext.ui.testing/src/org/eclipse/xtext/ui/testing/util/IResourcesSetupUtil.java b/org.eclipse.xtext.ui.testing/src/org/eclipse/xtext/ui/testing/util/IResourcesSetupUtil.java index c3e7b995975..5329ff9118d 100644 --- a/org.eclipse.xtext.ui.testing/src/org/eclipse/xtext/ui/testing/util/IResourcesSetupUtil.java +++ b/org.eclipse.xtext.ui.testing/src/org/eclipse/xtext/ui/testing/util/IResourcesSetupUtil.java @@ -390,11 +390,22 @@ public static void reallyWaitForAutoBuild() { public static void waitForBuild() { waitForBuild(null); } - - public static boolean isAutobuild(boolean enable) { + + /** + * @since 2.38 + */ + public static boolean isAutobuild() { return ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding(); } + /** + * @deprecated use {@link #isAutobuild()} instead (the boolean parameter is unused). + */ + @Deprecated(forRemoval = true) + public static boolean isAutobuild(boolean enable) { + return isAutobuild(); + } + public static boolean setAutobuild(boolean enable) { IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); boolean oldValue = description.isAutoBuilding(); From ccd44877edd3a612f257a6de8cabac4e7338e55c Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 30 Jan 2025 09:02:41 +0100 Subject: [PATCH 3/7] reset auto-build to the saved value --- .../ui/editor/quickfix/InternalBuilderTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java index cce9a81223e..690605ff20a 100644 --- a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java +++ b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java @@ -31,6 +31,9 @@ import org.eclipse.jdt.internal.core.JavaModelManager; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.ui.texteditor.MarkerUtilities; +import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil; +import org.junit.After; +import org.junit.Before; import org.junit.Test; /** @@ -38,6 +41,18 @@ */ public class InternalBuilderTest { + private boolean wasAutoBuild; + + @Before + public void saveAutoBuild() { + wasAutoBuild = IResourcesSetupUtil.isAutobuild(); + } + + @After + public void resetAutoBuild() { + setAutoBuild(wasAutoBuild); + } + @Test public void test() throws CoreException, FileNotFoundException { From fe67e71108825b9f2a31ab50f18f9900f637dbc6 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 30 Jan 2025 09:05:27 +0100 Subject: [PATCH 4/7] removed useless setAutobuild --- .../xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java | 2 +- .../ui/editor/quickfix/XtextGrammarQuickfixProviderTest.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java index 690605ff20a..a3cb02dba80 100644 --- a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java +++ b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/InternalBuilderTest.java @@ -178,7 +178,7 @@ public static void waitForAutoBuild() { } while (wasInterrupted); } - public static void setAutoBuild(boolean b) { + private static void setAutoBuild(boolean b) { System.out.println("Setting auto-build to " + b); IWorkspace workspace = ResourcesPlugin.getWorkspace(); diff --git a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixProviderTest.java b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixProviderTest.java index 3dcbc3c7359..50d94a2cc41 100644 --- a/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixProviderTest.java +++ b/org.eclipse.xtext.xtext.ui.tests/src/org/eclipse/xtext/xtext/ui/editor/quickfix/XtextGrammarQuickfixProviderTest.java @@ -263,7 +263,6 @@ private void assertAndApplySingleResolution(XtextEditor xtextEditor, String issu private void assertAndApplyAllResolutions(XtextEditor xtextEditor, String issueCode, int issueDataCount, int issueCount, String resolutionLabel) throws CoreException { - InternalBuilderTest.setAutoBuild(true); if (xtextEditor.isDirty()) { xtextEditor.doSave(new NullProgressMonitor()); } From 8956fba0b8cc7e394783ff94def2a6f31b633a06 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 30 Jan 2025 14:06:16 +0100 Subject: [PATCH 5/7] also refresh the project --- ...uickDebugSourceInstallingCompilationParticipantTest.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java index 921fcc3b875..066e9d9ef7f 100644 --- a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java +++ b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java @@ -11,6 +11,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IResource; import org.eclipse.xtend.ide.tests.AbstractXtendUITestCase; import org.eclipse.xtend.ide.tests.WorkbenchTestHelper; import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil; @@ -57,7 +58,10 @@ def dosomething() { // ensure also JDT builder finished its jobs IResourcesSetupUtil.waitForBuild( - new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("ANOTHER BUILD")); + new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("ANOTHER BUILD")); + + source.getProject().refreshLocal(IResource.DEPTH_INFINITE, + new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("REFRESH")); final IFile clazz = source.getProject().getFile("bin/somePackage/Outer.class"); assertTrue("bytecode not found", clazz.exists()); From 23662c92146279f908fcb69a89ac4979d94441aa Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Thu, 30 Jan 2025 18:31:50 +0100 Subject: [PATCH 6/7] attempt with simplification --- ...SourceInstallingCompilationParticipantTest.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java index 066e9d9ef7f..90dc6e9a142 100644 --- a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java +++ b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/compiler/QuickDebugSourceInstallingCompilationParticipantTest.java @@ -32,16 +32,6 @@ public class QuickDebugSourceInstallingCompilationParticipantTest extends Abstra @Test public void testIfThereIsAnyStatum() throws Exception { - // ensure JDT is fully functional and its participants registered - workbenchTestHelper.createFile("hello/Hello.java", """ - package hello; - - public class Hello { - } - """); - IResourcesSetupUtil.waitForBuild( - new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("JAVA BUILD")); - final IFile source = workbenchTestHelper.createFile("somePackage/Outer.xtend", """ package somePackage @@ -56,10 +46,6 @@ def dosomething() { IResourcesSetupUtil.waitForBuild( new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("XTEND BUILD")); - // ensure also JDT builder finished its jobs - IResourcesSetupUtil.waitForBuild( - new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("ANOTHER BUILD")); - source.getProject().refreshLocal(IResource.DEPTH_INFINITE, new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("REFRESH")); From ec36fa272ca49ce2ec11802cf39a0b0654dfa325 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Fri, 31 Jan 2025 09:45:38 +0100 Subject: [PATCH 7/7] explicit editor.waitForReconciler --- .../eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.xtend | 1 + .../eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.java | 1 + 2 files changed, 2 insertions(+) diff --git a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.xtend b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.xtend index d69b1ee7d42..70d24a47573 100644 --- a/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.xtend +++ b/org.eclipse.xtend.ide.tests/src/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.xtend @@ -90,6 +90,7 @@ class XtendHoverInEditorTest extends AbstractXtendUITestCase { waitForBuild(null) val editor = openEditor(fileBar) + editor.waitForReconciler val loggings = LoggingTester.captureLogging(Level.ERROR, AbstractBatchTypeResolver) [ val info = (hoverer as ITextHoverExtension2).getHoverInfo2(editor.internalSourceViewer as ITextViewer, new Region(19,1)) as XtextBrowserInformationControlInput assertTrue(info.html,info.html.contains("Hello Foo")) diff --git a/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.java b/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.java index 544ac1dedaa..d77459c02e2 100644 --- a/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.java +++ b/org.eclipse.xtend.ide.tests/xtend-gen/org/eclipse/xtend/ide/tests/hover/XtendHoverInEditorTest.java @@ -140,6 +140,7 @@ public void testHoverOfReferencedElementWithAnnotation() { final IFile fileBar = this.helper.createFile("Bar.xtend", contentBar); this._syncUtil.waitForBuild(null); final XtextEditor editor = this.helper.openEditor(fileBar); + this._syncUtil.waitForReconciler(editor); final Runnable _function = () -> { ISourceViewer _internalSourceViewer = editor.getInternalSourceViewer(); Region _region = new Region(19, 1);