implements PLN-0113
This commit is contained in:
+43
@@ -6,9 +6,13 @@ import p.studio.compiler.pbs.ast.PbsAst;
|
||||
import p.studio.compiler.pbs.semantics.PbsEditorialCompletionCandidate;
|
||||
import p.studio.compiler.pbs.semantics.PbsEditorialResolvedSymbol;
|
||||
import p.studio.compiler.pbs.semantics.PbsEditorialSignatureHelp;
|
||||
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.FrontendEditorialContext;
|
||||
import p.studio.compiler.services.FrontendLanguageService;
|
||||
import p.studio.compiler.services.FrontendSymbolKind;
|
||||
import p.studio.utilities.structures.ReadOnlyList;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,6 +43,32 @@ public final class PBSFrontendLanguageService implements FrontendLanguageService
|
||||
return editorialSupportService.completion(sourceText, ast, supplementalTopDecls, feSurfaceContext, offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FrontendCompletionCandidate> completion(
|
||||
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 List.of();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final ReadOnlyList<PbsAst.TopDecl> typedSupplementalTopDecls =
|
||||
(ReadOnlyList<PbsAst.TopDecl>) supplementalTopDecls;
|
||||
return completion(
|
||||
request.documentText(),
|
||||
ast,
|
||||
typedSupplementalTopDecls,
|
||||
feSurfaceContext,
|
||||
offset).stream()
|
||||
.map(this::toFrontendCompletionCandidate)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Optional<PbsEditorialResolvedSymbol> hover(
|
||||
final String sourceText,
|
||||
final PbsAst.File ast,
|
||||
@@ -65,4 +95,17 @@ public final class PBSFrontendLanguageService implements FrontendLanguageService
|
||||
public List<FrontendSemanticToken> semanticTokens(final String documentText) {
|
||||
return semanticTokenProvider.tokenize(documentText == null ? "" : documentText);
|
||||
}
|
||||
|
||||
private FrontendCompletionCandidate toFrontendCompletionCandidate(final PbsEditorialCompletionCandidate candidate) {
|
||||
return new FrontendCompletionCandidate(
|
||||
candidate.label(),
|
||||
toFrontendSymbolKind(candidate.kind()),
|
||||
candidate.detail(),
|
||||
candidate.documentation(),
|
||||
candidate.origin());
|
||||
}
|
||||
|
||||
private FrontendSymbolKind toFrontendSymbolKind(final PbsEditorialSymbolKind kind) {
|
||||
return FrontendSymbolKind.valueOf(kind.name());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user