Refactor: Java wrapper call instrumentation into focused helpers#2075
Open
shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
Open
Refactor: Java wrapper call instrumentation into focused helpers#2075shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors wrap_target_calls_with_treesitter in codeflash/languages/java/instrumentation.py to reduce complexity without changing instrumentation behavior. Issue #526
The original function handled several responsibilities in one place:
That made the function harder to review and riskier to modify, especially in a part of the codebase with a lot of exact emitted-source expectations.
What Changed
The repeated preparation and code-generation logic is now split into focused private helpers:
wrap_target_calls_with_treesitter now acts as the orchestration layer for:
Why This Is Better
This improves maintainability by:
This is intended to be a behavior-preserving refactor, not a logic change.
Behavior / Compatibility
No instrumentation behavior is intended to change.
In particular, this refactor preserves:
Validation
Results:
Both Passed


Risk
Low.
This change is a structural refactor in an area already covered by exact-string Java instrumentation tests, and the refactor preserves the original control flow rather than redesigning the instrumentation logic.