implement PLN-0032 structural anchor payloads and tests
This commit is contained in:
@@ -2,6 +2,7 @@ package p.studio.lsp;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import p.studio.lsp.dtos.LspStructuralAnchorDTO;
|
||||
import p.studio.lsp.messages.LspProjectContext;
|
||||
import p.studio.lsp.dtos.LspDefinitionTargetDTO;
|
||||
import p.studio.lsp.messages.LspAnalyzeDocumentRequest;
|
||||
@@ -104,6 +105,12 @@ final class LspServiceImplTest {
|
||||
assertTrue(
|
||||
flatten(analysis.documentSymbols()).stream().anyMatch(symbol -> symbol.kind() == p.studio.lsp.messages.LspSymbolKind.HANDLE),
|
||||
analysis.toString());
|
||||
assertFalse(analysis.structuralAnchors().isEmpty(), analysis.toString());
|
||||
assertEquals(OVERLAY_SOURCE.indexOf("{"), analysis.structuralAnchors().getFirst().startAnchor().startOffset());
|
||||
assertTrue(
|
||||
flattenAnchors(analysis.structuralAnchors()).stream().anyMatch(anchor ->
|
||||
anchor.startAnchor().startOffset() == OVERLAY_SOURCE.indexOf("if true {") + "if true ".length()),
|
||||
analysis.toString());
|
||||
assertTrue(
|
||||
analysis.workspaceSymbols().stream().anyMatch(symbol ->
|
||||
symbol.name().equals("helper") && symbol.documentPath().equals(normalize(helperFile))),
|
||||
@@ -236,6 +243,16 @@ final class LspServiceImplTest {
|
||||
return flattened;
|
||||
}
|
||||
|
||||
private static List<LspStructuralAnchorDTO> flattenAnchors(
|
||||
final List<LspStructuralAnchorDTO> anchors) {
|
||||
final List<LspStructuralAnchorDTO> flattened = new java.util.ArrayList<>();
|
||||
for (final var anchor : anchors) {
|
||||
flattened.add(anchor);
|
||||
flattened.addAll(flattenAnchors(anchor.children()));
|
||||
}
|
||||
return flattened;
|
||||
}
|
||||
|
||||
private VfsProjectContext projectContext(final Path projectRoot) {
|
||||
return new VfsProjectContext("Example", "pbs", projectRoot);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user