Skip to content

chore: Add util methods in WidgetRefactorUtil class #40320

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

Merged
merged 1 commit into from
Apr 25, 2025

Conversation

subrata71
Copy link
Contributor

@subrata71 subrata71 commented Apr 20, 2025

Description

EE Counterpart: https://github.com/appsmithorg/appsmith-ee/pull/7176

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14562403965
Commit: 0f601bb
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Sun, 20 Apr 2025 19:32:18 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Improved the ability to extract all widget names from a given configuration, enabling easier identification of widgets within complex layouts.

Copy link
Contributor

coderabbitai bot commented Apr 20, 2025

Walkthrough

A new utility method was introduced in the WidgetRefactorUtil class to extract all widget names from a given DSL JSON structure. This method uses a recursive approach to traverse the DSL tree, collecting widget names from each node and its children. No other logic or control flow was changed, and the addition is self-contained within the utility class.

Changes

File(s) Change Summary
app/server/appsmith-server/src/main/java/com/appsmith/server/widgets/refactors/WidgetRefactorUtil.java Added a public method to extract widget names from a DSL JSON node using a recursive helper method.

Poem

In the forest of widgets, a new path unfurled,
Gathering names from a DSL world.
With recursion it wanders, through branches and leaves,
Collecting each widget, as quietly it weaves.
Now every widget’s name, from root to the end,
Is found in a set—a developer’s friend!
🌳🧩

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@subrata71 subrata71 requested a review from sondermanish April 20, 2025 18:54
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Apr 20, 2025
@subrata71 subrata71 added the ok-to-test Required label for CI label Apr 20, 2025
@subrata71 subrata71 self-assigned this Apr 20, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/widgets/refactors/WidgetRefactorUtil.java (4)

217-221: Handle null inputs or annotate parameter
The public API currently delegates to the recursive helper, which handles null by early returning an empty set—but the public method itself doesn’t guard or document this behavior. Consider adding an explicit null check at the start or annotating the dsl parameter with @NotNull/@Nullable to clarify the contract.


217-221: Add JavaDoc to describe behavior and edge cases
As a new public utility, please include a concise JavaDoc covering:

  • Purpose of the method
  • Parameter expectations (e.g., null handling)
  • Return value semantics (empty set if no widget names)

223-235: Use constant and guard against non-array children
Rather than hard‑coding "children", use FieldName.CHILDREN. Also, verify that the node is an ArrayNode before iterating to avoid potential NPEs if the JSON shape changes.
Apply this diff:

-        if (dsl.has("children")) {
-            dsl.get("children").forEach(child -> extractWidgetNamesRecursive(child, widgetNames));
-        }
+        if (dsl.has(FieldName.CHILDREN) &&
+            dsl.get(FieldName.CHILDREN).isArray()) {
+            ((ArrayNode) dsl.get(FieldName.CHILDREN))
+                .forEach(child -> extractWidgetNamesRecursive(child, widgetNames));
+        }

223-235: Add unit tests for nested and edge cases
We need coverage for:

  • Nested children structures
  • Missing or empty widgetName fields
  • Null or malformed DSL inputs
    Would you like me to draft JUnit tests for these scenarios?
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 041d189 and 0f601bb.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/widgets/refactors/WidgetRefactorUtil.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
🔇 Additional comments (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/widgets/refactors/WidgetRefactorUtil.java (2)

217-221: New method looks solid
The recursion-based approach cleanly collects widget names without side effects on existing logic.


223-235: Recursive helper is correct
The extractWidgetNamesRecursive logic is straightforward and efficient for typical DSL sizes.

@subrata71 subrata71 merged commit fdf589e into release Apr 25, 2025
52 checks passed
@subrata71 subrata71 deleted the chore/code-split-for-widget-refactoring-util branch April 25, 2025 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants