but how do I make intellij suggest `carList: List&...
# intellij
c
but how do I make intellij suggest
carList: List<Car>
, with java, it used to be trivial
y
how do you expect this to work? how is IDEA supposed to know that you want to declare a list variable? in Java this is trivial because types go first and you've already entered the type
c
maybe he is talking about a rename refactoring? when I invoke rename on
blah: List<Int>
it suggests
list
as name, but
ints
would also be great and
intList
too
s
@yole I’m a bit late to this party, and I don’t disagree with what you’re saying, but consider what Idea suggests while you’re typing out, say, a parameter name
If I type out
Copy code
fun foo(car
idea does suggest that the type of that param should be
Car
if I make it to
carL
, then
carList: List<E>
is suggested. from the user’s POV, marrying the two together to suggest
List<Car>
doesn’t appear too far apart
I realize this is far from “trivial” as OP may have accidentally implied, and I’m definitely not clamoring for JetBrains to make this happen - I’m just saying, I can see where the guy’s coming from here
y
parameter name suggestions work based on names which already exist in your program.
carList
will be suggested if you already have a
carList
property, variable or parameter somewhere; the fact that it's suggested as
List<E>
looks like a bug to me. what we don't and won't do is suggest all possible suffixes (
List
,
Map
,
Set
,
Producer
,
Consumer
, you get the idea) after you've entered the name of a variable which matches a class name