sicua
Version:
A tool for analyzing project structure and dependencies
103 lines (102 loc) • 3.42 kB
TypeScript
import ts from "typescript";
/**
* Interface representing parsed parameter information
*/
interface ParsedParameter {
name: string;
type: string;
isOptional: boolean;
hasDefaultValue: boolean;
defaultValue: string | null;
isRestParameter: boolean;
isDestructured: boolean;
destructuredProperties: string[];
}
/**
* Utility class for parsing function parameters comprehensively
*/
export declare class ParameterParser {
/**
* Parses function parameters and returns detailed information
* @param node The function-like declaration
* @returns Array of parameter name strings (for backward compatibility)
*/
parseParameters(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): string[];
/**
* Parses function parameters with detailed information
* @param node The function-like declaration
* @returns Array of detailed parameter information
*/
parseParametersDetailed(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): ParsedParameter[];
/**
* Parses a single parameter node
* @param param The parameter declaration
* @returns Detailed parameter information
*/
private parseParameter;
/**
* Extracts the parameter name, handling destructuring and rest parameters
*/
private extractParameterName;
/**
* Extracts parameter type information
*/
private extractParameterType;
/**
* Checks if a parameter is optional
*/
private isOptionalParameter;
/**
* Extracts the default value of a parameter if it exists
*/
private extractDefaultValue;
/**
* Checks if a parameter uses destructuring
*/
private isDestructuredParameter;
/**
* Extracts properties from destructured parameters
*/
private extractDestructuredProperties;
/**
* Formats object destructuring pattern for display
*/
private formatObjectDestructuring;
/**
* Safely extracts name from property name node
*/
private getNameFromPropertyName;
/**
* Formats array destructuring pattern for display
*/
private formatArrayDestructuring;
/**
* Safely extracts name from binding name node
*/
private getNameFromBindingName;
/**
* Gets parameter count including rest parameters
*/
getParameterCount(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): number;
/**
* Gets required parameter count (excluding optional and rest parameters)
*/
getRequiredParameterCount(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): number;
/**
* Checks if function has destructured parameters
*/
hasDestructuredParameters(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean;
/**
* Checks if function has rest parameters
*/
hasRestParameters(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean;
/**
* Checks if function has optional parameters
*/
hasOptionalParameters(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): boolean;
/**
* Gets the complexity score for parameters (for analysis purposes)
*/
getParameterComplexity(node: ts.FunctionDeclaration | ts.MethodDeclaration | ts.ArrowFunction): number;
}
export {};