diff --git a/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF b/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF index a6b57c107..ac0147c2f 100644 --- a/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF +++ b/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF @@ -3,16 +3,16 @@ Bundle-ManifestVersion: 2 Bundle-Name: Debug Adapter client for Eclipse IDE (Incubation) Bundle-SymbolicName: org.eclipse.lsp4e.debug;singleton:=true Bundle-Vendor: Eclipse LSP4E -Bundle-Version: 0.16.1.qualifier +Bundle-Version: 0.16.2.qualifier Bundle-Activator: org.eclipse.lsp4e.debug.DSPPlugin Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.debug.core, org.eclipse.debug.ui, org.eclipse.jface, - org.eclipse.lsp4j.jsonrpc;bundle-version="[0.24.0,0.25.0)", - org.eclipse.lsp4j.jsonrpc.debug;bundle-version="[0.24.0,0.25.0)", - org.eclipse.lsp4j.debug;bundle-version="[0.24.0,0.25.0)", + org.eclipse.lsp4j.jsonrpc;bundle-version="[1.0.0,2.0.0)", + org.eclipse.lsp4j.jsonrpc.debug;bundle-version="[1.0.0,2.0.0)", + org.eclipse.lsp4j.debug;bundle-version="[1.0.0,2.0.0)", org.eclipse.ui.editors, org.eclipse.core.filesystem, org.eclipse.ui.ide;bundle-version="[3.16.0,4.0.0)", diff --git a/org.eclipse.lsp4e.test/META-INF/MANIFEST.MF b/org.eclipse.lsp4e.test/META-INF/MANIFEST.MF index 6369d95b0..4bdbc8c30 100644 --- a/org.eclipse.lsp4e.test/META-INF/MANIFEST.MF +++ b/org.eclipse.lsp4e.test/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Tests for language server bundle (Incubation) Bundle-SymbolicName: org.eclipse.lsp4e.test;singleton:=true -Bundle-Version: 0.16.4.qualifier +Bundle-Version: 0.16.5.qualifier Fragment-Host: org.eclipse.lsp4e Bundle-Vendor: Eclipse LSP4E Bundle-RequiredExecutionEnvironment: JavaSE-21 diff --git a/org.eclipse.lsp4e.test/pom.xml b/org.eclipse.lsp4e.test/pom.xml index c87cf3093..50051a8b9 100644 --- a/org.eclipse.lsp4e.test/pom.xml +++ b/org.eclipse.lsp4e.test/pom.xml @@ -8,7 +8,7 @@ org.eclipse.lsp4e.test eclipse-test-plugin - 0.16.4-SNAPSHOT + 0.16.5-SNAPSHOT diff --git a/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/diagnostics/DiagnosticsTest.java b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/diagnostics/DiagnosticsTest.java index f6674f003..40dcaddac 100644 --- a/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/diagnostics/DiagnosticsTest.java +++ b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/diagnostics/DiagnosticsTest.java @@ -13,12 +13,10 @@ *******************************************************************************/ package org.eclipse.lsp4e.test.diagnostics; -import static org.eclipse.lsp4e.test.utils.TestUtils.waitForAndAssertCondition; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.eclipse.lsp4e.test.utils.TestUtils.*; +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.MatcherAssert.*; +import static org.junit.jupiter.api.Assertions.*; import java.io.File; import java.io.FileOutputStream; @@ -106,7 +104,7 @@ public void testDiagnostics() throws CoreException { assertEquals(markerCharStart, MarkerUtilities.getCharStart(marker.get())); assertEquals(markerCharEnd, MarkerUtilities.getCharEnd(marker.get())); assertEquals(markerLineIndex + 1, MarkerUtilities.getLineNumber(marker.get())); - assertEquals(diagnostic.getMessage() + " [" + diagnostic.getCode().get() + "]", + assertEquals(diagnostic.getMessage().getLeft() + " [" + diagnostic.getCode().get() + "]", MarkerUtilities.getMessage(marker.get())); } @@ -232,7 +230,7 @@ public void testDiagnosticsRangeAfterDocument() throws CoreException { Diagnostic diagnostic = diagnostics.get(i); IMarker marker = markers[i]; - assertEquals(diagnostic.getMessage() + " [" + diagnostic.getCode().get() + "]", + assertEquals(diagnostic.getMessage().getLeft() + " [" + diagnostic.getCode().get() + "]", MarkerUtilities.getMessage(marker)); assertEquals(content.length(), MarkerUtilities.getCharStart(marker)); assertEquals(content.length(), MarkerUtilities.getCharEnd(marker)); diff --git a/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/edit/LSPEclipseUtilsTest.java b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/edit/LSPEclipseUtilsTest.java index 51c70f724..7304ff251 100644 --- a/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/edit/LSPEclipseUtilsTest.java +++ b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/edit/LSPEclipseUtilsTest.java @@ -13,12 +13,8 @@ *******************************************************************************/ package org.eclipse.lsp4e.test.edit; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -138,8 +134,9 @@ public void testWorkspaceEdit_CreateAndPopulateFile() throws Exception { String uri = file.getLocation().toFile().toURI().toString(); edits.add(Either.forRight(new CreateFile(uri))); edits.add(Either.forLeft( - new TextDocumentEdit(new VersionedTextDocumentIdentifier(uri, null), List.of( - new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), "abcHere\nabcHere2"))))); + new TextDocumentEdit(new VersionedTextDocumentIdentifier(uri, null), + List.of(Either.forLeft( + new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), "abcHere\nabcHere2")))))); final var workspaceEdit = new WorkspaceEdit(edits); // they should be applied from bottom to top LSPEclipseUtils.applyWorkspaceEdit(workspaceEdit); @@ -358,8 +355,8 @@ public void testResourceOperations() throws Exception { assertTrue(targetFile.exists()); LSPEclipseUtils.applyWorkspaceEdit(new WorkspaceEdit(List.of(Either.forLeft( new TextDocumentEdit(new VersionedTextDocumentIdentifier(targetFile.getLocationURI().toString(), 1), - List.of( - new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), "hello"))))))); + List.of(Either.forLeft( + new TextEdit(new Range(new Position(0, 0), new Position(0, 0)), "hello")))))))); assertEquals("hello", readContent(targetFile)); IFile otherFile = project.getFile("another/folder/file.lol"); LSPEclipseUtils.applyWorkspaceEdit(new WorkspaceEdit(List.of(Either.forRight( @@ -388,7 +385,7 @@ public void editExternalFile() throws Exception { te.setNewText("abc\ndef"); final var docEdit = new TextDocumentEdit( new VersionedTextDocumentIdentifier(file.toURI().toString(), null), - List.of(te)); + List.of(Either.forLeft(te))); final var we = new WorkspaceEdit(List.of(Either.forLeft(docEdit))); LSPEclipseUtils.applyWorkspaceEdit(we); assertTrue(file.isFile()); @@ -428,7 +425,7 @@ public void testTextEditDoesntAutomaticallySaveOpenResourceFiles() throws Except te.setNewText("abc\ndef"); final var docEdit = new TextDocumentEdit( new VersionedTextDocumentIdentifier(LSPEclipseUtils.toUri(targetFile).toString(), null), - List.of(te)); + List.of(Either.forLeft(te))); final var we = new WorkspaceEdit(List.of(Either.forLeft(docEdit))); LSPEclipseUtils.applyWorkspaceEdit(we); assertEquals("abc\ndef", ((StyledText) ((AbstractTextEditor) editor).getAdapter(Control.class)).getText()); @@ -444,7 +441,7 @@ public void testTextEditDoesntAutomaticallySaveOpenExternalFiles() throws Except te.setNewText("abc\ndef"); final var docEdit = new TextDocumentEdit( new VersionedTextDocumentIdentifier(file.toURI().toString(), null), - List.of(te)); + List.of(Either.forLeft(te))); final var we = new WorkspaceEdit(List.of(Either.forLeft(docEdit))); LSPEclipseUtils.applyWorkspaceEdit(we); assertEquals("abc\ndef", ((StyledText) ((AbstractTextEditor) editor).getAdapter(Control.class)).getText()); diff --git a/org.eclipse.lsp4e/META-INF/MANIFEST.MF b/org.eclipse.lsp4e/META-INF/MANIFEST.MF index 40bfd4fef..8974d720c 100644 --- a/org.eclipse.lsp4e/META-INF/MANIFEST.MF +++ b/org.eclipse.lsp4e/META-INF/MANIFEST.MF @@ -28,8 +28,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0", org.eclipse.tm4e.ui;resolution:=optional, org.eclipse.ui.editors, org.eclipse.ui.navigator;bundle-version="3.6.100", - org.eclipse.lsp4j;bundle-version="[0.24.0,0.25.0)", - org.eclipse.lsp4j.jsonrpc;bundle-version="[0.24.0,0.25.0)", + org.eclipse.lsp4j;bundle-version="[1.0.0,2.0.0)", + org.eclipse.lsp4j.jsonrpc;bundle-version="[1.0.0,2.0.0)", org.eclipse.ui.console, org.eclipse.ltk.core.refactoring, org.eclipse.core.expressions;bundle-version="3.5.0", diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/IMarkerAttributeComputer.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/IMarkerAttributeComputer.java index 90c4ea3dc..805fc07bf 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/IMarkerAttributeComputer.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/IMarkerAttributeComputer.java @@ -16,6 +16,7 @@ import org.eclipse.core.resources.IResource; import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jface.text.IDocument; +import org.eclipse.lsp4e.internal.NullSafetyHelper; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.jsonrpc.messages.Either; @@ -48,8 +49,9 @@ void addMarkerAttributesForDiagnostic(Diagnostic diagnostic, @Nullable IDocument */ default String computeMarkerMessage(Diagnostic diagnostic) { final Either code = diagnostic.getCode(); + String messageText = NullSafetyHelper.defaultIfNull(diagnostic.getMessage().getLeft(), ""); //$NON-NLS-1$ return code == null // - ? diagnostic.getMessage() - : diagnostic.getMessage() + " [" + code.get() + "]"; //$NON-NLS-1$//$NON-NLS-2$ + ? messageText + : messageText + " [" + code.get() + "]"; //$NON-NLS-1$//$NON-NLS-2$ } } diff --git a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LSPEclipseUtils.java b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LSPEclipseUtils.java index 7270449ba..6f41a4c29 100644 --- a/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LSPEclipseUtils.java +++ b/org.eclipse.lsp4e/src/org/eclipse/lsp4e/LSPEclipseUtils.java @@ -21,7 +21,7 @@ *******************************************************************************/ package org.eclipse.lsp4e; -import static org.eclipse.lsp4e.internal.NullSafetyHelper.castNonNull; +import static org.eclipse.lsp4e.internal.NullSafetyHelper.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -121,6 +121,7 @@ import org.eclipse.lsp4j.RenameFile; import org.eclipse.lsp4j.ResourceOperation; import org.eclipse.lsp4j.SignatureHelpParams; +import org.eclipse.lsp4j.SnippetTextEdit; import org.eclipse.lsp4j.TextDocumentEdit; import org.eclipse.lsp4j.TextDocumentIdentifier; import org.eclipse.lsp4j.TextDocumentPositionParams; @@ -1078,7 +1079,8 @@ private static boolean applyWorkspaceEditIfSingleOpenFile(WorkspaceEdit wsEdit) .map(TextDocumentIdentifier::getUri) .map(LSPEclipseUtils::toUri) .forEach(documentUris::add); - firstDocumentEdits.addAll(wsEdit.getDocumentChanges().get(0).getLeft().getEdits()); + firstDocumentEdits.addAll(toTextEditList( + wsEdit.getDocumentChanges().get(0).getLeft().getEdits())); } } if (documentUris.size() != 1 || firstDocumentEdits.isEmpty()) { @@ -1140,7 +1142,7 @@ private static CompositeChange toCompositeChange(WorkspaceEdit wsEdit, String na TextDocumentEdit edit = action.getLeft(); VersionedTextDocumentIdentifier id = edit.getTextDocument(); URI uri = URI.create(id.getUri()); - List textEdits = edit.getEdits(); + List textEdits = toTextEditList(edit.getEdits()); change.add(toChanges(uri, textEdits)); collectChangedURI(uri, textEdits, collector); } else if (action.isRight()) { @@ -1238,6 +1240,13 @@ private static CompositeChange toCompositeChange(WorkspaceEdit wsEdit, String na return change; } + private static final List toTextEditList(List> textEdits) { + return textEdits.stream() + .filter(e -> e.isLeft()) + .map(e -> e.getLeft()) + .toList(); + } + private static final Range DEFAULT_RANGE = new Range(new Position(0, 0), new Position(0, 0)); /** diff --git a/target-platforms/target-platform-latest/target-platform-latest.target b/target-platforms/target-platform-latest/target-platform-latest.target index 50626e37e..945b99d33 100644 --- a/target-platforms/target-platform-latest/target-platform-latest.target +++ b/target-platforms/target-platform-latest/target-platform-latest.target @@ -8,7 +8,7 @@ - +