implements PLN-0035 pbs inline type hint payload production
This commit is contained in:
@@ -89,7 +89,7 @@ final class LspServiceImplTest {
|
||||
assertEquals("pbs-function", semanticKeyForLexeme(analysis, OVERLAY_SOURCE, "helper"));
|
||||
assertEquals(List.of("/themes/pbs/semantic-highlighting.css"), analysis.semanticPresentation().resources());
|
||||
assertTrue(analysis.semanticPresentation().semanticKeys().contains("pbs-function"));
|
||||
assertTrue(analysis.inlineHints().isEmpty());
|
||||
assertFalse(analysis.inlineHints().isEmpty(), analysis.toString());
|
||||
|
||||
assertTrue(
|
||||
analysis.documentSymbols().stream().anyMatch(symbol -> symbol.name().equals("helper_call")),
|
||||
@@ -209,7 +209,8 @@ final class LspServiceImplTest {
|
||||
void analyzeDocumentReturnsDedicatedInlineHintTransportSurface() throws Exception {
|
||||
final Path projectRoot = createProject();
|
||||
final Path mainFile = projectRoot.resolve("src/main.pbs");
|
||||
Files.writeString(mainFile, "fn main() -> void { let value = 1; }\n");
|
||||
final String source = "fn main() -> void { let value = 1; }\n";
|
||||
Files.writeString(mainFile, source);
|
||||
|
||||
final VfsProjectDocument vfs = new FilesystemProjectDocumentVfsFactory().open(projectContext(projectRoot));
|
||||
final LspService service = new LspServiceImpl(
|
||||
@@ -218,7 +219,39 @@ final class LspServiceImplTest {
|
||||
|
||||
final var analysis = service.analyzeDocument(new LspAnalyzeDocumentRequest(mainFile));
|
||||
|
||||
assertTrue(analysis.inlineHints().isEmpty(), analysis.toString());
|
||||
assertEquals(1, analysis.inlineHints().size(), analysis.toString());
|
||||
assertEquals("int", analysis.inlineHints().getFirst().label());
|
||||
assertEquals("type", analysis.inlineHints().getFirst().category());
|
||||
assertEquals("value", sourceSlice(source, analysis.inlineHints().getFirst().anchor()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void analyzeDocumentPreservesValidInlineHintsUnderPartialDegradation() throws Exception {
|
||||
final Path projectRoot = createProject();
|
||||
final Path mainFile = projectRoot.resolve("src/main.pbs");
|
||||
final String source = """
|
||||
fn ok() -> void {
|
||||
let value = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
fn broken( -> void {
|
||||
let missing = 2;
|
||||
}
|
||||
""";
|
||||
Files.writeString(mainFile, source);
|
||||
|
||||
final VfsProjectDocument vfs = new FilesystemProjectDocumentVfsFactory().open(projectContext(projectRoot));
|
||||
final LspService service = new LspServiceImpl(
|
||||
new LspProjectContext("Example", "pbs", projectRoot),
|
||||
vfs);
|
||||
|
||||
final var analysis = service.analyzeDocument(new LspAnalyzeDocumentRequest(mainFile));
|
||||
|
||||
assertFalse(analysis.diagnostics().isEmpty(), analysis.toString());
|
||||
assertEquals(1, analysis.inlineHints().size(), analysis.toString());
|
||||
assertEquals("int", analysis.inlineHints().getFirst().label());
|
||||
assertEquals("value", sourceSlice(source, analysis.inlineHints().getFirst().anchor()));
|
||||
}
|
||||
|
||||
private Path createProject() throws Exception {
|
||||
@@ -315,6 +348,12 @@ final class LspServiceImplTest {
|
||||
return source.substring(start, end);
|
||||
}
|
||||
|
||||
private static String sourceSlice(
|
||||
final String source,
|
||||
final p.studio.lsp.dtos.LspRangeDTO range) {
|
||||
return spanContent(source, range.startOffset(), range.endOffset());
|
||||
}
|
||||
|
||||
private static final class OverlayVfsProjectDocument implements VfsProjectDocument {
|
||||
private final VfsProjectDocument delegate;
|
||||
private final Path overlayPath;
|
||||
|
||||
Reference in New Issue
Block a user