antlr-ng
Version:
Next generation ANTLR Tool
65 lines (64 loc) • 2.78 kB
TypeScript
import type { RecognitionException } from "antlr4ng";
import { IST } from "stringtemplate4ts";
import { ANTLRMessage } from "./ANTLRMessage.js";
import { IssueCode } from "./Issues.js";
import { ToolListener } from "./ToolListener.js";
export declare class ErrorManager {
private longMessages?;
private warningsAreErrors?;
private static readonly loadedFormats;
errors: number;
warnings: number;
/** All errors that have been generated */
errorTypes: Set<IssueCode>;
/** The group of templates that represent the current message format. */
private format;
private formatName;
private initSTListener;
private listeners;
/**
* Track separately so if someone adds a listener, it's the only one instead of it and the default stderr listener.
*/
private defaultListener;
constructor(msgFormat?: string, longMessages?: boolean | undefined, warningsAreErrors?: boolean | undefined);
static fatalInternalError(error: string, e: Error): void;
static internalError(error: string, e?: Error): void;
/** @returns The first non ErrorManager code location for generating messages. */
private static getLastNonErrorManagerCodeLocation;
formatWantsSingleLineMessage(): boolean;
getMessageTemplate(msg: ANTLRMessage): IST | null;
/**
* Raise a predefined message with some number of parameters for the StringTemplate but for which there
* is no location information possible.
*
* @param errorType The identifier of the issue.
* @param args The arguments to pass to the StringTemplate
*/
toolError(errorType: IssueCode, ...args: unknown[]): void;
toolError(errorType: IssueCode, e: Error, ...args: unknown[]): void;
grammarError(errorType: IssueCode, fileName: string, position: {
line: number;
column: number;
} | null, ...args: unknown[]): void;
addListener(tl: ToolListener): void;
removeListener(tl: ToolListener): void;
removeListeners(): void;
syntaxError(errorType: IssueCode, fileName: string, line: number, column: number, antlrException: RecognitionException | null, ...args: unknown[]): void;
info(msg: string): void;
error(msg: ANTLRMessage): void;
warning(msg: ANTLRMessage): void;
emit(msg: ANTLRMessage): void;
/**
* Return a StringTemplate that refers to the current format used for emitting messages.
*/
private getLocationFormat;
private getReportFormat;
private getMessageFormat;
/**
* The format gets reset either from the Tool if the user supplied a command line option to that effect.
* Otherwise we just use the default "antlr".
*/
private loadFormat;
/** Verify the message format template group */
private verifyFormat;
}