- Update discover_functions calls to new (source, file_path) signature
- Use language-specific FunctionOptimizer subclasses in tests
- Add explicit utf-8 encoding to read_text()/write_text() for Windows
- Fix pytest fixture in TestTsJestSkipsConversion (was __init__)
- Update nonexistent file tests for source-based discover_functions
- Remove unused imports
When optimizing TypeScript class methods that call other methods from the
same class, the helper methods were being appended OUTSIDE the class
definition. This caused syntax errors because class-specific keywords like
`private` are only valid inside a class body.
Changes:
- Add _find_same_class_helpers() method to identify helper methods belonging
to the same class as the target method
- Modify extract_code_context() to include same-class helpers inside the
class wrapper and filter them from the helpers list
- Fix all JavaScript/TypeScript tests by adding export keywords to test code
so functions can be discovered by discover_functions()
- Add comprehensive tests for same-class helper extraction
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix field name mismatches: .name → .function_name, .start_line → .starting_line,
.end_line → .ending_line, .start_col → .starting_col, .end_col → .ending_col
- Fix circular imports by creating function_types.py with FunctionParent
- Add lazy language registration via _ensure_languages_registered()
- Fix macOS symlink path resolution in ImportResolver
- Update all affected code and tests to use correct FunctionToOptimize attributes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When the optimized code contains type definitions (interfaces, types) that
are already imported in the original file, the code replacer was incorrectly
adding them as new declarations because it only checked for existing
declarations, not imports.
Fix: In `_add_global_declarations_for_language`, also check for imported
names (default imports, named imports, namespace imports) and exclude them
from being added as new declarations.
This fixes the bug where imported interfaces like `TreeNode` were being
duplicated in the output even though they were already imported.
See: https://github.com/codeflash-ai/appsmith/pull/20
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>