Reputation: 629
Suppose I have the following class and respective instance:
case class Account(name: String, age: Int, amount: BigDecimal, currency: String)
Account("name", 93, 100, "USD")
Question: Is there a shortcut in IntelliJ IDEA that will generate parameter names against passed arguments, i.e.
Account(name = "name", age = 93, amount = 100, currency = "USD")
This is very useful when you have a constructor or a method taking a long list of parameters and helps to read / refactor some old code.
Please note that I am aware of Ctrl+P
showing parameter info and I am also aware of Inlay Hints
setting in IntelliJ showing the hints in the editor.
Upvotes: 4
Views: 474
Reputation: 48410
There exists intention action Use named arguments
which transforms
User("Worf")
to
User(name = "Worf")
Upvotes: 3