Skip to content

Refactor: Deduplicate BinaryExpression and LogicalExpression transformation logic#8741

Merged
davepagurek merged 2 commits into
processing:dev-2.0from
LalitNarayanYadav:refactor/strands-binary-logical-dedup
Apr 27, 2026
Merged

Refactor: Deduplicate BinaryExpression and LogicalExpression transformation logic#8741
davepagurek merged 2 commits into
processing:dev-2.0from
LalitNarayanYadav:refactor/strands-binary-logical-dedup

Conversation

@LalitNarayanYadav
Copy link
Copy Markdown
Contributor

…Addresses #8694

Changes:

  • Deduplicated transformation logic shared by BinaryExpression and LogicalExpression
  • Introduced a helper transformBinaryOrLogical to centralize the operator-to-method-call transformation
  • Replaced both AST callback handlers with references to the shared helper

This reduces duplication and improves maintainability without changing 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

@p5-bot
Copy link
Copy Markdown

p5-bot Bot commented Apr 25, 2026

Continuous Release

CDN link

Published Packages

Commit hash: 48b9509

Previous deployments

324c592


This is an automated message.

Copy link
Copy Markdown
Contributor

@davepagurek davepagurek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LalitNarayanYadav, this is a nice well-scoped change! Are you interested in continuing to chip away at this file in some more PRs?

@davepagurek davepagurek merged commit d516e81 into processing:dev-2.0 Apr 27, 2026
5 checks passed
@LalitNarayanYadav
Copy link
Copy Markdown
Contributor Author

LalitNarayanYadav commented Apr 28, 2026

Thanks @davepagurek ! Yes, absolutely, I'd love to keep going.

I'm already working on the next cleanup: introducing a makeGuardedCallbacks wrapper to eliminate the repeated uniform context guard that's currently copy-pasted across ~12 handlers in ASTCallbacks:

if (ancestors.some(a => nodeIsUniform(a) || nodeIsUniformCallbackFn(a, state.uniformCallbackNames))) {
  return;
}

The idea is to wrap each handler automatically at the point where ASTCallbacks is used, so the guard logic lives in one place rather than being repeated in every handler body. I'll open that as a follow-up PR shortly.

@LalitNarayanYadav LalitNarayanYadav deleted the refactor/strands-binary-logical-dedup branch May 4, 2026 06:23
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.

2 participants