Skip to content

feat: add LitRenderer.withFunction migration support#35

Open
javier-godoy wants to merge 1 commit into
masterfrom
feat-33
Open

feat: add LitRenderer.withFunction migration support#35
javier-godoy wants to merge 1 commit into
masterfrom
feat-33

Conversation

@javier-godoy
Copy link
Copy Markdown
Member

@javier-godoy javier-godoy commented Jun 5, 2026

Close #33

Summary by CodeRabbit

  • New Features

    • Added support for registering LitRenderer event handlers across Vaadin versions, with automatic compatibility handling for Vaadin 25+.
  • Tests

    • Added validation tests ensuring LitRenderer event handler registration works as expected.
  • Chores

    • Updated build/tooling to support the migration and packaging workflow (internal post-processing and exclusions).

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 351a9c22-445f-4513-87f4-a98d0965c5ca

📥 Commits

Reviewing files that changed from the base of the PR and between bfc8a5d and be33f24.

📒 Files selected for processing (4)
  • pom.xml
  • src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererAsmPostProcessor.java
  • src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtension.java
  • src/test/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtensionTest.java
🚧 Files skipped from review as they are similar to previous changes (3)
  • pom.xml
  • src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererAsmPostProcessor.java
  • src/test/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtensionTest.java

Walkthrough

Adds a build-time ASM post-processor and Maven config to remap a stub LitRenderer to Vaadin's LitRenderer, a runtime LitRendererMigrationExtension.withFunction adapter that converts JSON argument types across Vaadin versions, and a JUnit test that verifies handler registration.

Changes

LitRenderer Cross-Version Support

Layer / File(s) Summary
Build-time ASM post-processor and configuration
pom.xml, src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererAsmPostProcessor.java
Maven adds asm-commons and configures patch-lit-renderer to run LitRendererAsmPostProcessor during process-classes. The post-processor remaps LitRendererMigrationExtension$LitRenderercom.vaadin.flow.data.renderer.LitRenderer, filters InnerClasses metadata, writes patched .class files, deletes the orphaned inner-class, and excludes the processor from javadoc/jar.
Runtime handler compatibility wrapper
src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtension.java
Adds withFunction(renderer, name, handler) that on Vaadin ≥25 wraps incoming Jackson ArrayNode to elemental.json.JsonArray via JsonMigration.convertToJsonValue before invoking the provided SerializableBiConsumer, otherwise delegates directly. Includes a private nested LitRenderer<SOURCE> wrapper type.
Handler registration test
src/test/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtensionTest.java
JUnit test (Vaadin 24+ gated) reflectively creates a LitRenderer, calls withFunction for "click", asserts the same renderer instance is returned, and verifies the handler was registered by locating a Map-typed field containing "click".

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers:

  • mlopezFC
  • paodb
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add LitRenderer.withFunction migration support' clearly and accurately summarizes the main change: adding a new migration helper for LitRenderer.withFunction compatibility.
Linked Issues check ✅ Passed The code implements all requirements from #33: provides LitRendererMigrationExtension.withFunction static helper, delegates to renderer.withFunction on Vaadin <25, wraps handler to convert ArrayNode to JsonArray on 25+, uses ASM post-processing to resolve LitRenderer at build time, and matches the add-on's existing elemental.json ↔ Jackson compatibility approach.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing LitRenderer.withFunction migration support: LitRendererMigrationExtension API, LitRendererAsmPostProcessor for build-time LitRenderer resolution, test coverage, and necessary pom.xml configuration. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-33

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (1)
src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtension.java (1)

6-8: 💤 Low value

Remove unused imports.

MethodHandle, MethodHandles, and MethodType are imported but never used in this class.

♻️ Proposed fix
 import com.vaadin.flow.function.SerializableBiConsumer;
 import com.vaadin.flow.server.Version;
 import elemental.json.JsonArray;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.invoke.MethodType;
 import lombok.SneakyThrows;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtension.java`
around lines 6 - 8, Remove the unused imports MethodHandle, MethodHandles, and
MethodType from the LitRendererMigrationExtension class: locate the import
statements for MethodHandle, MethodHandles, and MethodType at the top of
LitRendererMigrationExtension.java and delete them so only used imports remain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtension.java`:
- Around line 6-8: Remove the unused imports MethodHandle, MethodHandles, and
MethodType from the LitRendererMigrationExtension class: locate the import
statements for MethodHandle, MethodHandles, and MethodType at the top of
LitRendererMigrationExtension.java and delete them so only used imports remain.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: baf80680-775c-4bac-8fde-553e6e3d1da6

📥 Commits

Reviewing files that changed from the base of the PR and between 3c4fa9f and bfc8a5d.

📒 Files selected for processing (4)
  • pom.xml
  • src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererAsmPostProcessor.java
  • src/main/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtension.java
  • src/test/java/com/flowingcode/vaadin/jsonmigration/LitRendererMigrationExtensionTest.java

@javier-godoy
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@javier-godoy javier-godoy marked this pull request as ready for review June 5, 2026 19:20
@javier-godoy javier-godoy requested review from paodb and scardanzan June 5, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Do

Development

Successfully merging this pull request may close these issues.

Support LitRenderer.withFunction across Vaadin 24/25 (elemental.json JsonArray vs Jackson ArrayNode)

1 participant