import * as vscode from 'vscode'; import { LinterRule } from './LinterRule'; import { LinterContext } from '../LinterContext'; export class IndentationRule implements LinterRule { public checkLine(line: string, rawLine: string, lineIdx: number, ctx: LinterContext, lines: string[]): void { if (rawLine.trim().length === 0) {return;} if (rawLine.includes('\t')) {return;} // Sobald wir in Klammern oder einem Multi-Line Import sind (Visual Alignment), // greift die 4-Leerzeichen-Regel nicht! if (ctx.parenStack.length > 0 || ctx.bracketStack.length > 0 || ctx.inImportBlock) { return; } const leadingSpacesMatch = rawLine.match(/^ +/); const spaceCount = leadingSpacesMatch ? leadingSpacesMatch[0].length : 0; if (spaceCount > 0 && spaceCount % 4 !== 0) { ctx.addDiag( lineIdx, 0, spaceCount, `Invalid indentation (${spaceCount} spaces). Please use a multiple of 4. (Tip: Shift+Alt+F to auto-format)`, vscode.DiagnosticSeverity.Warning ); } } public checkEnd(lines: string[], ctx: LinterContext): void { // empty } }