prometeu-studio/discussion/workflow/plans/PLN-0080-propagate-semantic-parameter-names-to-pbs-lsp-editor-assistance.md

113 lines
6.0 KiB
Markdown

---
id: PLN-0080
ticket: pbs-autocomplete-parameter-names
title: Propagate semantic parameter names to PBS LSP editor assistance
status: open
created: 2026-05-08
ref_decisions: [DEC-0036]
tags: [compiler-pbs, studio, lsp, autocomplete, signature-help, stdlib]
---
## Briefing
`DEC-0036` requires completion, signature help, and hover to consume callable parameter names from the compiler semantic model and prevents generated ordinal placeholders from reaching user-facing editor/LSP output.
This plan implements the LSP/editor consumption slice after compiler semantic callable metadata exists.
## Objective
Propagate canonical semantic parameter names into PBS completion, signature help, hover, and VS Code-facing protocol mapping. Add tests proving `arg0`, `arg1`, and equivalent generated placeholders do not leak through user-facing LSP/editor surfaces.
## Dependencies
- Depends on accepted decision `DEC-0036`.
- Should follow `PLN-0078` for spec contract alignment.
- Requires `PLN-0079` or equivalent compiler semantic metadata before final acceptance.
## Scope
- Update PBS editorial support outputs consumed by the LSP bridge.
- Update LSP baseline messages/mappers if the protocol shape needs richer parameter metadata.
- Update completion item construction to use semantic parameter names in labels/details/snippets.
- Update signature help to display semantic parameter names and types.
- Update hover signatures to use the same parameter identity.
- Update VS Code extension only if it formats snippets or signatures locally.
- Add LSP/protocol tests that reject `argN` leakage.
## Non-Goals
- No compiler semantic model implementation; that belongs to `PLN-0079`.
- No authored parameter prose documentation.
- No final design for optional/default/rest parameter UI unless already surfaced by compiler metadata.
- No UI-only guesswork for missing names.
## Execution Method
1. Identify current LSP/editor assistance boundary:
- Inspect:
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/compiler/CompilerLanguageServiceBridge.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/LanguageServiceBridge.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineCompletionItem.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineSignature.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineSignatureHelp.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineHover.java`
- Map which fields currently carry callable signatures and parameters.
2. Consume semantic parameter names from compiler outputs:
- Update bridge/mapping code so completion/signature/hover surfaces use parameter names from PBS semantic callable metadata.
- Do not generate display names from method names, types, docs, or local maps.
- Treat missing semantic names as incomplete metadata and apply a non-misleading fallback UI that does not show `argN`.
3. Update protocol mapping:
- Inspect:
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/protocol/mapping/Lsp4jProtocolMessageMapper.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/protocol/mapping/ProtocolMessageMapper.java`
- Ensure LSP4J completion/signature/hover conversion preserves semantic parameter names.
- Ensure snippet placeholders, if emitted, use canonical parameter names.
4. Update VS Code extension if required:
- Inspect:
- `tools/vscode-extension/src/extension.ts`
- If the extension formats call snippets or signatures locally, remove any generated ordinal placeholders and consume protocol-provided semantic names.
5. Add LSP/editor tests:
- Extend:
- `prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/compiler/CompilerLanguageServiceBridgeTest.java`
- `prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/protocol/PrometeuTextDocumentServiceTest.java`
- `prometeu-lsp/prometeu-lsp-v1/src/test/java/p/studio/lsp/services/protocol/PrometeuLanguageServerTest.java`
- Assert completion labels/details/snippets do not contain `arg0` or `arg1`.
- Assert signature help parameter labels use semantic names.
- Assert hover callable signatures use the same semantic names.
## Acceptance Criteria
- Completion surfaces use canonical semantic parameter names and do not leak `argN`.
- Signature help surfaces use canonical semantic parameter names and do not leak `argN`.
- Hover callable signatures use canonical semantic parameter names and do not leak `argN`.
- The same callable uses the same parameter names across completion, signature help, and hover.
- Missing parameter metadata is represented without fabricating public ordinal names.
- VS Code extension behavior remains compatible with protocol outputs.
## Tests
- Run focused LSP tests:
- `CompilerLanguageServiceBridgeTest`
- `PrometeuTextDocumentServiceTest`
- `PrometeuLanguageServerTest`
- Run the LSP Gradle test task for `prometeu-lsp-v1` if available.
- Run VS Code extension tests/build if the extension code changes:
- `npm test` or `npm run compile` in `tools/vscode-extension`, depending on available scripts.
- Run `discussion validate`.
## Affected Artifacts
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/compiler/CompilerLanguageServiceBridge.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/LanguageServiceBridge.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineCompletionItem.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineSignature.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineSignatureHelp.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/messages/BaselineHover.java`
- `prometeu-lsp/prometeu-lsp-v1/src/main/java/p/studio/lsp/services/protocol/mapping/Lsp4jProtocolMessageMapper.java`
- `tools/vscode-extension/src/extension.ts` if local formatting is present.
- LSP protocol and bridge tests.