better semantic style for PBS

This commit is contained in:
2026-04-02 18:35:58 +01:00
parent 275a7aa408
commit 4c1a5317dd
14 changed files with 1051 additions and 44 deletions
@@ -14,8 +14,19 @@ public enum PbsSemanticKind {
OPERATOR("pbs-operator"),
PUNCTUATION("pbs-punctuation"),
FUNCTION("pbs-function"),
TYPE("pbs-type"),
BINDING("pbs-binding"),
METHOD("pbs-method"),
CONSTRUCTOR("pbs-constructor"),
STRUCT("pbs-struct"),
CONTRACT("pbs-contract"),
HOST("pbs-host"),
BUILTIN_TYPE("pbs-builtin-type"),
SERVICE("pbs-service"),
ERROR("pbs-error"),
ENUM("pbs-enum"),
CALLBACK("pbs-callback"),
GLOBAL("pbs-global"),
CONST("pbs-const"),
IMPLEMENTS("pbs-implements"),
IDENTIFIER("pbs-identifier");
private final String semanticKey;
@@ -108,6 +108,22 @@ public class PBSFrontendPhaseService implements FrontendPhaseService {
return irBackend;
}
public static Map<FileId, ReadOnlyList<p.studio.compiler.pbs.ast.PbsAst.TopDecl>> importedSupplementalTopDeclsByFile(
final FrontendPhaseContext ctx,
final DiagnosticSink diagnostics,
final BuildingIssueSink issues) {
final var service = new PBSFrontendPhaseService();
final var assembly = service.moduleAssemblyService.assemble(ctx, ctx.nameTable(), diagnostics, issues);
final var importedSemanticContexts = service.importedSemanticContextService.build(
assembly.parsedSourceFiles(),
assembly.moduleTable());
final Map<FileId, ReadOnlyList<p.studio.compiler.pbs.ast.PbsAst.TopDecl>> supplementalTopDeclsByFile = new LinkedHashMap<>();
for (final var entry : importedSemanticContexts.entrySet()) {
supplementalTopDeclsByFile.put(entry.getKey(), entry.getValue().supplementalTopDecls());
}
return Map.copyOf(supplementalTopDeclsByFile);
}
private IRBackend mergeCompiledSources(
final ArrayList<CompiledSourceFile> compiledSourceFiles,
final Set<ModuleId> failedModuleIds,
@@ -18,12 +18,56 @@
-fx-fill: #dcdcaa;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-type {
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-method {
-fx-fill: #d7d787;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-constructor {
-fx-fill: #f2c14e;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-struct {
-fx-fill: #4ec9b0;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-binding {
-fx-fill: #c586c0;
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-contract {
-fx-fill: #78dce8;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-host {
-fx-fill: #ffb86c;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-builtin-type {
-fx-fill: #8be9fd;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-service {
-fx-fill: #e06c75;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-error {
-fx-fill: #ff6b6b;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-enum {
-fx-fill: #56cfe1;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-callback {
-fx-fill: #c792ea;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-global {
-fx-fill: #f78c6c;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-const {
-fx-fill: #ffcb6b;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-implements {
-fx-fill: #a1c181;
}
.editor-workspace-code-area-type-pbs .text.editor-semantic-pbs-string {