UNPKG

cannabis

Version:
34 lines (33 loc) 1.94 kB
import { GeneralNode, tsMorph } from 'ts-simple-ast-extra'; /** * General definition of nodes that contemplate everything, directories, sourceFiles, and nodes, with a common minimal API */ export declare type ASTNode = GeneralNode; /** * Returns immediate children. In case of Nodes, children are obtained using forEachChild or getChildren according to * given getChildren parameter or to global config */ export declare function getASTNodeChildren(f: ASTNode, getChildren?: boolean): ASTNode[]; export declare function getASTNodeParent(f: ASTNode): ASTNode | undefined; /** * ASTNodeType are not ASTNodes, they are not part of the AST. They can only be accessed using the function 'get': * * */ export interface ASTNodeType { } export declare function getASTNodeSiblings(n: ASTNode): tsMorph.Directory[] | tsMorph.Node<tsMorph.ts.Node>[]; export declare function getASTNodeAncestors(n: ASTNode): any; /** * Gets a ASTNode that represents the SourceFile of given node, or undefined if it doesn't apply (i.e, given node is a directory). */ export declare function getASTSourceFile(f: ASTNode): ASTNode | undefined; export declare function isASTNode(f: any): f is ASTNode; export declare function getASTNodeKindName(n: ASTNode): string; export declare function getASTNodeName(node: ASTNode): string; export declare function setNodeProperty(n: ASTNode, path: string | (string | number)[], value: any): void; export declare function getNodeProperty<T = any>(n: ASTNode, path: string | (string | number)[]): T | undefined; export declare function getASTNodeText(n: ASTNode): string; export declare function getASTNodeFilePath(n: ASTNode): string; export declare function visit<T extends ASTNode = any>(n: T, v: (n: T, parent?: T | undefined, level?: number | undefined) => boolean, childrenFirst?: boolean, parent?: T, level?: number): boolean | undefined; export declare function getASTNodeDescendants(node: ASTNode): GeneralNode[];