import IODefinitions from '../../core/definitions.js'; import { Position } from '../../core/positions.js'; import IOError from '../../errors/io-error.js'; import Node from './nodes.js'; import '../../schema/schema.js'; import '../../schema/types/memberdef.js'; import '../../schema/schema-types.js'; /** * Error categories for styling and filtering */ type ErrorCategory = 'syntax' | 'validation' | 'runtime'; /** * ErrorNode represents a parsing error that occurred during AST construction. * This allows the parser to continue processing and collect multiple errors * instead of stopping at the first error encountered. * * @remarks * The error property accepts both IOError (preferred) and plain Error types * for backward compatibility. When IOError is used, additional properties * like errorCode, positionRange, and fact are available. */ declare class ErrorNode implements Node { /** * The error that caused this node to be created. * Prefer IOError for full type-safe access to error properties. */ readonly error: Error | IOError; readonly position: Position; readonly endPosition?: Position; constructor(error: Error | IOError, position: Position, endPosition?: Position); /** * Type guard to check if the error is an IOError. * Use this to safely access IOError-specific properties. * * @example * ```ts * if (errorNode.isIOError()) { * console.log(errorNode.error.errorCode); * } * ``` */ isIOError(): this is ErrorNode & { error: IOError; }; /** * Gets the error code if available. * Returns undefined for plain Error instances. */ get errorCode(): string | undefined; /** * Determines the error category based on the error type. * This enables UI to apply different styling (e.g., red for syntax, orange for validation). * * @returns 'syntax' for parser/syntax errors, 'validation' for schema validation errors, 'runtime' for others */ private getErrorCategory; /** * Returns error information as a value object. * This allows ErrorNodes to be serialized alongside valid nodes. * Includes error category for UI styling and errorCode when available. */ toValue(defs?: IODefinitions): any; /** * Returns the starting position of the error. */ getStartPos(): Position; /** * Returns the ending position of the error. * If no end position was provided, returns the start position. */ getEndPos(): Position; } export { type ErrorCategory, ErrorNode as default };