sicua
Version:
A tool for analyzing project structure and dependencies
128 lines (127 loc) • 3.41 kB
TypeScript
import ts from "typescript";
/**
* Configuration for function name resolution
*/
interface NameResolutionConfig {
includeAnonymousIndicator: boolean;
useParentContext: boolean;
resolveComputedNames: boolean;
maxComputedNameLength: number;
fallbackPrefix: string;
}
/**
* Detailed function name information
*/
interface ResolvedFunctionName {
name: string;
isAnonymous: boolean;
isComputed: boolean;
hasParentContext: boolean;
source: FunctionNameSource;
confidence: number;
alternativeNames: string[];
}
/**
* Source of function name resolution
*/
declare enum FunctionNameSource {
DIRECT_NAME = "direct_name",
VARIABLE_DECLARATION = "variable_declaration",
PROPERTY_ASSIGNMENT = "property_assignment",
EXPORT_ASSIGNMENT = "export_assignment",
PARENT_CONTEXT = "parent_context",
COMPUTED_EXPRESSION = "computed_expression",
FALLBACK = "fallback"
}
/**
* Utility class for comprehensive function name resolution
*/
export declare class FunctionNameResolver {
private config;
constructor(config?: Partial<NameResolutionConfig>);
/**
* Resolves function name (backward compatibility)
* @param node The function-like node
* @returns Simple function name string
*/
resolveName(node: ts.Node): string;
/**
* Resolves function name with detailed information
* @param node The function-like node
* @returns Detailed name resolution result
*/
resolveNameDetailed(node: ts.Node): ResolvedFunctionName;
/**
* Tries to resolve name directly from the node
*/
private tryDirectNameResolution;
/**
* Tries to resolve name from variable declaration context
*/
private tryVariableDeclarationResolution;
/**
* Tries to resolve name from property assignment context
*/
private tryPropertyAssignmentResolution;
/**
* Tries to resolve name from export context
*/
private tryExportResolution;
/**
* Tries to resolve name from parent context
*/
private tryParentContextResolution;
/**
* Tries to resolve computed property names
*/
private tryComputedNameResolution;
/**
* Resolves property name from various property name types
*/
private resolvePropertyName;
/**
* Resolves name from destructuring pattern
*/
private resolveDestructuredName;
/**
* Gets full property access path
*/
private getFullPropertyPath;
/**
* Simplifies computed expressions for naming
*/
private simplifyComputedExpression;
/**
* Gets base file name without extension
*/
private getFileBaseName;
/**
* Capitalizes first letter of string
*/
private capitalizeFirstLetter;
/**
* Creates a low confidence result
*/
private createLowConfidenceResult;
/**
* Creates fallback result
*/
private createFallbackResult;
/**
* Creates error fallback result
*/
private createErrorFallback;
/**
* Checks if a name resolution is reliable
*/
isReliableName(resolved: ResolvedFunctionName): boolean;
/**
* Gets the best alternative name
*/
getBestAlternativeName(resolved: ResolvedFunctionName): string;
/**
* Normalizes function name for consistency
*/
normalizeName(name: string): string;
}
export {};