Bug 32960 - [content assist] Rank most frequently used completion at top of each category
Summary: [content assist] Rank most frequently used completion at top of each category
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.2 M4   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2003-02-25 09:44 EST by Simon Tardell CLA
Modified: 2005-12-16 10:34 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Tardell CLA 2003-02-25 09:44:22 EST
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.
Comment 1 Dani Megert CLA 2003-06-17 09:00:59 EDT
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]
Comment 2 Simon Tardell CLA 2003-06-17 09:42:27 EDT
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.
Comment 3 Dani Megert CLA 2003-06-17 10:05:09 EDT
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?

Comment 4 Simon Tardell CLA 2003-06-17 10:31:42 EDT
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).
Comment 5 Dani Megert CLA 2003-06-17 11:00:55 EDT
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.
Comment 6 Dani Megert CLA 2005-07-20 11:31:58 EDT
Moving to JDT Core for comments: since they provide the elements and the ranking
they should also keep the LRU list.
Comment 7 Tom Hofmann CLA 2005-12-16 07:12:16 EST
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.

Comment 8 Jerome Lanneluc CLA 2005-12-16 10:28:00 EST
Thanks Tom. Moving to JDT UI to dispose since the work was done there.
Comment 9 Dani Megert CLA 2005-12-16 10:34:17 EST
.