2026-10-07 21:34:05 +00:00
|
|
|
import * as vscode from 'vscode';
|
2026-10-11 02:31:12 +00:00
|
|
|
import { validateTplDocument } from './core/TplLinter';
|
|
|
|
|
import { TplCodeActionProvider } from './providers/TplCodeActionProvider';
|
|
|
|
|
import { TplDocumentFormatter } from './providers/TplDocumentFormatter';
|
|
|
|
|
import { TplCompletionProvider } from './providers/TplCompletionProvider';
|
|
|
|
|
import { TplHoverProvider } from './providers/TplHoverProvider';
|
2026-10-07 21:34:05 +00:00
|
|
|
|
|
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
|
|
|
const diagnosticCollection = vscode.languages.createDiagnosticCollection('tpl-scanner');
|
|
|
|
|
context.subscriptions.push(diagnosticCollection);
|
|
|
|
|
|
2026-10-11 02:31:12 +00:00
|
|
|
// Linter-Events binden
|
2026-10-07 21:34:05 +00:00
|
|
|
vscode.workspace.onDidOpenTextDocument(doc => validateTplDocument(doc, diagnosticCollection));
|
|
|
|
|
vscode.workspace.onDidChangeTextDocument(event => validateTplDocument(event.document, diagnosticCollection));
|
2026-10-09 21:14:30 +00:00
|
|
|
|
2026-10-11 02:31:12 +00:00
|
|
|
// Live-Reload für Einstellungen
|
2026-10-09 21:14:30 +00:00
|
|
|
vscode.workspace.onDidChangeConfiguration(e => {
|
|
|
|
|
if (e.affectsConfiguration('tpl')) {
|
|
|
|
|
for (const doc of vscode.workspace.textDocuments) {
|
|
|
|
|
validateTplDocument(doc, diagnosticCollection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-10-07 21:34:05 +00:00
|
|
|
|
2026-10-11 02:31:12 +00:00
|
|
|
// Provider registrieren
|
2026-10-08 20:02:08 +00:00
|
|
|
context.subscriptions.push(vscode.languages.registerCodeActionsProvider('tpl', new TplCodeActionProvider(), { providedCodeActionKinds: [vscode.CodeActionKind.QuickFix] }));
|
|
|
|
|
context.subscriptions.push(vscode.languages.registerDocumentFormattingEditProvider('tpl', new TplDocumentFormatter()));
|
|
|
|
|
context.subscriptions.push(vscode.languages.registerCompletionItemProvider('tpl', new TplCompletionProvider(), '.'));
|
|
|
|
|
context.subscriptions.push(vscode.languages.registerHoverProvider('tpl', new TplHoverProvider()));
|
|
|
|
|
|
2026-10-11 02:31:12 +00:00
|
|
|
// Bei Aktivierung offene Dokumente einmal scannen
|
2026-10-08 20:02:08 +00:00
|
|
|
for (const doc of vscode.workspace.textDocuments) {
|
|
|
|
|
validateTplDocument(doc, diagnosticCollection);
|
|
|
|
|
}
|
2026-10-07 21:34:05 +00:00
|
|
|
}
|