Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1897 from eclipse/cd_lsp4j0130
Browse files Browse the repository at this point in the history
[#1793] update to lsp4j 0.13.0
  • Loading branch information
cdietrich authored May 20, 2022
2 parents cb0f2a0 + fedf312 commit b01959b
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 22 deletions.
4 changes: 2 additions & 2 deletions org.eclipse.xtext.ide.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
org.eclipse.core.runtime;bundle-version="3.13.0",
org.eclipse.xtext.ide,
org.junit;bundle-version="4.12.0",
org.eclipse.lsp4j;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
org.eclipse.lsp4j;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
org.eclipse.xtext.testlanguages,
org.eclipse.xtext.testlanguages.ide
Import-Package: org.apache.log4j;version="1.2.19"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -140,7 +140,7 @@ public void testMissingInitialize() throws Exception {
languageServer.definition(definitionParams).get();
Assert.fail("Expected a ResponseErrorException");
} catch (ExecutionException exception) {
Assert.assertEquals(ResponseErrorCode.serverNotInitialized.getValue(),
Assert.assertEquals(ResponseErrorCode.ServerNotInitialized.getValue(),
((ResponseErrorException) exception.getCause()).getResponseError().getCode());
}
}
Expand Down
4 changes: 2 additions & 2 deletions org.eclipse.xtext.ide/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
org.eclipse.xtend.lib,
org.eclipse.core.runtime;bundle-version="3.13.0";resolution:=optional;x-installation:=greedy,
org.eclipse.equinox.common;bundle-version="3.9.0",
org.eclipse.lsp4j;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
org.eclipse.lsp4j;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
org.eclipse.emf.ecore.change;bundle-version="[2.14.0,3)"
Import-Package: org.apache.log4j;version="1.2.19"
Export-Package: org.eclipse.xtext.ide;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
import org.eclipse.lsp4j.WorkspaceFolder;
import org.eclipse.lsp4j.WorkspaceFoldersOptions;
import org.eclipse.lsp4j.WorkspaceServerCapabilities;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.WorkspaceSymbolParams;
import org.eclipse.lsp4j.jsonrpc.Endpoint;
import org.eclipse.lsp4j.jsonrpc.json.JsonRpcMethod;
Expand Down Expand Up @@ -684,15 +685,15 @@ protected boolean isHierarchicalDocumentSymbolSupport() {
}

@Override
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
public CompletableFuture<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> symbol(WorkspaceSymbolParams params) {
return requestManager.runRead((cancelIndicator) -> symbol(params, cancelIndicator));
}

/**
* Compute the symbol information. Executed in a read request.
* @since 2.20
*/
protected List<? extends SymbolInformation> symbol(WorkspaceSymbolParams params, CancelIndicator cancelIndicator) {
protected Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> symbol(WorkspaceSymbolParams params, CancelIndicator cancelIndicator) {
return workspaceSymbolService.getSymbols(params.getQuery(), resourceAccess, workspaceManager.getIndex(),
cancelIndicator);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -240,7 +240,7 @@ protected void refreshWorkspaceConfig(CancelIndicator cancelIndicator) {
*/
protected IWorkspaceConfig getWorkspaceConfig() throws ResponseErrorException {
if (workspaceConfig == null) {
ResponseError error = new ResponseError(ResponseErrorCode.serverNotInitialized,
ResponseError error = new ResponseError(ResponseErrorCode.ServerNotInitialized,
"Workspace has not been initialized yet.", null);
throw new ResponseErrorException(error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.LinkedList;
import java.util.List;
import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
import org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess;
import org.eclipse.xtext.resource.IResourceDescription;
import org.eclipse.xtext.resource.IResourceDescriptions;
Expand All @@ -34,7 +36,7 @@ public class WorkspaceSymbolService {
@Inject
private OperationCanceledManager operationCanceledManager;

public List<? extends SymbolInformation> getSymbols(
public Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> getSymbols(
String query,
IResourceAccess resourceAccess,
IResourceDescriptions indexData,
Expand All @@ -51,7 +53,7 @@ public List<? extends SymbolInformation> getSymbols(
}
}
}
return result;
return Either.forLeft(result);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2016, 2021 TypeFox GmbH (http://www.typefox.io) and others.
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -92,6 +92,7 @@ import org.junit.jupiter.api.BeforeEach

import static extension org.eclipse.lsp4j.util.Ranges.containsRange
import static extension org.eclipse.xtext.util.Strings.*
import org.eclipse.lsp4j.WorkspaceSymbol

/**
* @author Sven Efftinge - Initial contribution and API
Expand Down Expand Up @@ -305,6 +306,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {

protected def dispatch String toExpectation(Position it) '''[«line», «character»]'''

@Deprecated
protected def dispatch String toExpectation(SymbolInformation it) '''
symbol "«name»" {
kind: «kind.value»
Expand All @@ -315,6 +317,16 @@ abstract class AbstractLanguageServerTest implements Endpoint {
}
'''
protected def dispatch String toExpectation(WorkspaceSymbol it) '''
symbol "«name»" {
kind: «kind.value»
location: «location.toExpectation»
«IF !containerName.nullOrEmpty»
container: "«containerName»"
«ENDIF»
}
'''
/**
* @since 2.16
*/
Expand Down Expand Up @@ -624,7 +636,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
if (configuration.getAssertSymbols !== null) {
configuration.getAssertSymbols.apply(symbols)
} else {
val unwrappedSymbols = symbols.map[if(hierarchicalDocumentSymbolSupport) getRight else getLeft]
val unwrappedSymbols = symbols.map[if (hierarchicalDocumentSymbolSupport) getRight else getLeft]
val String actualSymbols = unwrappedSymbols.toExpectation
assertEquals(getExpectedSymbols, actualSymbols)
}
Expand All @@ -637,8 +649,12 @@ abstract class AbstractLanguageServerTest implements Endpoint {
initializeContext(configuration)
val symbols = languageServer.symbol(new WorkspaceSymbolParams(query)).get
if (configuration.assertSymbols !== null) {
configuration.assertSymbols.apply(symbols)
if (configuration.assertSymbols !== null || configuration.assertWorkspaceSymbols !== null) {
if (symbols.isLeft) {
configuration.assertSymbols.apply(symbols.getLeft)
} else {
configuration.assertWorkspaceSymbols.apply(symbols.getRight)
}
} else {
val String actualSymbols = symbols.toExpectation
assertEquals(expectedSymbols, actualSymbols)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
import java.util.List;

import org.eclipse.lsp4j.SymbolInformation;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

public class WorkspaceSymbolConfiguration extends TextDocumentConfiguration {
private String query = "";

private String expectedSymbols = "";

@Deprecated
private Procedure1<? super List<? extends SymbolInformation>> assertSymbols = null;
private Procedure1<? super List<? extends WorkspaceSymbol>> assertWorkspaceSymbols = null;

public String getQuery() {
return query;
Expand All @@ -36,11 +39,27 @@ public void setExpectedSymbols(String expectedSymbols) {
this.expectedSymbols = expectedSymbols;
}

@Deprecated
public Procedure1<? super List<? extends SymbolInformation>> getAssertSymbols() {
return assertSymbols;
}

@Deprecated
public void setAssertSymbols(Procedure1<? super List<? extends SymbolInformation>> assertSymbols) {
this.assertSymbols = assertSymbols;
}

/**
* @since 2.27.0
*/
public Procedure1<? super List<? extends WorkspaceSymbol>> getAssertWorkspaceSymbols() {
return assertWorkspaceSymbols;
}

/**
* @since 2.27.0
*/
public void setAssertWorkspaceSymbols(Procedure1<? super List<? extends WorkspaceSymbol>> assertWorkspaceSymbols) {
this.assertWorkspaceSymbols = assertWorkspaceSymbols;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2016, 2021 TypeFox GmbH (http://www.typefox.io) and others.
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
Expand Down Expand Up @@ -81,6 +81,7 @@
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
import org.eclipse.lsp4j.WorkspaceEdit;
import org.eclipse.lsp4j.WorkspaceFolder;
import org.eclipse.lsp4j.WorkspaceSymbol;
import org.eclipse.lsp4j.WorkspaceSymbolParams;
import org.eclipse.lsp4j.jsonrpc.Endpoint;
import org.eclipse.lsp4j.jsonrpc.messages.Either;
Expand Down Expand Up @@ -519,6 +520,7 @@ protected String _toExpectation(final Position it) {
return _builder.toString();
}

@Deprecated
protected String _toExpectation(final SymbolInformation it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("symbol \"");
Expand Down Expand Up @@ -553,6 +555,40 @@ protected String _toExpectation(final SymbolInformation it) {
return _builder.toString();
}

protected String _toExpectation(final WorkspaceSymbol it) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("symbol \"");
String _name = it.getName();
_builder.append(_name);
_builder.append("\" {");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("kind: ");
int _value = it.getKind().getValue();
_builder.append(_value, " ");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("location: ");
String _expectation = this.toExpectation(it.getLocation());
_builder.append(_expectation, " ");
_builder.newLineIfNotEmpty();
{
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(it.getContainerName());
boolean _not = (!_isNullOrEmpty);
if (_not) {
_builder.append(" ");
_builder.append("container: \"");
String _containerName = it.getContainerName();
_builder.append(_containerName, " ");
_builder.append("\"");
_builder.newLineIfNotEmpty();
}
}
_builder.append("}");
_builder.newLine();
return _builder.toString();
}

/**
* @since 2.16
*/
Expand Down Expand Up @@ -1297,11 +1333,14 @@ protected void testSymbol(final Procedure1<? super WorkspaceSymbolConfiguration>
this.initializeContext(configuration);
String _query = configuration.getQuery();
WorkspaceSymbolParams _workspaceSymbolParams = new WorkspaceSymbolParams(_query);
final List<? extends SymbolInformation> symbols = this.languageServer.symbol(_workspaceSymbolParams).get();
Procedure1<? super List<? extends SymbolInformation>> _assertSymbols = configuration.getAssertSymbols();
boolean _tripleNotEquals = (_assertSymbols != null);
if (_tripleNotEquals) {
configuration.getAssertSymbols().apply(symbols);
final Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> symbols = this.languageServer.symbol(_workspaceSymbolParams).get();
if (((configuration.getAssertSymbols() != null) || (configuration.getAssertWorkspaceSymbols() != null))) {
boolean _isLeft = symbols.isLeft();
if (_isLeft) {
configuration.getAssertSymbols().apply(symbols.getLeft());
} else {
configuration.getAssertWorkspaceSymbols().apply(symbols.getRight());
}
} else {
final String actualSymbols = this.toExpectation(symbols);
this.assertEquals(configuration.getExpectedSymbols(), actualSymbols);
Expand Down Expand Up @@ -1524,6 +1563,8 @@ protected String toExpectation(final Object it) {
return _toExpectation((TextEdit)it);
} else if (it instanceof WorkspaceEdit) {
return _toExpectation((WorkspaceEdit)it);
} else if (it instanceof WorkspaceSymbol) {
return _toExpectation((WorkspaceSymbol)it);
} else if (it instanceof Either) {
return _toExpectation((Either<?, ?>)it);
} else {
Expand Down

0 comments on commit b01959b

Please sign in to comment.