All files / providers/linting linting-provider.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31                                                             
import { IToken } from '@faubulous/mentor-rdf-parsers';
import { Diagnostic } from 'vscode-languageserver-types';
import { LintingContext } from '@src/providers/linting/linting-context';
 
/**
 * Interface for pluggable lint rules that integrate into the language server's
 * single-pass token iteration.
 *
 * The language server calls `reset` once before iterating, `visitToken` for every
 * token (in order), and `finalize` once after the last token. Providers only need
 * to implement the methods relevant to them; `reset` and `finalize` are optional.
 */
export interface LintingProvider {
	/**
	 * Called once before each document validation. Reset any per-document state here.
	 */
	reset?(): void;
 
	/**
	 * Called once per token in document order. Return any diagnostics triggered by
	 * this token. Use `context.tokens[index - 1]` / `context.tokens[index + 1]` for
	 * look-behind / look-ahead without re-iterating.
	 */
	visitToken(context: LintingContext, token: IToken, index: number): Diagnostic[];
 
	/**
	 * Called once after all tokens have been visited. Return diagnostics that require
	 * full-document context (e.g. unused-prefix hints that need all usages seen first).
	 */
	finalize?(context: LintingContext): Diagnostic[];
}