/
sheonn
/
ObjectScriptFormatter
Обзор
Документация
Войти
/
sheonn
/
ObjectScriptFormatter
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/extension.ts
65 строк
2 KB
Sheonn
preliminary version
19 май 2026, 11:29
19 май 2026, 11:29
ae87253
Код
Авторство
О чём код?
// The module 'vscode' contains the VS Code extensibility API // Import the module and reference it with the alias vscode in your code below import * as vscode from 'vscode'; import { createParser } from "./parser"; import { TSFormatter } from "./formatter"; // The languages we handle const targetLanguages = [ 'objectscript', 'objectscript-int', 'objectscript-class', 'objectscript-csp', 'objectscript-macros', ]; // The uri schemes we handle those languages for const targetSchemes = [ 'isfs', 'isfs-readonly', 'objectscript', 'objectscriptxml', 'file', 'vscode-remote', 'vscode-notebook-cell' ]; // A document selector to target the right {language, scheme} tuples const documentSelector: any[] = []; targetLanguages.forEach(language => { targetSchemes.forEach(scheme => { documentSelector.push({ language, scheme }); }); }); // This method is called when your extension is activated // Your extension is activated the very first time the command is executed export async function activate(context: vscode.ExtensionContext) { try { const parser = await createParser(context); if (!parser || !parser.language) { return; } const formatter = new TSFormatter(parser, parser.language); const formatProvider = { provideDocumentFormattingEdits( document: vscode.TextDocument ): vscode.TextEdit[] { const source = document.getText(); return formatter.formatCode(source); } }; context.subscriptions.push( vscode.languages.registerDocumentFormattingEditProvider(documentSelector, formatProvider) ); } catch (err) { console.error(err); vscode.window.showErrorMessage("Failed " + context.extension.id + " :" + err); } } // This method is called when your extension is deactivated export function deactivate() {}