feat(pbs): resolve editorial chains and expose read-only external sources
This commit is contained in:
@@ -37,6 +37,7 @@ exports.activate = activate;
|
||||
exports.deactivate = deactivate;
|
||||
const net = __importStar(require("node:net"));
|
||||
const vscode = __importStar(require("vscode"));
|
||||
const externalSources_1 = require("./externalSources");
|
||||
const node_1 = require("vscode-languageclient/node");
|
||||
let client;
|
||||
let output;
|
||||
@@ -44,12 +45,14 @@ let reconnectTimer;
|
||||
let reconnectContext;
|
||||
let stoppingClient = false;
|
||||
let lastAppliedThemeSignature;
|
||||
const externalSources = new externalSources_1.ExternalSources();
|
||||
const RECONNECT_DELAY_MS = 2000;
|
||||
const VSCODE_HOST_ID = "vscode";
|
||||
function activate(context) {
|
||||
reconnectContext = context;
|
||||
output = vscode.window.createOutputChannel("Prometeu LSP");
|
||||
output.appendLine("Prometeu VS Code extension activated.");
|
||||
context.subscriptions.push(externalSources, vscode.workspace.registerTextDocumentContentProvider(externalSources_1.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", async () => {
|
||||
await startClient(context);
|
||||
});
|
||||
@@ -61,7 +64,12 @@ function activate(context) {
|
||||
void startClient(context);
|
||||
}
|
||||
async function deactivate() {
|
||||
await stopClient();
|
||||
try {
|
||||
await externalSources.shutdown();
|
||||
}
|
||||
finally {
|
||||
await stopClient();
|
||||
}
|
||||
}
|
||||
async function startClient(context) {
|
||||
clearReconnectTimer();
|
||||
@@ -113,7 +121,7 @@ async function startClient(context) {
|
||||
{
|
||||
scheme: "file",
|
||||
language: "pbs"
|
||||
}
|
||||
}, { scheme: externalSources_1.externalScheme, language: "pbs" }
|
||||
],
|
||||
synchronize: {
|
||||
fileEvents: [
|
||||
@@ -121,10 +129,20 @@ async function startClient(context) {
|
||||
]
|
||||
},
|
||||
initializationOptions: {
|
||||
...externalSources.initializationOptions,
|
||||
clientKind: "vscode",
|
||||
prometeuClientVersion: context.extension.packageJSON.version
|
||||
},
|
||||
outputChannel: output,
|
||||
middleware: {
|
||||
prepareRename: (document, position, token, next) => document.uri.scheme === externalSources_1.externalScheme ? null : next(document, position, token),
|
||||
provideRenameEdits: (document, position, name, token, next) => document.uri.scheme === externalSources_1.externalScheme ? null : next(document, position, name, token),
|
||||
provideDocumentFormattingEdits: (document, options, token, next) => document.uri.scheme === externalSources_1.externalScheme ? [] : next(document, options, token),
|
||||
provideCodeActions: (document, range, context, token, next) => document.uri.scheme === externalSources_1.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}`);
|
||||
@@ -138,11 +156,18 @@ async function startClient(context) {
|
||||
};
|
||||
const nextClient = new node_1.LanguageClient("prometeuStudioLsp", "Prometeu Studio LSP", serverOptions, 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: ${node_1.State[event.oldState]} -> ${node_1.State[event.newState]}`);
|
||||
if (event.newState !== node_1.State.Stopped) {
|
||||
return;
|
||||
}
|
||||
externalSources.disconnected();
|
||||
if (client === nextClient) {
|
||||
client = undefined;
|
||||
}
|
||||
@@ -152,11 +177,13 @@ async function startClient(context) {
|
||||
});
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user