Test Date: January 9, 2025
Successfully implemented AST context support across 10 Python tools in the code-intelligence-toolkit directory. The implementation adds the --ast-context flag to each tool, which shows hierarchical context (like TestClass(1-17) → testMethod(5-11)) for each result line.
| Tool | Status | Notes |
|---|---|---|
| find_text_v3.py | ✅ Success | Shows AST context for each search match in both Java and Python files |
| dead_code_detector.py | ✅ Success | Shows which class/method contains dead code |
| cross_file_analysis_ast.py | ✅ Success | Shows AST context for definitions and usages |
| method_analyzer_ast.py | Tool redirects to v2 which doesn't have the feature yet | |
| find_references_rg.py | ✅ Success | Shows AST context for each reference found |
| analyze_unused_methods_rg.py | ✅ Success | Shows AST context for unused methods |
| navigate.py | ✅ Success | Shows AST context when navigating to code locations |
| trace_calls.py | ✅ Success | Shows AST context in call trees |
| analyze_internal_usage.py | ✅ Success | Shows AST context for internal method usage |
| replace_text_ast.py | Has rope library issues but AST context feature is implemented |
code-intelligence-toolkit/test/TestASTContext.java:
8: [TestASTContext(6-42)]: private int counter = 0;
11: [TestASTContext(6-42)]: this.counter = 1;
18: [TestASTContext(6-42) → processData(14-20)]: counter++;
34: [TestASTContext(6-42) → getCounter(33-35)]: return counter;
method: unusedPrivateMethod
File: /path/to/TestASTContext.java:28 [TestASTContext(6-42) → unusedPrivateMethod(28-31)]
Language: java
Reason: Multiple usages found (2 references)
Code: private void unusedPrivateMethod(
Line 14 [TestASTContext(6-42) → processData(14-20)]:
>>> 14: public void processData(String orderId) {
Line 39 [TestASTContext(6-42) → main(37-41)]:
>>> 39: test.processData("ORDER123");
All tools now use the shared ast_context_finder.py module, which provides:
- Efficient caching of AST parsing results
- Support for both Python (using
astmodule) and Java (usingjavalang) - Robust Java method/class boundary detection with proper brace counting
- Structured data returns instead of string parsing
- method_analyzer_ast.py - The tool is redirected to v2 in run_any_python_tool.sh, but v2 doesn't have the AST context feature yet
- replace_text_ast.py - Has issues with the rope library version detection, but the AST context feature is properly implemented
- analyze_internal_usage.py - Only works with Java files due to its regex patterns
- Update method_analyzer_ast_v2.py with AST context support
- Fix rope library compatibility issues in replace_text_ast.py
- Consider extending analyze_internal_usage.py to support Python files