implements PLN-0114

This commit is contained in:
2026-07-15 11:29:02 +01:00
parent 6205b82e0b
commit bb8669bf46
5 changed files with 65 additions and 43 deletions
@@ -10,8 +10,11 @@ import p.studio.compiler.pbs.semantics.PbsEditorialSymbolKind;
import p.studio.compiler.pbs.semantics.PbsEditorialSupportService;
import p.studio.compiler.services.FrontendCompletionCandidate;
import p.studio.compiler.services.FrontendDocumentRequest;
import p.studio.compiler.services.FrontendDocumentation;
import p.studio.compiler.services.FrontendEditorialContext;
import p.studio.compiler.services.FrontendHover;
import p.studio.compiler.services.FrontendLanguageService;
import p.studio.compiler.services.FrontendSignature;
import p.studio.compiler.services.FrontendSymbolKind;
import p.studio.utilities.structures.ReadOnlyList;
@@ -78,6 +81,30 @@ public final class PBSFrontendLanguageService implements FrontendLanguageService
return editorialSupportService.hover(sourceText, ast, supplementalTopDecls, feSurfaceContext, offset);
}
@Override
public Optional<FrontendHover> hover(
final FrontendDocumentRequest request,
final FrontendEditorialContext editorialContext,
final int offset) {
if (request == null
|| editorialContext == null
|| !(editorialContext.syntaxTree() instanceof PbsAst.File ast)
|| !(editorialContext.supplementalDeclarations() instanceof ReadOnlyList<?> supplementalTopDecls)
|| !(editorialContext.semanticContext() instanceof FESurfaceContext feSurfaceContext)) {
return Optional.empty();
}
@SuppressWarnings("unchecked")
final ReadOnlyList<PbsAst.TopDecl> typedSupplementalTopDecls =
(ReadOnlyList<PbsAst.TopDecl>) supplementalTopDecls;
return hover(
request.documentText(),
ast,
typedSupplementalTopDecls,
feSurfaceContext,
offset).map(this::toFrontendHover);
}
public Optional<PbsEditorialSignatureHelp> signatureHelp(
final String sourceText,
final PbsAst.File ast,
@@ -105,6 +132,18 @@ public final class PBSFrontendLanguageService implements FrontendLanguageService
candidate.origin());
}
private FrontendHover toFrontendHover(final PbsEditorialResolvedSymbol symbol) {
return new FrontendHover(
symbol.displayName(),
toFrontendSymbolKind(symbol.kind()),
symbol.detail(),
symbol.origin(),
symbol.signatures().stream()
.map(signature -> new FrontendSignature(signature.label(), signature.parameterLabels(), ""))
.toList(),
FrontendDocumentation.markdown(symbol.documentation()));
}
private FrontendSymbolKind toFrontendSymbolKind(final PbsEditorialSymbolKind kind) {
return FrontendSymbolKind.valueOf(kind.name());
}
@@ -32,6 +32,13 @@ public interface FrontendLanguageService {
return Optional.empty();
}
default Optional<FrontendHover> hover(
final FrontendDocumentRequest request,
final FrontendEditorialContext editorialContext,
final int offset) {
return hover(request, offset);
}
default FrontendSignatureHelp signatureHelp(
final FrontendDocumentRequest request,
final int offset) {