Skip to content
Draft
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
8 changes: 4 additions & 4 deletions org.eclipse.lsp4e.debug/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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.2.qualifier
Bundle-Version: 0.16.3.qualifier
Fragment-Host: org.eclipse.lsp4e
Bundle-Vendor: Eclipse LSP4E
Bundle-RequiredExecutionEnvironment: JavaSE-21
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>org.eclipse.lsp4e.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>0.16.2-SNAPSHOT</version>
<version>0.16.3-SNAPSHOT</version>

<properties>
<os-jvm-flags /> <!-- for the default case -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
}

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions org.eclipse.lsp4e/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Language Server Protocol client for Eclipse IDE (Incubation)
Bundle-SymbolicName: org.eclipse.lsp4e;singleton:=true
Bundle-Version: 0.19.2.qualifier
Bundle-Version: 0.19.3.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-21
Require-Bundle: org.eclipse.core.runtime;bundle-version="3.12.0",
org.eclipse.equinox.common;bundle-version="3.8.0",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<artifactId>org.eclipse.lsp4e</artifactId>
<packaging>eclipse-plugin</packaging>
<version>0.19.2-SNAPSHOT</version>
<version>0.19.3-SNAPSHOT</version>

<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -48,8 +49,9 @@ void addMarkerAttributesForDiagnostic(Diagnostic diagnostic, @Nullable IDocument
*/
default String computeMarkerMessage(Diagnostic diagnostic) {
final Either<String, Integer> 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$
}
}
15 changes: 12 additions & 3 deletions org.eclipse.lsp4e/src/org/eclipse/lsp4e/LSPEclipseUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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<TextEdit> textEdits = edit.getEdits();
List<TextEdit> textEdits = toTextEditList(edit.getEdits());
change.add(toChanges(uri, textEdits));
collectChangedURI(uri, textEdits, collector);
} else if (action.isRight()) {
Expand Down Expand Up @@ -1238,6 +1240,13 @@ private static CompositeChange toCompositeChange(WorkspaceEdit wsEdit, String na
return change;
}

private static final List<TextEdit> toTextEditList(List<Either<TextEdit, SnippetTextEdit>> 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));

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<unit id="org.eclipse.lsp4j.debug" version="0.0.0"/>
<unit id="org.eclipse.lsp4j.jsonrpc.debug" version="0.0.0"/>
<unit id="com.google.gson" version="0.0.0"/>
<repository location="https://download.eclipse.org/lsp4j/updates/releases/0.24.0/"/>
<repository location="https://download.eclipse.org/lsp4j/builds/main/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
<unit id="org.eclipse.ui.tests.harness" version="0.0.0"/>
Expand Down
Loading