treesitter_analyze_file
Analyze source files to extract symbols like functions and classes. Supports Python, C, C++, and header files; optionally write results to a file to avoid context overload.
Instructions
Analyze a source code file and extract symbols (functions, classes, etc.).
Args: file_path: Path to the source code file to analyze (supports .py, .c, .cpp, .h, .hpp) output_file: If provided, writes result to this file instead of returning. Useful for large outputs to prevent context overload.
Returns: Dictionary containing: - file_path: The analyzed file path - language: Detected programming language - symbols: List of extracted symbols (functions, classes, etc.) - errors: Any parsing errors encountered OR if output_file is set: {"status": "written", "output_file": "...", "bytes_written": N}
Note: This function does not return the full AST to avoid serialization issues. Use treesitter_get_ast() if you need the complete AST.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| output_file | No |