GH-1431: adjust yaml manifest editor tests to simplified document symbols
This commit is contained in:
@@ -52,7 +52,6 @@ import org.eclipse.lsp4j.MarkupContent;
|
||||
import org.eclipse.lsp4j.Position;
|
||||
import org.eclipse.lsp4j.PublishDiagnosticsParams;
|
||||
import org.eclipse.lsp4j.Range;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
||||
import org.eclipse.lsp4j.TextEdit;
|
||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||
@@ -1039,32 +1038,35 @@ public class Editor {
|
||||
assertEquals(expectedText, getRawText());
|
||||
}
|
||||
|
||||
public void assertDocumentSymbols(String... symbolsAndContainers) throws Exception {
|
||||
Arrays.sort(symbolsAndContainers);
|
||||
public void assertDocumentSymbols(String... symbols) throws Exception {
|
||||
Arrays.sort(symbols);
|
||||
|
||||
StringBuilder expected = new StringBuilder();
|
||||
for (String string : symbolsAndContainers) {
|
||||
for (String string : symbols) {
|
||||
expected.append(string + "\n");
|
||||
}
|
||||
|
||||
List<? extends SymbolInformation> actualSymbols = getDocumentSymbols();
|
||||
List<? extends DocumentSymbol> actualSymbols = getDocumentSymbols();
|
||||
|
||||
List<String> actuals = new ArrayList<>();
|
||||
for (SymbolInformation actualSymbol : actualSymbols) {
|
||||
assertEquals(doc.getUri(), actualSymbol.getLocation().getUri());
|
||||
String coveredText = getText(actualSymbol.getLocation().getRange());
|
||||
for (DocumentSymbol actualSymbol : actualSymbols) {
|
||||
String coveredText = getText(actualSymbol.getRange());
|
||||
assertEquals(actualSymbol.getName(), coveredText);
|
||||
actuals.add(coveredText + "|" + actualSymbol.getContainerName());
|
||||
actuals.add(coveredText);
|
||||
}
|
||||
|
||||
Collections.sort(actuals);
|
||||
StringBuilder actual = new StringBuilder();
|
||||
for (String string : actuals) {
|
||||
actual.append(string + "\n");
|
||||
}
|
||||
|
||||
assertEquals(expected.toString(), actual.toString());
|
||||
}
|
||||
|
||||
public void assertHierarchicalDocumentSymbols(String expectedSymbolDump) throws Exception {
|
||||
StringBuilder symbolDump = new StringBuilder();
|
||||
List<? extends DocumentSymbol> rootSymbols = getHierarchicalDocumentSymbols();
|
||||
List<? extends DocumentSymbol> rootSymbols = getDocumentSymbols();
|
||||
dumpSymbols(rootSymbols, 0, symbolDump);
|
||||
assertEquals(expectedSymbolDump, symbolDump.toString());
|
||||
}
|
||||
@@ -1114,11 +1116,7 @@ public class Editor {
|
||||
}
|
||||
}
|
||||
|
||||
private List<? extends DocumentSymbol> getHierarchicalDocumentSymbols() throws Exception {
|
||||
return harness.getHierarchicalDocumentSymbols(this.doc);
|
||||
}
|
||||
|
||||
private List<? extends SymbolInformation> getDocumentSymbols() throws Exception {
|
||||
private List<? extends DocumentSymbol> getDocumentSymbols() throws Exception {
|
||||
return harness.getDocumentSymbols(this.doc);
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ import org.eclipse.lsp4j.ResourceOperationKind;
|
||||
import org.eclipse.lsp4j.ShowDocumentParams;
|
||||
import org.eclipse.lsp4j.ShowDocumentResult;
|
||||
import org.eclipse.lsp4j.ShowMessageRequestParams;
|
||||
import org.eclipse.lsp4j.SymbolInformation;
|
||||
import org.eclipse.lsp4j.TextDocumentClientCapabilities;
|
||||
import org.eclipse.lsp4j.TextDocumentContentChangeEvent;
|
||||
import org.eclipse.lsp4j.TextDocumentEdit;
|
||||
@@ -978,18 +977,12 @@ public class LanguageServerHarness {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<? extends DocumentSymbol> getHierarchicalDocumentSymbols(TextDocumentInfo document) throws Exception {
|
||||
public List<? extends DocumentSymbol> getDocumentSymbols(TextDocumentInfo document) throws Exception {
|
||||
waitForReconcile(); //TODO: if the server works properly this shouldn't be needed it should do that internally itself somehow.
|
||||
DocumentSymbolParams params = new DocumentSymbolParams(document.getId());
|
||||
return getServer().getTextDocumentService().documentSymbol(params).get().stream().map(e -> e.getRight()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<? extends SymbolInformation> getDocumentSymbols(TextDocumentInfo document) throws Exception {
|
||||
waitForReconcile(); //TODO: if the server works properly this shouldn't be needed it should do that internally itself somehow.
|
||||
DocumentSymbolParams params = new DocumentSymbolParams(document.getId());
|
||||
return getServer().getTextDocumentService().documentSymbol(params).get().stream().map(e -> e.getLeft()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocks the reconciler thread until a specific point in time explicitly controlled by the test.
|
||||
*/
|
||||
|
||||
@@ -1801,8 +1801,8 @@ public class ManifestYamlEditorTest {
|
||||
);
|
||||
|
||||
editor.assertDocumentSymbols(
|
||||
"my-app|Application",
|
||||
"app2|Application"
|
||||
"my-app",
|
||||
"app2"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user