Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to lsp4j 0.11.0 #574

Merged
merged 1 commit into from
Mar 31, 2021
Merged
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
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jacoco.version>0.8.6</jacoco.version>
<lsp4j.version>0.10.0</lsp4j.version>
<lsp4j.version>0.11.0</lsp4j.version>
<slf4j.version>1.7.30</slf4j.version>
<junit.version>5.7.1</junit.version>
<assertj.version>3.19.0</assertj.version>
Expand All @@ -54,7 +54,7 @@
<camel.quarkus.version>1.7.0</camel.quarkus.version>
<roaster.version>2.21.1.Final</roaster.version>
<awaitility.version>4.0.3</awaitility.version>
<tyrus.version>1.17</tyrus.version>
<tyrus.version>2.0.0</tyrus.version>
<commons-text.version>1.9</commons-text.version>
</properties>

Expand Down Expand Up @@ -225,7 +225,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.lsp4j</groupId>
<artifactId>org.eclipse.lsp4j.websocket</artifactId>
<artifactId>org.eclipse.lsp4j.websocket.jakarta</artifactId>
<version>${lsp4j.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextDocumentItem;
import org.eclipse.lsp4j.TextEdit;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.w3c.dom.Node;

import com.github.cameltooling.lsp.internal.instancemodel.CamelURIInstance;
Expand All @@ -53,9 +54,9 @@ public static void applyTextEditToCompletionItem(ILineRangeDefineable lineRangeD

// replace instead of insert
if(item.getInsertText() != null) {
item.setTextEdit(new TextEdit(range, item.getInsertText()));
item.setTextEdit(Either.forLeft(new TextEdit(range, item.getInsertText())));
} else {
item.setTextEdit(new TextEdit(range, item.getLabel()));
item.setTextEdit(Either.forLeft(new TextEdit(range, item.getLabel())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.eclipse.lsp4j.Range;
import org.eclipse.lsp4j.TextDocumentItem;
import org.eclipse.lsp4j.TextEdit;
import org.eclipse.lsp4j.jsonrpc.messages.Either;

import com.github.cameltooling.lsp.internal.catalog.util.CamelKafkaConnectorCatalogManager;
import com.github.cameltooling.lsp.internal.catalog.util.StringUtils;
Expand Down Expand Up @@ -93,7 +94,7 @@ public CompletableFuture<List<CompletionItem>> getCompletions(Position position,
CompletionItem completionItem = new CompletionItem("camel");
String insertText = indexOfFirstDot != -1 ? "camel" : CAMEL_KEY_PREFIX;
completionItem.setInsertText(insertText);
completionItem.setTextEdit(new TextEdit(new Range(new Position(getLine(), getStartPositionInLine()), new Position(getLine(), indexOfFirstDot != -1 ? getStartPositionInLine() + indexOfFirstDot : getEndPositionInLine())), insertText));
completionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(getLine(), getStartPositionInLine()), new Position(getLine(), indexOfFirstDot != -1 ? getStartPositionInLine() + indexOfFirstDot : getEndPositionInLine())), insertText)));
return CompletableFuture.completedFuture(Collections.singletonList(completionItem));
} else if (isBetweenFirstAndSecondDotOfCamelPropertyKey(position, indexOfSecondDot)) {
return getTopLevelCamelCompletion(camelCatalog,camelKafkaConnectorManager, indexOfSecondDot, position.getCharacter());
Expand Down Expand Up @@ -141,7 +142,7 @@ private CompletionItem createCompletionItemForCamelComponent(int indexOfSecondDo
Position end = new Position(getLine(), indexOfSecondDot != -1 ? getStartPositionInLine() + indexOfSecondDot : getEndPositionInLine());
Range range = new Range(start, end);
TextEdit textEdit = new TextEdit(range, insertText);
completionItem.setTextEdit(textEdit);
completionItem.setTextEdit(Either.forLeft(textEdit));
return completionItem;
}

Expand All @@ -155,7 +156,7 @@ private List<CompletionItem> createGroupCompletionFromMainModel(MainModel mainMo
Position start = new Position(getLine(), getStartPositionInLine() + CAMEL_KEY_PREFIX.length());
Position end = new Position(getLine(), indexOfSecondDot != -1 ? getStartPositionInLine() + indexOfSecondDot : getEndPositionInLine());
Range range = new Range(start, end);
completionItem.setTextEdit(new TextEdit(range, insertText));
completionItem.setTextEdit(Either.forLeft(new TextEdit(range, insertText)));
return completionItem;
}).collect(Collectors.toList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.eclipse.lsp4j.jsonrpc.Launcher.Builder;
import org.eclipse.lsp4j.services.LanguageClient;
import org.eclipse.lsp4j.services.LanguageClientAware;
import org.eclipse.lsp4j.websocket.WebSocketEndpoint;
import org.eclipse.lsp4j.websocket.jakarta.WebSocketEndpoint;

import com.github.cameltooling.lsp.internal.CamelLanguageServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.util.Collections;
import java.util.Set;

import javax.websocket.Endpoint;
import javax.websocket.server.ServerApplicationConfig;
import javax.websocket.server.ServerEndpointConfig;
import jakarta.websocket.Endpoint;
import jakarta.websocket.server.ServerApplicationConfig;
import jakarta.websocket.server.ServerEndpointConfig;

public class CamelLSPWebSocketServerConfigProvider implements ServerApplicationConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
package com.github.cameltooling.lsp.internal.websocket;

import javax.websocket.DeploymentException;
import jakarta.websocket.DeploymentException;

import org.glassfish.tyrus.server.Server;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected CompletionItem createExpectedAhcCompletionItem(int lineStart, int char
CompletionItem expectedAhcCompletioncompletionItem = new CompletionItem("ahc:httpUri");
expectedAhcCompletioncompletionItem.setDocumentation(AHC_DOCUMENTATION);
expectedAhcCompletioncompletionItem.setDeprecated(false);
expectedAhcCompletioncompletionItem.setTextEdit(new TextEdit(new Range(new Position(lineStart, characterStart), new Position(lineEnd, characterEnd)), "ahc:httpUri"));
expectedAhcCompletioncompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(lineStart, characterStart), new Position(lineEnd, characterEnd)), "ahc:httpUri")));
return expectedAhcCompletioncompletionItem;
}

Expand Down Expand Up @@ -250,7 +250,7 @@ public File getTestResource(String name) throws URISyntaxException {
}

protected boolean hasTextEdit(CompletionItem item) {
return item != null && item.getTextEdit() != null;
return item != null && item.getTextEdit().getLeft() != null;
}

protected Map<Object, Object> createMapSettingsWithComponent(String component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private CompletionItem createExpectedExtraComponentCompletionItem(int lineStart,
CompletionItem expectedAhcCompletioncompletionItem = new CompletionItem(syntax);
expectedAhcCompletioncompletionItem.setDocumentation(description);
expectedAhcCompletioncompletionItem.setDeprecated(false);
expectedAhcCompletioncompletionItem.setTextEdit(new TextEdit(new Range(new Position(lineStart, characterStart), new Position(lineEnd, characterEnd)), syntax));
expectedAhcCompletioncompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(lineStart, characterStart), new Position(lineEnd, characterEnd)), syntax)));
return expectedAhcCompletioncompletionItem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void testProvideCompletionForYamlOnRealFileWithCamelKCloseToModelineWithURIConta
expectedanyOrderAttributeCompletionItem.setDeprecated(false);
expectedanyOrderAttributeCompletionItem.setDetail("boolean");
expectedanyOrderAttributeCompletionItem.setInsertText("anyOrder=false");
expectedanyOrderAttributeCompletionItem.setTextEdit(new TextEdit(new Range(new Position(12, 47), new Position(12, 47)), "anyOrder=false"));
expectedanyOrderAttributeCompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(12, 47), new Position(12, 47)), "anyOrder=false")));
expectedanyOrderAttributeCompletionItem.setKind(CompletionItemKind.Property);
assertThat(completions.get().getLeft()).contains(expectedanyOrderAttributeCompletionItem);
}
Expand All @@ -235,7 +235,7 @@ void testProvideCompletionForYamlOnRealFileWithCamelKCloseToModelineWithURIConta
expectedanyOrderAttributeCompletionItem.setDeprecated(false);
expectedanyOrderAttributeCompletionItem.setDetail("boolean");
expectedanyOrderAttributeCompletionItem.setInsertText("anyOrder=false");
expectedanyOrderAttributeCompletionItem.setTextEdit(new TextEdit(new Range(new Position(12, 46), new Position(12, 46)), "anyOrder=false"));
expectedanyOrderAttributeCompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(12, 46), new Position(12, 46)), "anyOrder=false")));
expectedanyOrderAttributeCompletionItem.setKind(CompletionItemKind.Property);
assertThat(completions.get().getLeft()).contains(expectedanyOrderAttributeCompletionItem);
}
Expand All @@ -253,7 +253,7 @@ void testProvideCompletionForYamlOnRealFileWithCamelKCloseToModelineWithURIConta
expectedanyOrderAttributeCompletionItem.setDeprecated(false);
expectedanyOrderAttributeCompletionItem.setDetail("boolean");
expectedanyOrderAttributeCompletionItem.setInsertText("anyOrder=false");
expectedanyOrderAttributeCompletionItem.setTextEdit(new TextEdit(new Range(new Position(12, 47), new Position(12, 47)), "anyOrder=false"));
expectedanyOrderAttributeCompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(12, 47), new Position(12, 47)), "anyOrder=false")));
expectedanyOrderAttributeCompletionItem.setKind(CompletionItemKind.Property);
assertThat(completions.get().getLeft()).contains(expectedanyOrderAttributeCompletionItem);
}
Expand All @@ -271,7 +271,7 @@ void testProvideCompletionForYamlOnRealFileWithCamelKCloseToModelineWithURIConta
expectedanyOrderAttributeCompletionItem.setDeprecated(false);
expectedanyOrderAttributeCompletionItem.setDetail("boolean");
expectedanyOrderAttributeCompletionItem.setInsertText("anyOrder=false");
expectedanyOrderAttributeCompletionItem.setTextEdit(new TextEdit(new Range(new Position(12, 45), new Position(12, 45)), "anyOrder=false"));
expectedanyOrderAttributeCompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(12, 45), new Position(12, 45)), "anyOrder=false")));
expectedanyOrderAttributeCompletionItem.setKind(CompletionItemKind.Property);
assertThat(completions.get().getLeft()).contains(expectedanyOrderAttributeCompletionItem);
}
Expand All @@ -289,7 +289,7 @@ void testProvideCompletionForYamlOnRealFileWithCamelKCloseToModelineWithURIConta
expectedanyOrderAttributeCompletionItem.setDeprecated(false);
expectedanyOrderAttributeCompletionItem.setDetail("boolean");
expectedanyOrderAttributeCompletionItem.setInsertText("anyOrder=false");
expectedanyOrderAttributeCompletionItem.setTextEdit(new TextEdit(new Range(new Position(12, 45), new Position(12, 45)), "anyOrder=false"));
expectedanyOrderAttributeCompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(12, 45), new Position(12, 45)), "anyOrder=false")));
expectedanyOrderAttributeCompletionItem.setKind(CompletionItemKind.Property);
assertThat(completions.get().getLeft()).contains(expectedanyOrderAttributeCompletionItem);
}
Expand All @@ -307,7 +307,7 @@ void testProvideCompletionForYamlOnRealFileWithCamelKCloseToModelineWithURIConta
expectedanyOrderAttributeCompletionItem.setDeprecated(false);
expectedanyOrderAttributeCompletionItem.setDetail("boolean");
expectedanyOrderAttributeCompletionItem.setInsertText("anyOrder=false");
expectedanyOrderAttributeCompletionItem.setTextEdit(new TextEdit(new Range(new Position(12, 50), new Position(12, 50)), "anyOrder=false"));
expectedanyOrderAttributeCompletionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(12, 50), new Position(12, 50)), "anyOrder=false")));
expectedanyOrderAttributeCompletionItem.setKind(CompletionItemKind.Property);
assertThat(completions.get().getLeft()).contains(expectedanyOrderAttributeCompletionItem);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import java.net.UnknownHostException;
import java.util.concurrent.CountDownLatch;

import javax.websocket.ClientEndpointConfig;
import javax.websocket.DeploymentException;
import javax.websocket.Endpoint;
import javax.websocket.EndpointConfig;
import javax.websocket.Session;
import jakarta.websocket.ClientEndpointConfig;
import jakarta.websocket.DeploymentException;
import jakarta.websocket.Endpoint;
import jakarta.websocket.EndpointConfig;
import jakarta.websocket.Session;

import org.glassfish.tyrus.client.ClientManager;
import org.junit.jupiter.api.AfterEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void testFetcher() throws Exception {
CompletionItem completionItemForPropertyFetcher = completions.get(0);
assertThat(completionItemForPropertyFetcher.getLabel()).isEqualTo("aPropertyFetcher");
assertThat(completionItemForPropertyFetcher.getKind()).isEqualTo(CompletionItemKind.Variable);
assertThat(completionItemForPropertyFetcher.getTextEdit().getRange()).isEqualTo(new Range(new Position(0, text.length()), new Position(0, text.length())));
assertThat(completionItemForPropertyFetcher.getTextEdit().getLeft().getRange()).isEqualTo(new Range(new Position(0, text.length()), new Position(0, text.length())));
}

@Test
Expand Down Expand Up @@ -201,9 +201,9 @@ void testApiName() throws Exception {
CompletionItem accountCompletionItem = completions.get(0);
assertThat(accountCompletionItem.getLabel()).isEqualTo("account");
assertThat(accountCompletionItem.getInsertText()).isEqualTo("account");
assertThat(accountCompletionItem.getTextEdit().getNewText()).isEqualTo("account");
assertThat(accountCompletionItem.getTextEdit().getLeft().getNewText()).isEqualTo("account");
Range expectedRange = new Range(new Position(0, text.length() -1), new Position(0, text.length()));
assertThat(accountCompletionItem.getTextEdit().getRange()).isEqualTo(expectedRange);
assertThat(accountCompletionItem.getTextEdit().getLeft().getRange()).isEqualTo(expectedRange);
}

@Test
Expand All @@ -215,9 +215,9 @@ void testWithPartialMethodName() throws Exception {
CompletionItem accountCompletionItem = completions.get(0);
assertThat(accountCompletionItem.getLabel()).isEqualTo("fetch");
assertThat(accountCompletionItem.getInsertText()).isEqualTo("fetch");
assertThat(accountCompletionItem.getTextEdit().getNewText()).isEqualTo("fetch");
assertThat(accountCompletionItem.getTextEdit().getLeft().getNewText()).isEqualTo("fetch");
Range expectedRange = new Range(new Position(0, text.length() -1), new Position(0, text.length()));
assertThat(accountCompletionItem.getTextEdit().getRange()).isEqualTo(expectedRange);
assertThat(accountCompletionItem.getTextEdit().getLeft().getRange()).isEqualTo(expectedRange);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void testComponent() throws Exception {
List<CompletionItem> items = completions.get().getLeft();
assertThat(items).hasSize(2);
for (CompletionItem completionItem : items) {
TextEdit textEdit = completionItem.getTextEdit();
TextEdit textEdit = completionItem.getTextEdit().getLeft();
Range range = textEdit.getRange();
assertThat(range.getStart().getLine()).isZero();
assertThat(range.getStart().getCharacter()).isEqualTo(11 /*start of URI */);
Expand All @@ -59,7 +59,7 @@ void testAttribute() throws Exception {
List<CompletionItem> items = completions.get().getLeft();
assertThat(items).hasSize(13);
for (CompletionItem completionItem : items) {
TextEdit textEdit = completionItem.getTextEdit();
TextEdit textEdit = completionItem.getTextEdit().getLeft();
Range range = textEdit.getRange();
assertThat(range.getStart().getLine()).isZero();
assertThat(range.getStart().getCharacter()).isEqualTo(45 /* just before 'bufferSize' */);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void testProvideCamelOptions(String textTotest, int line, int character)

private CompletionItem createExpectedCompletionItem(String enumOption) {
CompletionItem completionItem = new CompletionItem(enumOption);
completionItem.setTextEdit(new TextEdit(new Range(new Position(0, 43), new Position(0, 43)), enumOption));
completionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(0, 43), new Position(0, 43)), enumOption)));
return completionItem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void testProvideCamelOptions() throws Exception {
void testProvideCamelOptionsForConsumerOnly() throws Exception {
CompletionItem completionItem = new CompletionItem("bridgeErrorHandler");
completionItem.setInsertText("bridgeErrorHandler=false");
completionItem.setTextEdit(new TextEdit(new Range(new Position(0, 27), new Position(0, 27)), "bridgeErrorHandler=false"));
completionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(0, 27), new Position(0, 27)), "bridgeErrorHandler=false")));
completionItem.setDocumentation("Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.");
completionItem.setDetail("boolean");
completionItem.setDeprecated(false);
Expand All @@ -58,7 +58,7 @@ void testProvideCamelOptionsForConsumerOnly() throws Exception {
void testProvideCamelOptionsForConsumerOnlyForJava() throws Exception {
CompletionItem completionItem = new CompletionItem("bridgeErrorHandler");
completionItem.setInsertText("bridgeErrorHandler=false");
completionItem.setTextEdit(new TextEdit(new Range(new Position(0, 22), new Position(0, 22)), "bridgeErrorHandler=false"));
completionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(0, 22), new Position(0, 22)), "bridgeErrorHandler=false")));
completionItem.setDocumentation("Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored.");
completionItem.setDetail("boolean");
completionItem.setDeprecated(false);
Expand All @@ -70,7 +70,7 @@ void testProvideCamelOptionsForConsumerOnlyForJava() throws Exception {
void testProvideCamelOptionsForConsumerOrProducer() throws Exception {
CompletionItem completionItem = new CompletionItem("clientConfigOptions");
completionItem.setInsertText("clientConfigOptions=");
completionItem.setTextEdit(new TextEdit(new Range(new Position(0, 23), new Position(0, 23)), "clientConfigOptions="));
completionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(0, 23), new Position(0, 23)), "clientConfigOptions=")));
completionItem.setDocumentation("To configure the AsyncHttpClientConfig using the key/values from the Map.");
completionItem.setDetail("java.util.Map<java.lang.String, java.lang.Object>");
completionItem.setDeprecated(false);
Expand Down Expand Up @@ -98,7 +98,7 @@ private void testProvideCamelOptions(String textTotest, int line, int character,
private CompletionItem getBridgeEndpointExpectedCompletionItem(int startCharacter, int endCharacter) {
CompletionItem completionItem = new CompletionItem("bridgeEndpoint");
completionItem.setInsertText("bridgeEndpoint=false");
completionItem.setTextEdit(new TextEdit(new Range(new Position(0, startCharacter), new Position(0, endCharacter)), "bridgeEndpoint=false"));
completionItem.setTextEdit(Either.forLeft(new TextEdit(new Range(new Position(0, startCharacter), new Position(0, endCharacter)), "bridgeEndpoint=false")));
completionItem.setDocumentation("If the option is true, then the Exchange.HTTP_URI header is ignored, and use the endpoint's URI for request. You may also set the throwExceptionOnFailure to be false to let the AhcProducer send all the fault response back.");
completionItem.setDetail("boolean");
completionItem.setKind(CompletionItemKind.Property);
Expand Down
Loading