Skip to content
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

feat(generator-plugin-transfertypes): add generics & importing from the correct module #3318

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Lodin
Copy link
Contributor

@Lodin Lodin commented Mar 3, 2025

This pull request includes several changes across multiple files to enhance functionality and improve the codebase. The most important changes involve adding new annotations, refactoring methods, and updating dependencies. Below is a summary of the key changes:

Enhancements and New Features:

  • Added new annotation @FromModule to specify module information for transfer types in packages/java/runtime-plugin-transfertypes/src/main/java/com/vaadin/hilla/transfertypes/annotations/FromModule.java.
  • Introduced new Signal classes and corresponding test cases to handle different signal types in packages/java/parser-jvm-plugin-transfertypes/src/test/java/com/vaadin/hilla/signals/. [1] [2] [3] [4]

Code Refactoring:

  • Refactored scan method in Plugin interface to provide a default implementation in packages/java/parser-jvm-core/src/main/java/com/vaadin/hilla/parser/core/Plugin.java.
  • Updated TransferTypesPlugin to handle new signal classes and added logic to replace signal classes with local signal records in packages/java/parser-jvm-plugin-transfertypes/src/main/java/com/vaadin/hilla/parser/plugins/transfertypes/TransferTypesPlugin.java. [1] [2]

Dependency and Import Management:

  • Added necessary imports for new signal classes and annotations in TransferTypesPlugin and other related files.
  • Updated module-info.java to export the new annotations package in packages/java/runtime-plugin-transfertypes/src/main/java/module-info.java.

Testing and Validation:

  • Added comprehensive test cases for new signal functionality in packages/java/parser-jvm-plugin-transfertypes/src/test/java/com/vaadin/hilla/parser/plugins/transfertypes/signals/SignalTest.java.

These changes collectively enhance the functionality and maintainability of the codebase by introducing new features, refactoring existing methods, and ensuring proper dependency management.

@Lodin Lodin requested a review from taefi March 3, 2025 12:29
Comment on lines +10 to +12
public Signal<String> getStringSignal() {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should actually prevent this case from happening, though, it is possible in java.

Copy link
Contributor Author

@Lodin Lodin Mar 3, 2025

Choose a reason for hiding this comment

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

What do you mean? It's just a test file, isn't it? All we need is a method signature here.

Copy link
Contributor

Choose a reason for hiding this comment

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

There shouldn't be possibility of returning Signal<String>, but only its concrete implementations such as ListSignal, ValueSignal, NumberSignal for now. Not sure, where is it the correct place to put a check on this.

Copy link

sonarqubecloud bot commented Mar 3, 2025

@@ -0,0 +1,3 @@
package com.vaadin.hilla.signals;

public record Signal<T>() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

This file may not be needed, since there shouldn't be a possibility to have Signal as the return type in any endpoint methods.

Copy link
Contributor

@taefi taefi Mar 3, 2025

Choose a reason for hiding this comment

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

Not actually sure why should there be two sets of placeholder classes for the signals, one with annotations on top of them, and one without any annotations. Why wouldn't putting the newly introduced annotation on top of the actual implementation of the ListSignal, ValueSignal, NumberSignal, and others work?

if (namedSpecifier.isBlank()
&& defaultSpecifier.isBlank()) {
throw new IllegalArgumentException(String
.format("@FromImport annotation for class %s must have at least one named specifier or a default specifier",
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is typo:

Suggested change
.format("@FromImport annotation for class %s must have at least one named specifier or a default specifier",
.format("@FromModule annotation for class %s must have at least one named specifier or a default specifier",

@@ -0,0 +1,3 @@
package com.vaadin.hilla.signals;

public record Signal<T>() {}
Copy link
Contributor

@taefi taefi Mar 3, 2025

Choose a reason for hiding this comment

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

Not actually sure why should there be two sets of placeholder classes for the signals, one with annotations on top of them, and one without any annotations. Why wouldn't putting the newly introduced annotation on top of the actual implementation of the ListSignal, ValueSignal, NumberSignal, and others work?

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