From 73d1dd6b8e001f911f3d2c226bf0a2632be59d83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 24 Nov 2026 16:18:35 +0200 Subject: [PATCH 1/3] Make TestXML XSL and XSD tests trigger a real document change testXSLFile created blah.xsl with "FAIL" and then set the editor document to the same "FAIL" content, so no didChange was sent and the test relied solely on the diagnostics published on didOpen, which sometimes did not arrive in time. Create the file empty so that setting the content is an actual edit. Do the same in testXSDFile, where the invalid initial "FAIL" content could already produce the expected markers on didOpen, so the test did not really verify diagnostics for the edited content. Assisted-by: Anthropic Claude Code (claude-opus-5-5) --- .../src/org/eclipse/wildwebdeveloper/tests/TestXML.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java b/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java index b42423e6c0..3d8c2dda44 100644 --- a/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java +++ b/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java @@ -88,7 +88,7 @@ public void testXMLFile() throws Exception { @Test public void testXSLFile() throws Exception { final IFile file = project.getFile("blah.xsl"); - file.create("FAIL".getBytes(), true, false, null); + file.create(new byte[0], true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("FAIL"); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { @@ -103,7 +103,7 @@ public void testXSLFile() throws Exception { @Test public void testXSDFile() throws Exception { final IFile file = project.getFile("blah.xsd"); - file.create("FAIL".getBytes(), true, false, null); + file.create(new byte[0], true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("a<"); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { From 7c7161ef54adea6c50d59dfd5c4973474da43a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 24 Nov 2026 16:45:11 +0200 Subject: [PATCH 2/3] Wait for the XML language server before editing in TestXML AllCleanRule shuts down all language servers around each test, so every diagnostics test in TestXML starts a fresh LemMinX process. The 5s wait for markers had to cover the server startup and initialization too, and on loaded CI machines that sometimes did not finish in time. Add a waitForLanguageServer helper that waits until the language server for the document is started and initialized before the document is edited, so that the 5s wait only covers validation and marker creation. Assisted-by: Anthropic Claude Code (claude-opus-5-5) --- .../wildwebdeveloper/tests/TestXML.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java b/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java index 3d8c2dda44..194d6a24eb 100644 --- a/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java +++ b/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java @@ -24,6 +24,8 @@ import java.util.HashMap; import java.util.List; import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.stream.Collectors; @@ -41,7 +43,9 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.lsp4e.LanguageServers; import org.eclipse.lsp4e.operations.completion.LSContentAssistProcessor; +import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.ide.IDE; @@ -70,12 +74,20 @@ public void setUpProject() throws CoreException { project.open(null); } + private static void waitForLanguageServer(IDocument document) throws Exception { + List servers = LanguageServers.forDocument(document) + .collectAll(ls -> CompletableFuture.completedFuture(ls)).get(5, TimeUnit.SECONDS); + assertFalse(servers.isEmpty(), "No language server started for the document"); + } + @Test public void testXMLFile() throws Exception { final IFile file = project.getFile("blah.xml"); file.create("FAIL".getBytes(), true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); - editor.getDocumentProvider().getDocument(editor.getEditorInput()).set(" { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; @@ -90,7 +102,9 @@ public void testXSLFile() throws Exception { final IFile file = project.getFile("blah.xsl"); file.create(new byte[0], true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); - editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("FAIL"); + IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); + waitForLanguageServer(document); + document.set("FAIL"); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; @@ -105,7 +119,9 @@ public void testXSDFile() throws Exception { final IFile file = project.getFile("blah.xsd"); file.create(new byte[0], true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); - editor.getDocumentProvider().getDocument(editor.getEditorInput()).set("a<"); + IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); + waitForLanguageServer(document); + document.set("a<"); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; @@ -120,7 +136,9 @@ public void testDTDFile() throws Exception { final IFile file = project.getFile("blah.dtd"); file.create("FAIL".getBytes(), true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); - editor.getDocumentProvider().getDocument(editor.getEditorInput()).set(""); + IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); + waitForLanguageServer(document); + document.set(""); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { try { return file.findMarkers("org.eclipse.lsp4e.diagnostic", true, IResource.DEPTH_ZERO).length != 0; From 7e9ca5b543f570bb5aeb72f5bf3c830b29a76a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=8A?= =?UTF-8?q?=D1=80=20=D0=9A=D1=83=D1=80=D1=82=D0=B0=D0=BA=D0=BE=D0=B2?= Date: Tue, 24 Nov 2026 17:29:03 +0200 Subject: [PATCH 3/3] Wait for the document to be parsed before editing in TestXML LemMinX can end up with a stale model when an edit arrives while it is still parsing the content sent with didOpen: no diagnostics are then published for the edited content and the tests time out waiting for markers. Replace the wait for the server start with a documentSymbol request, which only completes once LemMinX has parsed the opened document, so the following edit cannot race with that parse. Assisted-by: Anthropic Claude Code (claude-opus-5-5) --- .../wildwebdeveloper/tests/TestXML.java | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java b/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java index 194d6a24eb..7f9eb162e7 100644 --- a/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java +++ b/org.eclipse.wildwebdeveloper.tests/src/org/eclipse/wildwebdeveloper/tests/TestXML.java @@ -24,7 +24,6 @@ import java.util.HashMap; import java.util.List; import java.util.concurrent.Callable; -import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; @@ -43,9 +42,12 @@ import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.lsp4e.LSPEclipseUtils; import org.eclipse.lsp4e.LanguageServers; import org.eclipse.lsp4e.operations.completion.LSContentAssistProcessor; -import org.eclipse.lsp4j.services.LanguageServer; +import org.eclipse.lsp4j.DocumentSymbolParams; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.ui.ide.IDE; @@ -74,10 +76,17 @@ public void setUpProject() throws CoreException { project.open(null); } - private static void waitForLanguageServer(IDocument document) throws Exception { - List servers = LanguageServers.forDocument(document) - .collectAll(ls -> CompletableFuture.completedFuture(ls)).get(5, TimeUnit.SECONDS); - assertFalse(servers.isEmpty(), "No language server started for the document"); + /** + * Waits until the language server has parsed the document as opened, so that + * a following edit does not race with the parse triggered by didOpen (which + * can leave LemMinX with a stale model and no diagnostics for the edit). + */ + private static void waitForDocumentParsed(IDocument document) throws Exception { + assertFalse(LanguageServers.forDocument(document) // + .withCapability(ServerCapabilities::getDocumentSymbolProvider) // + .collectAll(ls -> ls.getTextDocumentService().documentSymbol(new DocumentSymbolParams( + new TextDocumentIdentifier(LSPEclipseUtils.toUri(document).toString())))) // + .get(5, TimeUnit.SECONDS).isEmpty(), "No language server answered for the document"); } @Test @@ -86,7 +95,7 @@ public void testXMLFile() throws Exception { file.create("FAIL".getBytes(), true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); - waitForLanguageServer(document); + waitForDocumentParsed(document); document.set(" { try { @@ -103,7 +112,7 @@ public void testXSLFile() throws Exception { file.create(new byte[0], true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); - waitForLanguageServer(document); + waitForDocumentParsed(document); document.set("FAIL"); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { try { @@ -120,7 +129,7 @@ public void testXSDFile() throws Exception { file.create(new byte[0], true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); - waitForLanguageServer(document); + waitForDocumentParsed(document); document.set("a<"); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { try { @@ -137,7 +146,7 @@ public void testDTDFile() throws Exception { file.create("FAIL".getBytes(), true, false, null); ITextEditor editor = (ITextEditor) IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file); IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); - waitForLanguageServer(document); + waitForDocumentParsed(document); document.set(""); assertTrue(DisplayHelper.waitForCondition(PlatformUI.getWorkbench().getDisplay(), 5000, () -> { try {