UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

60 lines (59 loc) 2.03 kB
import ts from "typescript"; import { TranslationKey } from "../../../types/translation.types"; /** * Extracts enhanced context information for translation keys */ export declare class ContextExtractor { /** * Extracts code context for a call expression * @param call The call expression node * @param sourceFile The source file * @returns Code context object */ extractContextForCall(call: ts.CallExpression, sourceFile: ts.SourceFile): { before: string; line: string; after: string; }; /** * Enhances a translation key with additional context information * @param key Translation key to enhance * @param sourceFile Source file containing the key * @returns Enhanced translation key with usage context */ enhanceKeyWithContext(key: TranslationKey, sourceFile: ts.SourceFile): TranslationKey; /** * Extracts code lines around a specific line * @param sourceFile Source file * @param lineNumber Line number (1-based) * @returns Object with before, current, and after lines */ private extractCodeLinesAround; /** * Extracts detailed usage context for a translation key * @param translationKey Translation key * @param sourceFile Source file * @returns Enhanced usage context information */ extractUsageContext(translationKey: TranslationKey, sourceFile: ts.SourceFile): { isInJSX: boolean; isInConditional: boolean; parentComponent: string | undefined; isInEventHandler: boolean; renderCount: number; }; /** * Finds the call expression node for a translation key * @param translationKey Translation key * @param sourceFile Source file * @returns Call expression node if found */ private findCallNode; /** * Analyzes the context of a node * @param node Node to analyze * @param sourceFile Source file * @returns Context analysis */ private analyzeNodeContext; }