Code completion in pattern matching should offer parameter names as variable names where possible
Pattern matching, especially when working with the reflection API, is harder than necessary, because the IDE gives no useful indication of the to-be-deconstructed (number of parameters, types, names, etc.) item.
Given the following example class ...
... consider this example ("|" is the position of the cursor):
Currently, no completion or suggestion is offered.
What I would like to see would be a completion using the parameter names from the definition of the class/extractor/... as a variable name:
I'm not familiar with the IDE internals so if people think this would be trivial to implement, I would give it a shot myself.
Given the following example class ...
case class Car(brand: String, model: String, make: Int)
... consider this example ("|" is the position of the cursor):
def buyingDecision(car: Car) = car match {
case Car(|
}
Currently, no completion or suggestion is offered.
What I would like to see would be a completion using the parameter names from the definition of the class/extractor/... as a variable name:
case class Car(brand: String, model: String, make: Int)
def buyingDecision(car: Car) = car match {
case Car(brand, model, make) => |
}
I'm not familiar with the IDE internals so if people think this would be trivial to implement, I would give it a shot myself.
Leave a comment
on 2012-10-18 01:11 *
By simon.ochsenreither
Description changed from Pattern matching, especiall... to Pattern matching, especiall...
on 2012-10-18 01:37 *
By simon.ochsenreither
Slightly related to #1001192.
on 2015-03-13 23:15 *
By Simon Schäfer
Eclipse version changed from All to Luna - Eclipse 4.4
Version changed from 2.1.0-M2-210 to 4.0.0
Milestone changed from Enhancements to -none-