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

Commit fedf312

Browse files
committed
[#1793] update to lsp4j 0.13.0
Signed-off-by: Christian Dietrich <[email protected]>
1 parent cb0f2a0 commit fedf312

File tree

9 files changed

+101
-22
lines changed

9 files changed

+101
-22
lines changed

org.eclipse.xtext.ide.tests/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
1414
org.eclipse.core.runtime;bundle-version="3.13.0",
1515
org.eclipse.xtext.ide,
1616
org.junit;bundle-version="4.12.0",
17-
org.eclipse.lsp4j;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
18-
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
17+
org.eclipse.lsp4j;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
18+
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
1919
org.eclipse.xtext.testlanguages,
2020
org.eclipse.xtext.testlanguages.ide
2121
Import-Package: org.apache.log4j;version="1.2.19"

org.eclipse.xtext.ide.tests/src/org/eclipse/xtext/ide/tests/server/ServerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2016, 2020 TypeFox GmbH (http://www.typefox.io) and others.
2+
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
33
* This program and the accompanying materials are made available under the
44
* terms of the Eclipse Public License 2.0 which is available at
55
* http://www.eclipse.org/legal/epl-2.0.
@@ -140,7 +140,7 @@ public void testMissingInitialize() throws Exception {
140140
languageServer.definition(definitionParams).get();
141141
Assert.fail("Expected a ResponseErrorException");
142142
} catch (ExecutionException exception) {
143-
Assert.assertEquals(ResponseErrorCode.serverNotInitialized.getValue(),
143+
Assert.assertEquals(ResponseErrorCode.ServerNotInitialized.getValue(),
144144
((ResponseErrorException) exception.getCause()).getResponseError().getCode());
145145
}
146146
}

org.eclipse.xtext.ide/META-INF/MANIFEST.MF

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Require-Bundle: org.eclipse.xtext;visibility:=reexport,
1111
org.eclipse.xtend.lib,
1212
org.eclipse.core.runtime;bundle-version="3.13.0";resolution:=optional;x-installation:=greedy,
1313
org.eclipse.equinox.common;bundle-version="3.9.0",
14-
org.eclipse.lsp4j;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
15-
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.12.0,0.13.0)";resolution:=optional,
14+
org.eclipse.lsp4j;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
15+
org.eclipse.lsp4j.jsonrpc;bundle-version="[0.13.0,0.14.0)";resolution:=optional,
1616
org.eclipse.emf.ecore.change;bundle-version="[2.14.0,3)"
1717
Import-Package: org.apache.log4j;version="1.2.19"
1818
Export-Package: org.eclipse.xtext.ide;

org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/LanguageServerImpl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
import org.eclipse.lsp4j.WorkspaceFolder;
9393
import org.eclipse.lsp4j.WorkspaceFoldersOptions;
9494
import org.eclipse.lsp4j.WorkspaceServerCapabilities;
95+
import org.eclipse.lsp4j.WorkspaceSymbol;
9596
import org.eclipse.lsp4j.WorkspaceSymbolParams;
9697
import org.eclipse.lsp4j.jsonrpc.Endpoint;
9798
import org.eclipse.lsp4j.jsonrpc.json.JsonRpcMethod;
@@ -684,15 +685,15 @@ protected boolean isHierarchicalDocumentSymbolSupport() {
684685
}
685686

686687
@Override
687-
public CompletableFuture<List<? extends SymbolInformation>> symbol(WorkspaceSymbolParams params) {
688+
public CompletableFuture<Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>>> symbol(WorkspaceSymbolParams params) {
688689
return requestManager.runRead((cancelIndicator) -> symbol(params, cancelIndicator));
689690
}
690691

691692
/**
692693
* Compute the symbol information. Executed in a read request.
693694
* @since 2.20
694695
*/
695-
protected List<? extends SymbolInformation> symbol(WorkspaceSymbolParams params, CancelIndicator cancelIndicator) {
696+
protected Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> symbol(WorkspaceSymbolParams params, CancelIndicator cancelIndicator) {
696697
return workspaceSymbolService.getSymbols(params.getQuery(), resourceAccess, workspaceManager.getIndex(),
697698
cancelIndicator);
698699
}

org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/WorkspaceManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016, 2017 TypeFox GmbH (http://www.typefox.io) and others.
2+
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
33
* This program and the accompanying materials are made available under the
44
* terms of the Eclipse Public License 2.0 which is available at
55
* http://www.eclipse.org/legal/epl-2.0.
@@ -240,7 +240,7 @@ protected void refreshWorkspaceConfig(CancelIndicator cancelIndicator) {
240240
*/
241241
protected IWorkspaceConfig getWorkspaceConfig() throws ResponseErrorException {
242242
if (workspaceConfig == null) {
243-
ResponseError error = new ResponseError(ResponseErrorCode.serverNotInitialized,
243+
ResponseError error = new ResponseError(ResponseErrorCode.ServerNotInitialized,
244244
"Workspace has not been initialized yet.", null);
245245
throw new ResponseErrorException(error);
246246
}

org.eclipse.xtext.ide/src/org/eclipse/xtext/ide/server/symbol/WorkspaceSymbolService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import java.util.LinkedList;
1515
import java.util.List;
1616
import org.eclipse.lsp4j.SymbolInformation;
17+
import org.eclipse.lsp4j.WorkspaceSymbol;
18+
import org.eclipse.lsp4j.jsonrpc.messages.Either;
1719
import org.eclipse.xtext.findReferences.IReferenceFinder.IResourceAccess;
1820
import org.eclipse.xtext.resource.IResourceDescription;
1921
import org.eclipse.xtext.resource.IResourceDescriptions;
@@ -34,7 +36,7 @@ public class WorkspaceSymbolService {
3436
@Inject
3537
private OperationCanceledManager operationCanceledManager;
3638

37-
public List<? extends SymbolInformation> getSymbols(
39+
public Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> getSymbols(
3840
String query,
3941
IResourceAccess resourceAccess,
4042
IResourceDescriptions indexData,
@@ -51,7 +53,7 @@ public List<? extends SymbolInformation> getSymbols(
5153
}
5254
}
5355
}
54-
return result;
56+
return Either.forLeft(result);
5557
}
5658

5759
}

org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/AbstractLanguageServerTest.xtend

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2016, 2021 TypeFox GmbH (http://www.typefox.io) and others.
2+
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
33
* This program and the accompanying materials are made available under the
44
* terms of the Eclipse Public License 2.0 which is available at
55
* http://www.eclipse.org/legal/epl-2.0.
@@ -92,6 +92,7 @@ import org.junit.jupiter.api.BeforeEach
9292

9393
import static extension org.eclipse.lsp4j.util.Ranges.containsRange
9494
import static extension org.eclipse.xtext.util.Strings.*
95+
import org.eclipse.lsp4j.WorkspaceSymbol
9596

9697
/**
9798
* @author Sven Efftinge - Initial contribution and API
@@ -305,6 +306,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
305306

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

309+
@Deprecated
308310
protected def dispatch String toExpectation(SymbolInformation it) '''
309311
symbol "«name»" {
310312
kind: «kind.value»
@@ -315,6 +317,16 @@ abstract class AbstractLanguageServerTest implements Endpoint {
315317
}
316318
'''
317319
320+
protected def dispatch String toExpectation(WorkspaceSymbol it) '''
321+
symbol "«name»" {
322+
kind: «kind.value»
323+
location: «location.toExpectation»
324+
«IF !containerName.nullOrEmpty»
325+
container: "«containerName»"
326+
«ENDIF»
327+
}
328+
'''
329+
318330
/**
319331
* @since 2.16
320332
*/
@@ -624,7 +636,7 @@ abstract class AbstractLanguageServerTest implements Endpoint {
624636
if (configuration.getAssertSymbols !== null) {
625637
configuration.getAssertSymbols.apply(symbols)
626638
} else {
627-
val unwrappedSymbols = symbols.map[if(hierarchicalDocumentSymbolSupport) getRight else getLeft]
639+
val unwrappedSymbols = symbols.map[if (hierarchicalDocumentSymbolSupport) getRight else getLeft]
628640
val String actualSymbols = unwrappedSymbols.toExpectation
629641
assertEquals(getExpectedSymbols, actualSymbols)
630642
}
@@ -637,8 +649,12 @@ abstract class AbstractLanguageServerTest implements Endpoint {
637649
638650
initializeContext(configuration)
639651
val symbols = languageServer.symbol(new WorkspaceSymbolParams(query)).get
640-
if (configuration.assertSymbols !== null) {
641-
configuration.assertSymbols.apply(symbols)
652+
if (configuration.assertSymbols !== null || configuration.assertWorkspaceSymbols !== null) {
653+
if (symbols.isLeft) {
654+
configuration.assertSymbols.apply(symbols.getLeft)
655+
} else {
656+
configuration.assertWorkspaceSymbols.apply(symbols.getRight)
657+
}
642658
} else {
643659
val String actualSymbols = symbols.toExpectation
644660
assertEquals(expectedSymbols, actualSymbols)

org.eclipse.xtext.testing/src/org/eclipse/xtext/testing/WorkspaceSymbolConfiguration.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
import java.util.List;
1212

1313
import org.eclipse.lsp4j.SymbolInformation;
14+
import org.eclipse.lsp4j.WorkspaceSymbol;
1415
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
1516

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

1920
private String expectedSymbols = "";
2021

22+
@Deprecated
2123
private Procedure1<? super List<? extends SymbolInformation>> assertSymbols = null;
24+
private Procedure1<? super List<? extends WorkspaceSymbol>> assertWorkspaceSymbols = null;
2225

2326
public String getQuery() {
2427
return query;
@@ -36,11 +39,27 @@ public void setExpectedSymbols(String expectedSymbols) {
3639
this.expectedSymbols = expectedSymbols;
3740
}
3841

42+
@Deprecated
3943
public Procedure1<? super List<? extends SymbolInformation>> getAssertSymbols() {
4044
return assertSymbols;
4145
}
4246

47+
@Deprecated
4348
public void setAssertSymbols(Procedure1<? super List<? extends SymbolInformation>> assertSymbols) {
4449
this.assertSymbols = assertSymbols;
4550
}
51+
52+
/**
53+
* @since 2.27.0
54+
*/
55+
public Procedure1<? super List<? extends WorkspaceSymbol>> getAssertWorkspaceSymbols() {
56+
return assertWorkspaceSymbols;
57+
}
58+
59+
/**
60+
* @since 2.27.0
61+
*/
62+
public void setAssertWorkspaceSymbols(Procedure1<? super List<? extends WorkspaceSymbol>> assertWorkspaceSymbols) {
63+
this.assertWorkspaceSymbols = assertWorkspaceSymbols;
64+
}
4665
}

org.eclipse.xtext.testing/xtend-gen/org/eclipse/xtext/testing/AbstractLanguageServerTest.java

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2016, 2021 TypeFox GmbH (http://www.typefox.io) and others.
2+
* Copyright (c) 2016, 2022 TypeFox GmbH (http://www.typefox.io) and others.
33
* This program and the accompanying materials are made available under the
44
* terms of the Eclipse Public License 2.0 which is available at
55
* http://www.eclipse.org/legal/epl-2.0.
@@ -81,6 +81,7 @@
8181
import org.eclipse.lsp4j.VersionedTextDocumentIdentifier;
8282
import org.eclipse.lsp4j.WorkspaceEdit;
8383
import org.eclipse.lsp4j.WorkspaceFolder;
84+
import org.eclipse.lsp4j.WorkspaceSymbol;
8485
import org.eclipse.lsp4j.WorkspaceSymbolParams;
8586
import org.eclipse.lsp4j.jsonrpc.Endpoint;
8687
import org.eclipse.lsp4j.jsonrpc.messages.Either;
@@ -519,6 +520,7 @@ protected String _toExpectation(final Position it) {
519520
return _builder.toString();
520521
}
521522

523+
@Deprecated
522524
protected String _toExpectation(final SymbolInformation it) {
523525
StringConcatenation _builder = new StringConcatenation();
524526
_builder.append("symbol \"");
@@ -553,6 +555,40 @@ protected String _toExpectation(final SymbolInformation it) {
553555
return _builder.toString();
554556
}
555557

558+
protected String _toExpectation(final WorkspaceSymbol it) {
559+
StringConcatenation _builder = new StringConcatenation();
560+
_builder.append("symbol \"");
561+
String _name = it.getName();
562+
_builder.append(_name);
563+
_builder.append("\" {");
564+
_builder.newLineIfNotEmpty();
565+
_builder.append(" ");
566+
_builder.append("kind: ");
567+
int _value = it.getKind().getValue();
568+
_builder.append(_value, " ");
569+
_builder.newLineIfNotEmpty();
570+
_builder.append(" ");
571+
_builder.append("location: ");
572+
String _expectation = this.toExpectation(it.getLocation());
573+
_builder.append(_expectation, " ");
574+
_builder.newLineIfNotEmpty();
575+
{
576+
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(it.getContainerName());
577+
boolean _not = (!_isNullOrEmpty);
578+
if (_not) {
579+
_builder.append(" ");
580+
_builder.append("container: \"");
581+
String _containerName = it.getContainerName();
582+
_builder.append(_containerName, " ");
583+
_builder.append("\"");
584+
_builder.newLineIfNotEmpty();
585+
}
586+
}
587+
_builder.append("}");
588+
_builder.newLine();
589+
return _builder.toString();
590+
}
591+
556592
/**
557593
* @since 2.16
558594
*/
@@ -1297,11 +1333,14 @@ protected void testSymbol(final Procedure1<? super WorkspaceSymbolConfiguration>
12971333
this.initializeContext(configuration);
12981334
String _query = configuration.getQuery();
12991335
WorkspaceSymbolParams _workspaceSymbolParams = new WorkspaceSymbolParams(_query);
1300-
final List<? extends SymbolInformation> symbols = this.languageServer.symbol(_workspaceSymbolParams).get();
1301-
Procedure1<? super List<? extends SymbolInformation>> _assertSymbols = configuration.getAssertSymbols();
1302-
boolean _tripleNotEquals = (_assertSymbols != null);
1303-
if (_tripleNotEquals) {
1304-
configuration.getAssertSymbols().apply(symbols);
1336+
final Either<List<? extends SymbolInformation>, List<? extends WorkspaceSymbol>> symbols = this.languageServer.symbol(_workspaceSymbolParams).get();
1337+
if (((configuration.getAssertSymbols() != null) || (configuration.getAssertWorkspaceSymbols() != null))) {
1338+
boolean _isLeft = symbols.isLeft();
1339+
if (_isLeft) {
1340+
configuration.getAssertSymbols().apply(symbols.getLeft());
1341+
} else {
1342+
configuration.getAssertWorkspaceSymbols().apply(symbols.getRight());
1343+
}
13051344
} else {
13061345
final String actualSymbols = this.toExpectation(symbols);
13071346
this.assertEquals(configuration.getExpectedSymbols(), actualSymbols);
@@ -1524,6 +1563,8 @@ protected String toExpectation(final Object it) {
15241563
return _toExpectation((TextEdit)it);
15251564
} else if (it instanceof WorkspaceEdit) {
15261565
return _toExpectation((WorkspaceEdit)it);
1566+
} else if (it instanceof WorkspaceSymbol) {
1567+
return _toExpectation((WorkspaceSymbol)it);
15271568
} else if (it instanceof Either) {
15281569
return _toExpectation((Either<?, ?>)it);
15291570
} else {

0 commit comments

Comments
 (0)