feat(pbs): resolve editorial chains and expose read-only external sources
Intrepid/Prometeu/Studio/pipeline/head Build started...
Test / Build skipped: 16, passed: 838
Intrepid/Prometeu/Studio/pipeline/pr-master This commit looks good

This commit is contained in:
2026-10-07 09:00:31 +01:00
parent d0737df0ac
commit 967b9ec598
38 changed files with 1856 additions and 42 deletions
+29 -2
View File
@@ -1,5 +1,6 @@
import * as net from "node:net";
import * as vscode from "vscode";
import { ExternalSources, externalScheme } from "./externalSources";
import {
CloseAction,
@@ -17,6 +18,7 @@ let reconnectTimer: NodeJS.Timeout | undefined;
let reconnectContext: vscode.ExtensionContext | undefined;
let stoppingClient = false;
let lastAppliedThemeSignature: string | undefined;
const externalSources = new ExternalSources();
const RECONNECT_DELAY_MS = 2000;
@@ -76,6 +78,11 @@ export function activate(context: vscode.ExtensionContext): void {
reconnectContext = context;
output = vscode.window.createOutputChannel("Prometeu LSP");
output.appendLine("Prometeu VS Code extension activated.");
context.subscriptions.push(externalSources,
vscode.workspace.registerTextDocumentContentProvider(externalScheme, externalSources),
vscode.window.onDidChangeActiveTextEditor(() => externalSources.refreshStatus()),
vscode.workspace.onDidOpenTextDocument(document => void externalSources.opened(document)),
vscode.workspace.onDidCloseTextDocument(document => void externalSources.closeDocument(document)));
const connectCommand = vscode.commands.registerCommand(
"prometeu.connectStudioLsp",
@@ -98,7 +105,8 @@ export function activate(context: vscode.ExtensionContext): void {
}
export async function deactivate(): Promise<void> {
await stopClient();
try { await externalSources.shutdown(); }
finally { await stopClient(); }
}
async function startClient(context: vscode.ExtensionContext): Promise<void> {
@@ -167,7 +175,7 @@ async function startClient(context: vscode.ExtensionContext): Promise<void> {
{
scheme: "file",
language: "pbs"
}
}, { scheme: externalScheme, language: "pbs" }
],
synchronize: {
fileEvents: [
@@ -175,10 +183,20 @@ async function startClient(context: vscode.ExtensionContext): Promise<void> {
]
},
initializationOptions: {
...externalSources.initializationOptions,
clientKind: "vscode",
prometeuClientVersion: context.extension.packageJSON.version
},
outputChannel: output,
middleware: {
prepareRename: (document, position, token, next) => document.uri.scheme === externalScheme ? null : next(document, position, token),
provideRenameEdits: (document, position, name, token, next) => document.uri.scheme === externalScheme ? null : next(document, position, name, token),
provideDocumentFormattingEdits: (document, options, token, next) => document.uri.scheme === externalScheme ? [] : next(document, options, token),
provideCodeActions: (document, range, context, token, next) => document.uri.scheme === externalScheme ? [] : next(document, range, context, token),
provideHover: (document, position, token, next) => externalSources.canQuery(document) ? next(document, position, token) : null,
provideDefinition: (document, position, token, next) => externalSources.canQuery(document) ? next(document, position, token) : null,
provideDocumentSemanticTokens: (document, token, next) => externalSources.canQuery(document) ? next(document, token) : null
},
errorHandler: {
error: (error) => {
output.appendLine(`Prometeu LSP transport error: ${error.message}`);
@@ -198,11 +216,18 @@ async function startClient(context: vscode.ExtensionContext): Promise<void> {
clientOptions
);
client = nextClient;
nextClient.registerFeature({
fillClientCapabilities(capabilities) {
capabilities.experimental = { ...capabilities.experimental, prometeuExternalSources: true };
},
initialize() {}, clear() {}, getState() { return { kind: "static" }; }
});
nextClient.onDidChangeState((event) => {
output.appendLine(`Prometeu LSP state changed: ${State[event.oldState]} -> ${State[event.newState]}`);
if (event.newState !== State.Stopped) {
return;
}
externalSources.disconnected();
if (client === nextClient) {
client = undefined;
}
@@ -213,11 +238,13 @@ async function startClient(context: vscode.ExtensionContext): Promise<void> {
try {
await nextClient.start();
await externalSources.connected(nextClient);
await applyPrometeuVisualTheme(nextClient.initializeResult);
output.appendLine("Prometeu Studio LSP client started.");
vscode.window.showInformationMessage("Connected to Prometeu Studio LSP.");
} catch (error) {
externalSources.resetSession();
if (client === nextClient) {
client = undefined;
}