sicua
Version:
A tool for analyzing project structure and dependencies
87 lines (86 loc) • 3.77 kB
TypeScript
import ts from "typescript";
export declare class ASTUtils {
/**
* Gets the name of a function-like declaration
*/
static getFunctionName(node: ts.Node | ts.FunctionDeclaration | ts.ArrowFunction): string;
/**
* Finds all nodes matching a specific predicate across all source files
*/
static findNodesInFiles<T extends ts.Node>(sourceFiles: Map<string, ts.SourceFile>, predicate: (node: ts.Node) => node is T): Map<string, T[]>;
/**
* Finds all nodes matching a predicate in a single file
*/
static findNodes<T extends ts.Node>(sourceFile: ts.SourceFile, predicate: (node: ts.Node) => node is T): T[];
/**
* Gets the location info for a node with source file context
*/
static getNodeLocation(node: ts.Node, sourceFile: ts.SourceFile): {
line: number;
column: number;
};
/**
* Gets the source file for a node
*/
static getSourceFileForNode(node: ts.Node, sourceFiles: Map<string, ts.SourceFile>): ts.SourceFile | undefined;
/**
* Builds a path to a node from its ancestors
*/
static getNodePath(node: ts.Node): ts.Node[];
/**
* Gets the nearest parent matching a predicate
*/
static findNearestParent<T extends ts.Node>(node: ts.Node, predicate: (node: ts.Node) => node is T): T | undefined;
/**
* Finds all references to an identifier across all files
*/
static findReferencesInFiles(sourceFiles: Map<string, ts.SourceFile>, identifier: string): Map<string, ts.Identifier[]>;
/**
* Finds all references to an identifier in a single file
*/
static findReferences(sourceFile: ts.SourceFile, identifier: string): ts.Identifier[];
/**
* Gets all containing conditions for a node
*/
static findContainingConditions(node: ts.Node): string[];
private static findJsxConditionalAttributes;
private static findConditionsInFunction;
/**
* Gets all identifiers used in a node
*/
static findIdentifiersInFiles(sourceFiles: Map<string, ts.SourceFile>): Map<string, ts.Identifier[]>;
/**
* Gets the containing function-like declaration
*/
static getContainingFunction(node: ts.Node): ts.FunctionLikeDeclaration | undefined;
/**
* Gets the containing block scope
*/
static getContainingBlock(node: ts.Node): ts.Block | undefined;
/**
* Checks if a node represents a pure expression
*/
static isPure(node: ts.Expression): boolean;
/**
* Finds nodes across multiple files with source file context
*/
static findNodesWithContext<T extends ts.Node>(sourceFiles: Map<string, ts.SourceFile>, predicate: (node: ts.Node) => node is T): Array<{
node: T;
sourceFile: ts.SourceFile;
filePath: string;
}>;
static isErrorCreation(node: ts.Node): boolean;
static isPromiseRejection(node: ts.Node): boolean;
static isInsideCatchClause(node: ts.Node): boolean;
static isCustomErrorClass(node: ts.Node): node is ts.ClassDeclaration;
static getCustomErrorClassName(node: ts.ClassDeclaration): string | undefined;
static getFunctionNameFromNode(node: ts.Node): string;
static safeGetNodeText(node: ts.Node | undefined): string;
static safeIsArrayBindingPattern(node: ts.Node | undefined): node is ts.ArrayBindingPattern;
static isTestFile(node: ts.Node): boolean;
static isHook(node: ts.Node): node is ts.CallExpression;
static getHookName(node: ts.CallExpression): string;
static isAnalyzableFunction(node: ts.Node, typeChecker: ts.TypeChecker): node is ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction;
static isEventHandler(node: ts.Node): boolean;
static isPromiseRelated(node: ts.Node): boolean;
}