UNPKG

cannabis

Version:
29 lines (28 loc) 1.27 kB
import { ASTQQuery } from 'astq'; import { ts, tsMorph } from 'ts-simple-ast-extra'; import { ASTNode } from "../node/astNode"; import { Config } from './config'; export declare type Node = tsMorph.Node; export declare const TypeGuards: typeof tsMorph.TypeGuards; export interface QueryResult<T extends ASTNode = ASTNode> { result?: T[]; error?: Error; query?: ASTQQuery<T>; ast: ASTNode; timings: { parseAst: number; compileQuery: number; executeQuery: number; }; } /** * It will create and execute a new query defined by [[q]] on nodes defined by [[codeOrNode]] as follows. If * it's a string, then a new source file will be created with that content. If it's a ts.Node, then that node * will be used (internally creating a ts-morph node). If it's a ASTNode, it could be a Directory, a file or a * node and that will be used to issue the query. */ export declare function queryAst<T extends ASTNode = Node>(q: string, codeOrNode: string | ts.Node | ASTNode, options?: Partial<Config>): QueryResult<T>; /** * Async version of [[queryAst]]. */ export declare function queryAstAsync<T extends ASTNode = Node>(q: string, codeOrNode: string | ts.Node | ASTNode, options?: Partial<Config>): Promise<QueryResult<T>>;