2019-11-03 19:42:43 +00:00
|
|
|
import { LogLevel } from 'noicejs';
|
|
|
|
|
2019-09-11 01:08:57 +00:00
|
|
|
import { VisitorContext } from './VisitorContext';
|
2019-11-03 19:42:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a runtime error, not an exception.
|
|
|
|
*/
|
|
|
|
export interface VisitorError {
|
|
|
|
data: any;
|
|
|
|
level: LogLevel;
|
|
|
|
msg: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface VisitorResult {
|
|
|
|
changes: ReadonlyArray<any>;
|
|
|
|
errors: ReadonlyArray<any>;
|
|
|
|
}
|
2019-06-16 18:30:04 +00:00
|
|
|
|
2019-11-02 15:26:22 +00:00
|
|
|
export interface Visitor<TResult extends VisitorResult = VisitorResult> {
|
2019-06-24 03:48:07 +00:00
|
|
|
/**
|
|
|
|
* Select nodes eligible to be visited.
|
|
|
|
**/
|
|
|
|
pick(ctx: VisitorContext, root: any): Promise<Array<any>>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Visit a node.
|
|
|
|
*/
|
|
|
|
visit(ctx: VisitorContext, node: any): Promise<TResult>;
|
|
|
|
}
|