diff --git a/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF b/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF index a77333859..07daf9004 100644 --- a/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF +++ b/org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF @@ -10,9 +10,9 @@ Require-Bundle: org.eclipse.ui, 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/src/org/eclipse/lsp4e/test/diagnostics/DiagnosticsTest.java b/org.eclipse.lsp4e.test/src/org/eclipse/lsp4e/test/diagnostics/DiagnosticsTest.java index 01854edde..04cf29368 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.nio.file.Files; import java.nio.file.Path; @@ -107,7 +105,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())); } @@ -233,7 +231,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 8ef6c570d..40529c7aa 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( @@ -386,7 +383,7 @@ public void editExternalFile(@TempDir Path tempDir) 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(Files.isRegularFile(file)); @@ -425,7 +422,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()); @@ -441,7 +438,7 @@ public void testTextEditDoesntAutomaticallySaveOpenExternalFiles(@TempDir Path t 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 3a0df4ebd..ffe2dbf57 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 71b65da77..bbb13a983 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; @@ -120,6 +120,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; @@ -1093,7 +1094,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()) { @@ -1155,7 +1157,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()) { @@ -1253,6 +1255,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 02a28642f..3e98e4153 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 @@ - +