import { Token } from './index'; import { ParameterToken } from './parameter'; import { AtomToken } from './atom'; import { SyntaxToken } from './syntax'; import type { Config, LintError } from '../base'; declare interface Frame { args: Record; parent?: Frame | undefined; title: string; } /** * template or magic word * * 模板或魔术字 * @classdesc `{childNodes: [AtomToken|SyntaxToken, ...AtomToken[], ...ParameterToken[]]}` */ export declare abstract class TranscludeToken extends Token { #private; readonly modifier: string; readonly name: string; readonly childNodes: readonly [AtomToken | SyntaxToken, ...ParameterToken[]] | readonly [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]]; abstract get firstChild(): AtomToken | SyntaxToken; abstract get lastChild(): AtomToken | SyntaxToken | ParameterToken; abstract get children(): [AtomToken | SyntaxToken, ...ParameterToken[]] | [SyntaxToken, AtomToken, AtomToken, ...ParameterToken[]]; abstract get firstElementChild(): AtomToken | SyntaxToken; abstract get lastElementChild(): AtomToken | SyntaxToken | ParameterToken; get type(): 'template' | 'magic-word'; /** * module name * * 模块名 * @since v1.21.0 */ get module(): string | undefined; /** * function name * * 函数名 * @since v1.21.2 */ get function(): string | undefined; /** whether to contain duplicated parameters / 是否存在重复参数 */ get duplication(): boolean; set duplication(duplication: boolean); /** * number of anonymous parameters * * 匿名参数的个数 * @since v1.36.0 */ get anonCount(): number; /** * @param title 模板标题或魔术字 * @param parts 参数各部分 * @throws `SyntaxError` 非法的模板名称 */ constructor(title: string, parts: ([string] | [string | number, string])[], config: Config, accum?: Token[]); /** * Set the transclusion modifier * * 设置引用修饰符 * @param modifier transclusion modifier / 引用修饰符 */ setModifier(modifier: string): boolean; /** * Check if it is a template or a module * * 是否是模板或模块 */ isTemplate(): boolean; /** * @override * @param token node to be inserted / 待插入的子节点 * @param i position to be inserted at / 插入位置 */ insertAt(token: T, i?: number): T; /** * Get parameters with the specified name * * 获取指定参数 * @param key parameter name / 参数名 * @param exact whether to match anonymosity / 是否匹配匿名性 * @param copy whether to return a copy / 是否返回一个备份 * @param init whether to initialize during parsing / 是否在解析时进行初始化 */ getArgs(key: string | number, exact?: boolean, copy?: boolean, init?: boolean): Set; /** * Get duplicated parameters * * 获取重名参数 * @throws `Error` 仅用于模板 */ getDuplicatedArgs(): [string, ParameterToken[]][]; /** * Get possible values of some magic words * * 对特定魔术字获取可能的取值 * @throws `Error` 不是可接受的魔术字 */ getPossibleValues(): Token[]; cloneNode(): this; /** * Convert to substitution * * 替换引用 */ subst(): void; /** * Convert to safe substitution * * 安全的替换引用 */ safesubst(): void; /** * @override * @param i position of the child node / 移除位置 */ removeAt(i: number): ParameterToken; /** * Get all parameters * * 获取所有参数 */ getAllArgs(): ParameterToken[]; /** * Get all anonymous parameters * * 获取所有匿名参数 */ getAnonArgs(): ParameterToken[]; /** * Check if there is a parameter with the specified name * * 是否具有某参数 * @param key parameter name / 参数名 * @param exact whether to match anonymosity / 是否匹配匿名性 */ hasArg(key: string | number, exact?: boolean): boolean; /** * Get the effective parameter with the specified name * * 获取生效的指定参数 * @param key parameter name / 参数名 * @param exact whether to match anonymosity / 是否匹配匿名性 */ getArg(key: string | number, exact?: boolean): ParameterToken | undefined; /** * Remove parameters with the specified name * * 移除指定参数 * @param key parameter name / 参数名 * @param exact whether to match anonymosity / 是否匹配匿名性 */ removeArg(key: string | number, exact?: boolean): void; /** * Get all parameter names * * 获取所有参数名 */ getKeys(): string[]; /** * Get parameter values * * 获取参数值 * @param key parameter name / 参数名 */ getValues(key: string | number): string[]; /** * Get the effective parameter value * * 获取生效的参数值 * @param key parameter name / 参数名 */ getValue(): Record; getValue(key: string | number): string | undefined; /** * Insert an anonymous parameter * * 插入匿名参数 * @param val parameter value / 参数值 * @param newline whether to append the new parameter on a new line / 是否在添加参数时另起一行 */ newAnonArg(val: string, newline?: boolean): ParameterToken; /** * Set the parameter value * * 设置参数值 * @param key parameter name / 参数名 * @param value parameter value / 参数值 * @param newline whether to append the new parameter on a new line / 是否在添加参数时另起一行 */ setValue(key: string, value: string, newline?: boolean): void; /** * Convert all anonymous parameters to named ones * * 将匿名参数改写为命名参数 * @throws `Error` 仅用于模板 */ anonToNamed(): void; /** * Replace the template name * * 替换模板名 * @param title template name / 模板名 */ replaceTemplate(title: string): void; /** * Replace the module name * * 替换模块名 * @param title module name / 模块名 */ replaceModule(title: string): void; /** * Replace the module function * * 替换模块函数 * @param func module function name / 模块函数名 */ replaceFunction(func: string): void; /** * Count duplicated parameters * * 重复参数计数 * @throws `Error` 仅用于模板 */ hasDuplicatedArgs(): number; /** * Fix duplicated parameters * @description * - Only empty parameters and identical parameters are removed with `aggressive = false`. * Anonymous parameters have a higher precedence, otherwise all anonymous parameters are converted to named ones. * - Additionally, consecutive numbered parameters are treated with `aggressive = true`. * * 修复重名参数 * @description * - `aggressive = false`时只移除空参数和全同参数,优先保留匿名参数,否则将所有匿名参数更改为命名。 * - `aggressive = true`时还会尝试处理连续的以数字编号的参数。 * @param aggressive whether to use a more risky approach / 是否使用有更大风险的修复手段 */ fixDuplication(aggressive?: boolean): string[]; /** * Escape tables inside the template * * 转义模板内的表格 */ escapeTables(): this; /** * Get the module name and module function name * * 获取模块名和模块函数名 * @since v1.16.4 * @throws `Error` 仅用于模块 */ getModule(): [string, string | undefined]; /** * Get the [frame object](https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#frame-object) * * 获取 [frame 对象](https://www.mediawiki.org/wiki/Extension:Scribunto/Lua_reference_manual#frame-object) * @param context template calling this module / 调用该模块的模板 * @since v1.22.0 * @throws `Error` 仅用于模块 */ getFrame(context?: this): Frame; } export {};