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-18 02:38:07 +00:00
|
|
|
import { workspaceIndex } from './core/WorkspaceIndex'; // <-- Index importiert
|
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-18 02:38:07 +00:00
|
|
|
// LIVE INDEXING & LINTING
|
|
|
|
|
vscode.workspace.onDidOpenTextDocument(doc => {
|
|
|
|
|
if (doc.languageId === 'tpl') {
|
|
|
|
|
workspaceIndex.updateFile(doc.uri, doc.getText());
|
|
|
|
|
validateTplDocument(doc, diagnosticCollection);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
vscode.workspace.onDidChangeTextDocument(event => {
|
|
|
|
|
if (event.document.languageId === 'tpl') {
|
|
|
|
|
workspaceIndex.updateFile(event.document.uri, event.document.getText());
|
|
|
|
|
validateTplDocument(event.document, diagnosticCollection);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Aufräumen, wenn Dateien gelöscht werden
|
|
|
|
|
vscode.workspace.onDidDeleteFiles(event => {
|
|
|
|
|
for (const uri of event.files) {
|
|
|
|
|
workspaceIndex.removeFile(uri);
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-10-09 21:14:30 +00:00
|
|
|
|
|
|
|
|
vscode.workspace.onDidChangeConfiguration(e => {
|
|
|
|
|
if (e.affectsConfiguration('tpl')) {
|
2026-10-12 19:43:46 +00:00
|
|
|
scanWorkspace(diagnosticCollection);
|
2026-10-09 21:14:30 +00:00
|
|
|
}
|
|
|
|
|
});
|
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-07 21:34:05 +00:00
|
|
|
|
2026-10-12 19:43:46 +00:00
|
|
|
context.subscriptions.push(vscode.commands.registerCommand('tpl.scanWorkspace', () => {
|
|
|
|
|
scanWorkspace(diagnosticCollection);
|
|
|
|
|
vscode.window.showInformationMessage("TPL: Workspace-Scan gestartet.");
|
|
|
|
|
}));
|
|
|
|
|
|
2026-10-18 02:38:07 +00:00
|
|
|
// Initialer Scan beim Start
|
2026-10-12 19:43:46 +00:00
|
|
|
scanWorkspace(diagnosticCollection);
|
|
|
|
|
}
|
|
|
|
|
|
2026-10-18 02:38:07 +00:00
|
|
|
// Füttert RAM und Linter
|
2026-10-12 19:43:46 +00:00
|
|
|
async function scanWorkspace(collection: vscode.DiagnosticCollection) {
|
|
|
|
|
const files = await vscode.workspace.findFiles('**/*.tpl', '**/node_modules/**');
|
|
|
|
|
|
|
|
|
|
for (const file of files) {
|
|
|
|
|
const doc = await vscode.workspace.openTextDocument(file);
|
2026-10-18 02:38:07 +00:00
|
|
|
|
|
|
|
|
// ZUERST in den RAM laden...
|
|
|
|
|
workspaceIndex.updateFile(doc.uri, doc.getText());
|
|
|
|
|
|
|
|
|
|
// ... DANN linten
|
2026-10-12 19:43:46 +00:00
|
|
|
validateTplDocument(doc, collection);
|
2026-10-08 20:02:08 +00:00
|
|
|
}
|
2026-10-07 21:34:05 +00:00
|
|
|
}
|