fix(pbs): keep editorial signatures in source syntax
Share frontend type and return presentation across hover, completion, signature help, outline and inferred hints. Preserve generic applications, source grouping, nominal origins and navigation. Add parser structure, real module/reexport, LSP mapping and Studio consumer regressions. Document the PBS editorial contract. WRK-0021 / DEC-0001 / PLN-0001. Full make -C tooling verify passed all 11 stages: tooling/build/runs/20261126T135036Z-bed847d1/manifest.json. Commit and push explicitly requested by the user.
This commit is contained in:
@@ -99,6 +99,54 @@ class AutomationLspQueriesTest {
|
||||
assertTrue(symbols.toString().contains("renamed"), symbols.toString());
|
||||
assertFalse(symbols.toString().contains("helper"), symbols.toString());
|
||||
}
|
||||
|
||||
@Test void sourceSignaturesReachTheStudioConsumerOverTheActualServer() throws Exception {
|
||||
final String text = """
|
||||
declare error Io { Failed; }
|
||||
fn load(left: int, right: int) -> result<Io> (first: int, second: int) {
|
||||
return ok((first: left, second: right));
|
||||
}
|
||||
fn maybe(value: optional int) -> optional int { return value; }
|
||||
fn caller() -> result<Io> (first: int, second: int) {
|
||||
let candidate = maybe(none);
|
||||
return load(1, 2)!;
|
||||
}
|
||||
""";
|
||||
Files.writeString(source, text);
|
||||
Files.writeString(source.resolveSibling("mod.barrel"), "pub error Io; "
|
||||
+ "pub fn load(left: int, right: int) -> result<Io> (first: int, second: int); "
|
||||
+ "pub fn maybe(value: optional int) -> optional int; "
|
||||
+ "pub fn caller() -> result<Io> (first: int, second: int);");
|
||||
acquire();
|
||||
final String expected = "load(left: int, right: int) -> result<Io> (first: int, second: int)";
|
||||
final java.util.function.IntFunction<Map<String, Object>> atOffset = offset -> {
|
||||
final String prefix = text.substring(0, offset);
|
||||
return at((int) prefix.chars().filter(c -> c == '\n').count(), offset - prefix.lastIndexOf('\n') - 1);
|
||||
};
|
||||
final int call = text.indexOf("load(1, 2)");
|
||||
final var help = query("signatureHelp", atOffset.apply(call + 8)).path("result");
|
||||
assertEquals(1, help.path("activeParameter").asInt(), help.toString());
|
||||
final var signature = help.path("signatures").get(0);
|
||||
assertNotNull(signature, help.toString());
|
||||
assertEquals(expected, signature.path("label").asText());
|
||||
assertEquals("left: int", signature.path("parameters").get(0).path("label").asText());
|
||||
assertEquals("right: int", signature.path("parameters").get(1).path("label").asText());
|
||||
assertTrue(query("hover", atOffset.apply(call + 1)).path("result").toString().contains(expected));
|
||||
final var items = query("completion", atOffset.apply(call + 1)).path("result").path("items");
|
||||
boolean found = false;
|
||||
for (var item : items) if (item.path("label").asText().equals("load")) {
|
||||
assertEquals(expected, item.path("detail").asText());
|
||||
found = true;
|
||||
}
|
||||
assertTrue(found, items.toString());
|
||||
assertTrue(query("documentSymbols", at(0, 0)).path("result").toString()
|
||||
.contains("(left: int, right: int) -> result<Io> (first: int, second: int)"));
|
||||
final var optional = query("signatureHelp", atOffset.apply(text.indexOf("maybe(none)") + 6))
|
||||
.path("result").path("signatures").get(0);
|
||||
assertNotNull(optional);
|
||||
assertEquals("maybe(value: optional int) -> optional int", optional.path("label").asText());
|
||||
assertFalse(query("definition", atOffset.apply(call + 1)).path("result").isEmpty());
|
||||
}
|
||||
@Test void validEmptyDocumentIsSuccessfulEvaluatedAnalysis() throws Exception {
|
||||
Files.writeString(source, "");
|
||||
Files.writeString(source.resolveSibling("mod.barrel"), "pub fn frame() -> void;\n");
|
||||
|
||||
Reference in New Issue
Block a user