UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

73 lines (72 loc) 2.83 kB
import ts from "typescript"; import { TranslationHook, TranslationCall } from "../types/translation.additional"; import { TranslationKey } from "../../../types/translation.types"; /** * Finds all translation hooks in a source file * @param sourceFile TypeScript source file * @param filePath Path to the source file * @returns Array of translation hooks found in the file */ export declare function findTranslationHooksInFile(sourceFile: ts.SourceFile, filePath: string): TranslationHook[]; /** * Finds all translation calls for a specific hook * @param sourceFile TypeScript source file * @param hookName The variable name used for translations * @returns Array of translation calls */ export declare function findTranslationCalls(sourceFile: ts.SourceFile, hookName: string): TranslationCall[]; /** * Gets the enclosing component name for a node * @param node AST node * @param sourceFile Source file containing the node * @returns The component name */ export declare function getComponentNameForNode(node: ts.Node, sourceFile: ts.SourceFile): string; /** * Analyzes the usage context of a translation call * @param node The call expression node * @param componentName The component name * @returns The usage context object */ export declare function analyzeUsageContext(node: ts.Node, componentName: string): { isInJSX: boolean; isInConditional: boolean; parentComponent: string | undefined; isInEventHandler: boolean; renderCount: number; }; /** * Processes a translation key and creates a TranslationKey object * @param keyText The translation key text * @param namespace The namespace if available * @param componentName The component name * @param call The call expression node * @param sourceFile The source file * @param filePath The file path * @returns TranslationKey object */ export declare function processTranslationKey(keyText: string, namespace: string | undefined, componentName: string, call: ts.CallExpression, sourceFile: ts.SourceFile, filePath: string): TranslationKey; /** * Gets context code for a node (line before, current line, line after) * @param node The AST node * @param sourceFile The source file * @returns Object with before, line, and after text */ export declare function getContextCode(node: ts.Node, sourceFile: ts.SourceFile): { before: string; line: string; after: string; }; /** * Creates a source file from content * @param filePath File path * @param content File content * @returns TypeScript source file */ export declare function createSourceFile(filePath: string, content: string): ts.SourceFile; /** * Determines if a file is a TypeScript/JavaScript file * @param filePath File path * @returns Boolean indicating if it's a TS/JS file */ export declare function isTypeScriptFile(filePath: string): boolean;