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 List.of(), Map.of(), and Set.of() #7102

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

lkishalmi
Copy link
Contributor

Some cheap new tricks for Java Wizards!

@lkishalmi lkishalmi added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) Editor labels Feb 24, 2024
@lkishalmi lkishalmi added this to the NB22 milestone Feb 24, 2024
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

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

lof mof sof, I like it!

@lkishalmi lkishalmi merged commit 94555c4 into apache:master Feb 26, 2024
40 checks passed
@mbien
Copy link
Member

mbien commented Feb 26, 2024

(not sure about using var for collections by default, since types often matter but it is just a template)

@mbien
Copy link
Member

mbien commented Feb 26, 2024

@lkishalmi what would you think about also adding ilof imof and isof?

@lkishalmi
Copy link
Contributor Author

(not sure about using var for collections by default, since types often matter but it is just a template)

Well, since the resulted collection is immutable, I do not think the type would really matter.

Personally I would mainly use them in education space, creating sort code for demonstration purposes, and yes they are just templates.

@lkishalmi
Copy link
Contributor Author

@lkishalmi what would you think about also adding ilof imof and isof?

Where i would stand for?

@mbien
Copy link
Member

mbien commented Feb 26, 2024

i for the interface on the left hand side.

ilof would be List<|> list = List.of()

it might have to put the cursor between <> first, since I am not quite sure how to automatically set the generics once the type is modified on the right hand side.

@lkishalmi
Copy link
Contributor Author

Could be done, I'd probably use llof, mmof, and ssoffor abbrevs.isofis pretty close to the commonly usediof`.

Also popped in my mind, that the List.copyOf(), etc would be more common with records, and then records with compact constructor...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Editor 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

2 participants