-
Notifications
You must be signed in to change notification settings - Fork 4k
Migrate getIn to GetNodeByDeltaPathVisitor #12812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate getIn to GetNodeByDeltaPathVisitor #12812
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR migrates the getIn method functionality from AppNode implementations to a new GetNodeByDeltaPathVisitor class, following the visitor pattern. This change replaces the recursive getIn method that was directly implemented in BlockNode and ElementNode classes.
Key changes:
- Introduces a new visitor pattern for node traversal by delta path
- Removes the
getInmethod from theAppNodeinterface and implementations - Updates all existing usages to use the new visitor pattern
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
GetNodeByDeltaPathVisitor.ts |
New visitor class that implements delta path traversal logic |
GetNodeByDeltaPathVisitor.test.ts |
Comprehensive test suite for the new visitor |
ElementNode.ts |
Removes the getIn method implementation |
BlockNode.ts |
Removes the getIn method implementation |
BlockNode.test.ts |
Updates tests to use visitor pattern via helper function |
AppRoot.ts |
Adds visitor usage and helper methods for node traversal |
AppRoot.test.ts |
Updates tests to use the new visitor pattern |
AppNode.interface.ts |
Removes getIn method from interface definition |
8f785ac to
4ee6955
Compare
eef2346 to
fbd52d2
Compare
4ee6955 to
7d9edc4
Compare
fbd52d2 to
1a8a94b
Compare
7d9edc4 to
3448d32
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
frontend/lib/src/render-tree/visitors/GetNodeByDeltaPathVisitor.ts
Outdated
Show resolved
Hide resolved
3448d32 to
b320d2a
Compare
1a8a94b to
38db539
Compare
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0000%
✅ Coverage change is within normal range. |
b320d2a to
9f84e8e
Compare
c65a132 to
1f05240
Compare
9f84e8e to
770c9d0
Compare
951bcac to
c3d6ea0
Compare
80b1478 to
97cd5f2
Compare
c3d6ea0 to
ad210aa
Compare
97cd5f2 to
0b3dd40
Compare
ad210aa to
22c1b20
Compare
0b3dd40 to
1788c2a
Compare
22c1b20 to
cfa91f3
Compare
1788c2a to
c52b408
Compare
c52b408 to
b9afac2
Compare
d7b0129 to
7b930f0
Compare
3ecb1d2 to
97426f6
Compare
7b930f0 to
0bf7c7e
Compare
| /** | ||
| * A visitor that retrieves a node at a specific delta path. | ||
| * | ||
| * This replaces the getIn method functionality from AppNode implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] I can see this context being useful at first, but maybe it is better in the PR description/commit messages and then keep the docstring referencing only the current functionality.
| ) | ||
| } | ||
|
|
||
| private addBlock( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[suggestion] not for this PR, but should this actually be called replaceNode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea. It's weird because it's aligning to delta protobuf, but this is practically a replacement.
| } | ||
|
|
||
| visitElementNode(_node: ElementNode): AppNode | undefined { | ||
| // ElementNodes are leaf nodes - they have no children to traverse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // ElementNodes are leaf nodes - they have no children to traverse | |
| // ElementNodes have no children and therefore we do not check them for the element. |
| } | ||
|
|
||
| if (remainingPath.length === 0) { | ||
| // Base case: we're at the target location, return the child |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Perhaps
// Base case: we've consumed the entire path (at target location), return the target node
| return node.children[currentIndex] | ||
| } | ||
|
|
||
| // Recursive case: continue down the path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Perhaps
// Recursive case: create a new visitor and continue traversal
97426f6 to
96013c8
Compare
0bf7c7e to
dc7d050
Compare
96013c8 to
4e7ec2f
Compare

Describe your changes
A little more complicated than the ElementSet Visitor, but this change updates the getIn Method to a GetNodeByDeltaPath visitor.
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.