implements PLN-0111

This commit is contained in:
2026-07-15 11:22:38 +01:00
parent 3ee0da3c0a
commit b1e75973f9
19 changed files with 1154 additions and 45 deletions
@@ -0,0 +1,63 @@
package p.studio.compiler.services;
import org.junit.jupiter.api.Test;
import java.nio.file.Path;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
class FrontendLanguageServiceTest {
@Test
void defaultLanguageServiceCapabilitiesAreEmpty() {
final FrontendLanguageService service = new FrontendLanguageService() {
};
final FrontendDocumentRequest request = new FrontendDocumentRequest(
Path.of("."),
Path.of("src/main.pbs"),
"fun main() {}");
assertTrue(service.semanticTokens(request).isEmpty());
assertTrue(service.completion(request, 0).isEmpty());
assertTrue(service.hover(request, 0).isEmpty());
assertEquals(FrontendSignatureHelp.empty(), service.signatureHelp(request, 0));
}
@Test
void completionCandidateNormalizesOptionalText() {
final var candidate = new FrontendCompletionCandidate(
" draw ",
FrontendSymbolKind.FUNCTION,
" callable ",
" docs ",
" stdlib ");
assertEquals("draw", candidate.label());
assertEquals("callable", candidate.detail());
assertEquals("docs", candidate.documentation());
assertEquals("stdlib", candidate.origin());
}
@Test
void hoverDefaultsToEmptyMarkdownDocumentation() {
final var hover = new FrontendHover(
"draw",
FrontendSymbolKind.FUNCTION,
null,
null,
List.of(new FrontendSignature("draw(x)", List.of("x"), null)),
null);
assertEquals("draw", hover.displayName());
assertTrue(hover.documentation().isBlank());
assertEquals(FrontendDocumentationFormat.MARKDOWN, hover.documentation().format());
assertEquals(1, hover.signatures().size());
}
@Test
void signatureHelpRejectsNegativeActiveIndexes() {
assertThrows(IllegalArgumentException.class, () -> new FrontendSignatureHelp(List.of(), -1, 0));
assertThrows(IllegalArgumentException.class, () -> new FrontendSignatureHelp(List.of(), 0, -1));
}
}