implements PLN-0079
This commit is contained in:
+52
-1
@@ -155,7 +155,7 @@ final class PbsEditorialSupportServiceTest {
|
||||
ReadOnlyList.empty(),
|
||||
source.lastIndexOf("2);"));
|
||||
assertTrue(methodHelp.isPresent());
|
||||
assertEquals("blend(arg0: int, arg1: int) -> int", methodHelp.orElseThrow().signatures().getFirst().label());
|
||||
assertEquals("blend(dx: int, dy: int) -> int", methodHelp.orElseThrow().signatures().getFirst().label());
|
||||
assertEquals(1, methodHelp.orElseThrow().activeParameter());
|
||||
|
||||
final var constructorHelp = service.signatureHelp(
|
||||
@@ -171,6 +171,57 @@ final class PbsEditorialSupportServiceTest {
|
||||
assertEquals("Vec()", constructorHover.signatures().getFirst().label());
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldPreserveSemanticParameterNamesForHostAndBuiltinCallables() {
|
||||
final var source = """
|
||||
import { Gfx, Sprite } from @sdk:gfx;
|
||||
|
||||
fn main(sprite: Sprite) -> void {
|
||||
Gfx.draw_pixel(1, 2, 3);
|
||||
sprite.blit(4, 5);
|
||||
}
|
||||
""";
|
||||
final var ast = parseOrdinary(source);
|
||||
final var supplementalTopDecls = supplementalTopDecls("""
|
||||
declare host Gfx {
|
||||
fn draw_pixel(x: int, y: int, color: int) -> void;
|
||||
}
|
||||
|
||||
declare builtin type Sprite(
|
||||
pub id: int
|
||||
) {
|
||||
fn blit(x: int, y: int) -> void;
|
||||
}
|
||||
""");
|
||||
|
||||
final var hostHelp = service.signatureHelp(
|
||||
source,
|
||||
ast,
|
||||
supplementalTopDecls,
|
||||
source.indexOf("2, 3"));
|
||||
assertTrue(hostHelp.isPresent());
|
||||
assertEquals("draw_pixel(x: int, y: int, color: int) -> void", hostHelp.orElseThrow().signatures().getFirst().label());
|
||||
assertFalse(hostHelp.orElseThrow().signatures().getFirst().label().contains("arg"));
|
||||
|
||||
final var builtinHelp = service.signatureHelp(
|
||||
source,
|
||||
ast,
|
||||
supplementalTopDecls,
|
||||
source.indexOf("5);"));
|
||||
assertTrue(builtinHelp.isPresent());
|
||||
assertEquals("blit(x: int, y: int) -> void", builtinHelp.orElseThrow().signatures().getFirst().label());
|
||||
assertFalse(builtinHelp.orElseThrow().signatures().getFirst().label().contains("arg"));
|
||||
|
||||
final var hostCompletion = service.completion(
|
||||
source,
|
||||
ast,
|
||||
supplementalTopDecls,
|
||||
source.indexOf("draw_pixel"));
|
||||
assertTrue(hostCompletion.stream().anyMatch(candidate ->
|
||||
candidate.label().equals("draw_pixel")
|
||||
&& candidate.detail().equals("draw_pixel(x: int, y: int, color: int) -> void")));
|
||||
}
|
||||
|
||||
private PbsEditorialResolvedSymbol requireHover(
|
||||
final String source,
|
||||
final PbsAst.File ast,
|
||||
|
||||
Reference in New Issue
Block a user