UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

83 lines (82 loc) 2.81 kB
import ts from "typescript"; import { TranslationKey } from "../../../types/translation.types"; /** * Finds translation keys used in source code with enhanced context */ export declare class TranslationKeyFinder { private translationKeys; private analyzedFiles; private contextExtractor; constructor(); /** * Finds all translation keys in source files * @param sourceFiles Map of source files to analyze * @returns Promise resolving when analysis is complete */ findAllTranslationKeys(sourceFiles: Map<string, ts.SourceFile>): Promise<void>; /** * Gets the collected translation keys * @returns Array of translation keys */ getTranslationKeys(): TranslationKey[]; /** * Analyzes a source file for translation hooks and calls * @param sourceFile Source file to analyze * @param filePath Path to the source file * @returns Analysis results with hooks and keys */ private analyzeSourceFile; /** * Processes a translation hook to find translation keys * @param hook Translation hook to process * @param sourceFile Source file * @param filePath File path * @returns Array of translation keys */ private processTranslationHook; /** * Processes a translation call to create a translation key with usage context * @param call Translation call * @param namespace Optional namespace * @param componentName Component name * @param sourceFile Source file * @param filePath File path * @returns Translation key with usage context */ private processTranslationCall; /** * Groups translation keys by file path * @returns Map of file paths to arrays of translation keys */ groupKeysByFile(): Map<string, TranslationKey[]>; /** * Finds files with the most translation keys * @param limit Maximum number of files to return * @returns Array of files sorted by key count */ findFilesWithMostKeys(limit?: number): Array<{ filePath: string; keyCount: number; keys: TranslationKey[]; }>; /** * Finds translation keys in JSX context * @returns Array of keys used in JSX */ findKeysInJSX(): TranslationKey[]; /** * Finds translation keys in conditional rendering * @returns Array of keys used in conditional rendering */ findKeysInConditionals(): TranslationKey[]; /** * Finds translation keys in event handlers * @returns Array of keys used in event handlers */ findKeysInEventHandlers(): TranslationKey[]; /** * Groups translation keys by component * @returns Map of component names to arrays of translation keys */ groupKeysByComponent(): Map<string, TranslationKey[]>; }