Skip to content

Refactor: Extract replaceIdentifierReferences and remove reliance on this in ASTCallbacks#8728

Open
LalitNarayanYadav wants to merge 1 commit intoprocessing:dev-2.0from
LalitNarayanYadav:refactor/strands-transpiler-pipeline
Open

Refactor: Extract replaceIdentifierReferences and remove reliance on this in ASTCallbacks#8728
LalitNarayanYadav wants to merge 1 commit intoprocessing:dev-2.0from
LalitNarayanYadav:refactor/strands-transpiler-pipeline

Conversation

@LalitNarayanYadav
Copy link
Copy Markdown
Contributor

Addresses #8694

Changes:

  • Extracted replaceIdentifierReferences from ASTCallbacks into a standalone helper function
  • Removed reliance on this binding within ASTCallbacks
  • Replaced all this.replaceIdentifierReferences(...) calls with direct function calls
  • Updated internal callback references (e.g., BinaryExpression, AssignmentExpression) to use explicit ASTCallbacks references
  • Removed the inline helper implementation from ASTCallbacks

This improves modularity and makes the code easier to reason about, while preserving existing behavior.


Screenshots of the change:

N/A (non-visual refactor)


PR Checklist

  • npm run lint passes
  • Inline reference is included / updated
  • Unit tests are included / updated

@LalitNarayanYadav
Copy link
Copy Markdown
Contributor Author

This is the first incremental refactor PR for #8694.

I’ve focused on extracting replaceIdentifierReferences out of ASTCallbacks and removing reliance on this binding, without changing any transformation logic.

The goal is to make the code easier to reason about and prepare for further cleanup in smaller, reviewable steps.

Next steps (planned incremental PRs):

  • Deduplicate BinaryExpression / LogicalExpression handling
  • Introduce a guarded callback wrapper to reduce repeated ancestor checks
  • Extract shared helpers used in control flow transformations
  • Add a high-level pipeline documentation block

Happy to adjust the approach based on feedback before proceeding further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant