Skip to content

Commit

Permalink
Add command for showing SlithIR
Browse files Browse the repository at this point in the history
  • Loading branch information
frabert committed Apr 11, 2024
1 parent 55af58b commit 8769cf6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ export async function activate(context: vscode.ExtensionContext) {
await slitherLanguageClient.analyze({ uris: [qp.uri.toString()] });
}));

const slithirProvider = new (class implements vscode.TextDocumentContentProvider {
provideTextDocumentContent(uri: vscode.Uri): string {
return uri.path;
}
})();

vscode.workspace.registerTextDocumentContentProvider("slithir", slithirProvider);

context.subscriptions.push(vscode.commands.registerCommand("slither.show_slithir", async (name, text) => {
let uri = vscode.Uri.from({ scheme: "slithir", path: text, query: name });
let doc = await vscode.workspace.openTextDocument(uri); // calls back into the provider
await vscode.window.showTextDocument(doc, { preview: true, viewColumn: vscode.ViewColumn.Beside });
}));

// If we are in debug mode, log our activation message and focus on the output channel
if (isDebuggingExtension()) {
Logger.show();
Expand Down

0 comments on commit 8769cf6

Please sign in to comment.