Community
Participate
Working Groups
When suggesting a completion, code completion should remember earlier completions and promote those that have been used before to the top of the list. Some examples where this makes sense: - When using a class that has a fairly long name and that starts the same as many other classes (usually connected...). - When using a class that has a names mate in a different package. The quintessential example is {java.awt.,java.util.}List. Usually the latter is the desired, but it never comes on top.
Just an example where it does not make sense: 1. type "H" + Ctrl+Space, select HelloWorld 2. type Space + "helloWorld;" ==> HelloWorld helloWorld; 3. press "return" 4. type "h" + Ctrl+Space Currently, as expected, the field "helloWorld" is the first choice. Implementing your suggestion would have the type as first choice. In my opinion an LRU based scheme for code assist does not work well. I would rather prefer to have a preference page where I can either - specify content assist filter (e.g. java.awt.*) [simple] or - fully tweak the relevance assigned to code assist proposals [complex]
It is not clear to me that it would not make sense in your example. Perhaps you want to declare several variables of the same type after one another. E.g. Complex a = new Complex(1,2); Complex b = new Complex(3,4); Complex c = Complex.multiply(a,b); Now, just because Complex goes from 15th place on the list to the top, doesn't mean that a,b and c go to 15th place (rather 2nd, 3rd and 4th). Recently used should perhaps be "recently used or declared". I think this can only be decided by trying it out.
In my example the relevance of the field helloWorld is higher than the relevance of the type and hence it is before the type. This is what people explictly requested. Your feature would override the relevance of the proposal. What about the other suggestions I made?
I don't think manually configured filters is convenient enough to be useful. I can buy that helloWorld should be ranked before HelloWorld in your example, but then HelloWorld should be ranked before any other class (since it was more recently used). (Thus my proposal is a refinement to the current behaviour) Perhaps the term "used" should include both "used as a completion", and "referenced in the current element" (method, class, whatever).
The refined proposal might work: we would only promote the LRU element to the top of its category (categories override the relevance) e.g. HelloWorld would not be higher rated than the field helloWorld because the field category comes before the type category but HelloWorld would be the first class in the type category. I adapted the summary.
Moving to JDT Core for comments: since they provide the elements and the ranking they should also keep the LRU list.
I believe this can be closed: JDT-UI now remembers chosen type proposals and increases their relevance based on the contet they are used in. The implementation doesn't help currently when there is no context (ie. expected type), but at least gives you the recently used types when assigning, filling parameters, or returning a new instance. We would need to investigate whether the MRU list should also be consulted when there is no expected type. The same concept can be applied to methods but isn't yet implemented.
Thanks Tom. Moving to JDT UI to dispose since the work was done there.
.