sicua
Version:
A tool for analyzing project structure and dependencies
93 lines (92 loc) • 2.83 kB
TypeScript
import ts from "typescript";
/**
* Detailed async analysis result
*/
interface AsyncAnalysis {
isAsync: boolean;
hasExplicitAsync: boolean;
returnsPromise: boolean;
hasAwaitExpressions: boolean;
hasPromiseCreation: boolean;
hasPromiseChaining: boolean;
hasThenCatch: boolean;
asyncPatterns: string[];
awaitCount: number;
promiseMethodsUsed: string[];
}
/**
* Utility class for detecting async patterns in functions
*/
export declare class AsyncDetector {
private typeChecker?;
constructor(typeChecker?: ts.TypeChecker);
/**
* Determines if a function is async (for backward compatibility)
* @param node The function-like declaration
* @returns Boolean indicating if the function is async
*/
isAsync(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean;
/**
* Performs detailed async analysis
* @param node The function-like declaration
* @returns Detailed async analysis result
*/
analyzeAsync(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): AsyncAnalysis;
/**
* Checks if function has explicit async modifier
*/
private hasAsyncModifier;
/**
* Checks if function returns a Promise type
*/
private returnsPromiseType;
/**
* Analyzes function body for async patterns
*/
private analyzeBodyForAsyncPatterns;
/**
* Checks if a type string represents a Promise
*/
private isPromiseTypeString;
/**
* Checks if function has return statements that return Promises
*/
private hasPromiseReturns;
/**
* Checks if an expression creates or returns a Promise
*/
private isPromiseExpression;
/**
* Checks if a call expression is a Promise constructor
*/
private isPromiseConstructor;
/**
* Gets Promise static method name if the call is to Promise static method
*/
private getPromiseStaticMethod;
/**
* Gets Promise chain method name if the call is promise chaining
*/
private getPromiseChainMethod;
/**
* Identifies common async library calls
*/
private getAsyncLibraryCall;
/**
* Checks if function uses async/await pattern
*/
hasAsyncAwaitPattern(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean;
/**
* Checks if function uses Promise pattern (then/catch)
*/
hasPromisePattern(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean;
/**
* Checks if function body contains await expressions
*/
private hasAwaitInBody;
/**
* Gets async complexity score
*/
getAsyncComplexity(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): number;
}
export {};