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

Java Code Templates for records and sealed types #7088

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

lkishalmi
Copy link
Contributor

Well, I've started to work with Java 17 lately also using some records. It seems while new language features are supported, there is still a way to go.

This one is trivial to add a few code templates to work with records and sealed types.

@lkishalmi lkishalmi added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Feb 20, 2024
@lkishalmi lkishalmi added this to the NB22 milestone Feb 20, 2024
Comment on lines 497 to 502
<!-- Record generation -->

<codetemplate abbreviation="prec"><code><![CDATA[${no-format}private record ${Type}(${cursor}) {}]]></code></codetemplate>
<codetemplate abbreviation="preci"><code><![CDATA[${no-format}private record ${Type}(${cursor}) implements ${classVar editable="false" currClassName default="getClass()"} {}]]></code></codetemplate>
<codetemplate abbreviation="rec"><code><![CDATA[${no-format}public record ${Type}(${cursor}) {}]]></code></codetemplate>
<codetemplate abbreviation="reci"><code><![CDATA[${no-format}public record ${Type}(${cursor}) implements ${classVar editable="false" currClassName default="getClass()"} {}]]></code></codetemplate>
Copy link
Member

Choose a reason for hiding this comment

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

how about letting rec generate record ${Type}(${cursor}) {} and purec public record ${Type}(${cursor}) {}?

Since i found declaring records inside methods is quite common, those would have no public/private modifier.

@lkishalmi
Copy link
Contributor Author

@mbien Would this be Ok with you? I went with P for public and p for private that would be mostly consistent with other abbrevs like Psfs for public static final String

@mbien
Copy link
Member

mbien commented Feb 27, 2024

@mbien Would this be Ok with you? I went with P for public and p for private that would be mostly consistent with other abbrevs like Psfs for public static final String

Yes, if this makes it more consistent to other templates - please change it as you think its best. I am no heavy template user, I probably know less than 10. But rec and lofmofsof I will probably remember ;)

@lkishalmi
Copy link
Contributor Author

The change is already there.

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

I don't use the abbreviations much either, but looks OK to me.

@lkishalmi lkishalmi merged commit ffec3dd into apache:master Mar 19, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants