import { StringReader } from '../utils/StringReader'; import { ClientCache } from './ClientCache'; import { ParserSuggestion } from './ParserSuggestion'; import { ParsingError } from './ParsingError'; import { Token } from './Token'; /** * Represent an argument parser. * @template T Type of the parsed data. Can be string, Selector, NBT, etc. */ export interface Parser { /** * Parse. * @param reader Input reader. */ parse(reader: StringReader, ...params: any[]): ParserResult; } /** * Represent a parsed result. * @template T Type of the parsed data. Can be a FunctionInfo, Line, etc. */ export interface ParserResult { /** * Parsed data. */ data: T; } export declare namespace ParserResult { function create(data: T): ParserResult; } export interface ValidateResult { /** * All errors occurred while the process of parsing. */ errors: ParsingError[]; /** * Local cache. */ cache: ClientCache; /** * Semantic tokens. */ tokens: Token[]; /** * Signature hints. * @example * { * fix: ['advancement'], * options: [ * ['grant', ['']], * ['revoke', ['']] * ] * } * @example * { * fix: ['setblock', ''], * options: [ * ['', ['[destroy|keep|replace]']] * ] * } */ hint: { /** * Hints for previous nodes. */ fix: string[]; /** * Hints for the current node and the following nodes. */ options: [string, string[]][]; }; } export declare namespace ValidateResult { function create(partial?: Partial): ValidateResult; } /** * ValidateResult with completions. */ export interface LegacyValidateResult extends ValidateResult { /** * Completions. */ completions: ParserSuggestion[]; } export declare namespace LegacyValidateResult { function create(partial?: Partial): LegacyValidateResult; } /** * Represent a result parsed by argument parser. * @template T Type of the parsed data. Can be a string, Selector, NBT, etc. */ export interface ArgumentParserResult extends ParserResult, LegacyValidateResult { } export declare namespace ArgumentParserResult { function create(data: T, partial?: Partial>): ArgumentParserResult; } export declare function combineArgumentParserResult(base: ArgumentParserResult, override: Partial): void;