Skip to content

Commit ef83670

Browse files
committed
GH-1431: adjust yaml manifest editor tests to simplified document symbols
1 parent 812102a commit ef83670

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import org.eclipse.lsp4j.Position;
5353
import org.eclipse.lsp4j.PublishDiagnosticsParams;
5454
import org.eclipse.lsp4j.Range;
55-
import org.eclipse.lsp4j.SymbolInformation;
5655
import org.eclipse.lsp4j.TextDocumentIdentifier;
5756
import org.eclipse.lsp4j.TextEdit;
5857
import org.eclipse.lsp4j.jsonrpc.messages.Either;
@@ -1039,32 +1038,35 @@ public void assertRawText(String expectedText) throws Exception {
10391038
assertEquals(expectedText, getRawText());
10401039
}
10411040

1042-
public void assertDocumentSymbols(String... symbolsAndContainers) throws Exception {
1043-
Arrays.sort(symbolsAndContainers);
1041+
public void assertDocumentSymbols(String... symbols) throws Exception {
1042+
Arrays.sort(symbols);
1043+
10441044
StringBuilder expected = new StringBuilder();
1045-
for (String string : symbolsAndContainers) {
1045+
for (String string : symbols) {
10461046
expected.append(string + "\n");
10471047
}
10481048

1049-
List<? extends SymbolInformation> actualSymbols = getDocumentSymbols();
1049+
List<? extends DocumentSymbol> actualSymbols = getDocumentSymbols();
1050+
10501051
List<String> actuals = new ArrayList<>();
1051-
for (SymbolInformation actualSymbol : actualSymbols) {
1052-
assertEquals(doc.getUri(), actualSymbol.getLocation().getUri());
1053-
String coveredText = getText(actualSymbol.getLocation().getRange());
1052+
for (DocumentSymbol actualSymbol : actualSymbols) {
1053+
String coveredText = getText(actualSymbol.getRange());
10541054
assertEquals(actualSymbol.getName(), coveredText);
1055-
actuals.add(coveredText + "|" + actualSymbol.getContainerName());
1055+
actuals.add(coveredText);
10561056
}
1057+
10571058
Collections.sort(actuals);
10581059
StringBuilder actual = new StringBuilder();
10591060
for (String string : actuals) {
10601061
actual.append(string + "\n");
10611062
}
1063+
10621064
assertEquals(expected.toString(), actual.toString());
10631065
}
10641066

10651067
public void assertHierarchicalDocumentSymbols(String expectedSymbolDump) throws Exception {
10661068
StringBuilder symbolDump = new StringBuilder();
1067-
List<? extends DocumentSymbol> rootSymbols = getHierarchicalDocumentSymbols();
1069+
List<? extends DocumentSymbol> rootSymbols = getDocumentSymbols();
10681070
dumpSymbols(rootSymbols, 0, symbolDump);
10691071
assertEquals(expectedSymbolDump, symbolDump.toString());
10701072
}
@@ -1114,11 +1116,7 @@ private static int compare(Position p1, Position p2) {
11141116
}
11151117
}
11161118

1117-
private List<? extends DocumentSymbol> getHierarchicalDocumentSymbols() throws Exception {
1118-
return harness.getHierarchicalDocumentSymbols(this.doc);
1119-
}
1120-
1121-
private List<? extends SymbolInformation> getDocumentSymbols() throws Exception {
1119+
private List<? extends DocumentSymbol> getDocumentSymbols() throws Exception {
11221120
return harness.getDocumentSymbols(this.doc);
11231121
}
11241122

headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/LanguageServerHarness.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
import org.eclipse.lsp4j.ShowDocumentParams;
9898
import org.eclipse.lsp4j.ShowDocumentResult;
9999
import org.eclipse.lsp4j.ShowMessageRequestParams;
100-
import org.eclipse.lsp4j.SymbolInformation;
101100
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
102101
import org.eclipse.lsp4j.TextDocumentContentChangeEvent;
103102
import org.eclipse.lsp4j.TextDocumentEdit;
@@ -978,18 +977,12 @@ private synchronized List<Editor> getOpenEditors(String uri) {
978977
.collect(Collectors.toList());
979978
}
980979

981-
public List<? extends DocumentSymbol> getHierarchicalDocumentSymbols(TextDocumentInfo document) throws Exception {
980+
public List<? extends DocumentSymbol> getDocumentSymbols(TextDocumentInfo document) throws Exception {
982981
waitForReconcile(); //TODO: if the server works properly this shouldn't be needed it should do that internally itself somehow.
983982
DocumentSymbolParams params = new DocumentSymbolParams(document.getId());
984983
return getServer().getTextDocumentService().documentSymbol(params).get().stream().map(e -> e.getRight()).collect(Collectors.toList());
985984
}
986985

987-
public List<? extends SymbolInformation> getDocumentSymbols(TextDocumentInfo document) throws Exception {
988-
waitForReconcile(); //TODO: if the server works properly this shouldn't be needed it should do that internally itself somehow.
989-
DocumentSymbolParams params = new DocumentSymbolParams(document.getId());
990-
return getServer().getTextDocumentService().documentSymbol(params).get().stream().map(e -> e.getLeft()).collect(Collectors.toList());
991-
}
992-
993986
/**
994987
* Blocks the reconciler thread until a specific point in time explicitly controlled by the test.
995988
*/

headless-services/manifest-yaml-language-server/src/test/java/org/springframework/ide/vscode/manifest/yaml/ManifestYamlEditorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,8 +1801,8 @@ public void reconcileRouteValidDomain() throws Exception {
18011801
);
18021802

18031803
editor.assertDocumentSymbols(
1804-
"my-app|Application",
1805-
"app2|Application"
1804+
"my-app",
1805+
"app2"
18061806
);
18071807
}
18081808

0 commit comments

Comments
 (0)