Skip to content

Latest commit

 

History

History
85 lines (66 loc) · 3.51 KB

File metadata and controls

85 lines (66 loc) · 3.51 KB

AST Context Feature Test Results

Test Date: January 9, 2025

Summary

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.

Test Results

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 ⚠️ Redirected 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 ⚠️ Partial Has rope library issues but AST context feature is implemented

Example Output

find_text_v3.py

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;

dead_code_detector.py

  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(

find_references_rg.py

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");

Implementation Details

All tools now use the shared ast_context_finder.py module, which provides:

  • Efficient caching of AST parsing results
  • Support for both Python (using ast module) and Java (using javalang)
  • Robust Java method/class boundary detection with proper brace counting
  • Structured data returns instead of string parsing

Known Issues

  1. 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
  2. replace_text_ast.py - Has issues with the rope library version detection, but the AST context feature is properly implemented
  3. analyze_internal_usage.py - Only works with Java files due to its regex patterns

Next Steps

  1. Update method_analyzer_ast_v2.py with AST context support
  2. Fix rope library compatibility issues in replace_text_ast.py
  3. Consider extending analyze_internal_usage.py to support Python files