Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 483511

Summary: [content assist] Substring completion breaks proposal sorting
Product: [Eclipse Project] JDT Reporter: Markus Keller <markus.kell.r>
Component: TextAssignee: Noopur Gupta <noopur_gupta>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: daniel_megert, Lars.Vogel, marcel.bruch, stephan.herrmann
Version: 4.6   
Target Milestone: 4.6 M5   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 487668    

Description Markus Keller CLA 2015-12-02 14:11:54 EST
I20151201-1100

Invoke Content Assist after "s.", then type "st":

        String s = "";
        s.

When substring matches are enabled, the most relevant completions ("startWith") are not on top of the list any more. When you complete after "s.st", the proposals are sorted as expected.

=> Substring completions require Content Assist to re-compute the relevance of all proposals when the user continues typing. This is especially important when the proposal popup has been opened automatically by the auto-activation trigger on ".".
Comment 1 Stephan Herrmann CLA 2015-12-08 09:48:24 EST
Just so this example doesn't get lost:

(In reply to Stephan Herrmann from bug 481752 comment #9)
> In I20151201-1100 which contains the fix from bug 481752 comment 8 I see the following
> bad behavior:
> 
> 
> I completely typed all of these characters:
> 
>   String.valueOf(currentMethod.selector).equals("foo")
> 
> but completion changed this to
> 
>   String.copyValueOf(currentMethod.selector).contentEquals("foo")

(In reply to Stephan Herrmann from bug 481752 comment #11)
> Sorry if it wasn't clear.
> 
> Let me split into steps:
> 
> (1) Type:
>     String.valueOf
> (2) Type: 
>     (
> -> Completion inserts to become: 
>     String.copyValueOf(|)
> (3) Insert argument and continue typing until you have: 
>     String.copyValueOf(currentMethod.selector).equals
> (4) Type:
>     (
> -> Completion inserts to become:
>     String.copyValueOf(currentMethod.selector).contentEquals(|)
> 
> In both cases it picked a proposal that is a worse match than what I had
> typed up-to that point.
> 
> Disclaimer: I didn't even look at the list of proposals, because I was
> faster by just typing the 6 / 7 chars.
Comment 2 Markus Keller CLA 2015-12-08 14:15:00 EST
Just ran into this with String#equals(..):

- type "a string".
=> auto-assist opens proposals popup

- type equ
- press Enter
=> inserts contentEquals(..)
Comment 3 Noopur Gupta CLA 2016-01-12 08:52:56 EST
Fixed with: https://bugs.eclipse.org/bugs/show_bug.cgi?id=470203#c12.
Comment 4 Stephan Herrmann CLA 2016-01-25 14:01:45 EST
What exactly has been fixed here?

Using I20160125-0400 the scenario from comment 1 is still or again broken. Just try to *type* the following method:

	void test(char[] arg) {
		String.valueOf(arg).equals("foo");
	}

You can't!
It gets:

	void test(char[] arg) {
		String.copyValueOf(arg).contentEquals("foo");
	}
Comment 5 Dani Megert CLA 2016-01-26 03:40:37 EST
(In reply to Stephan Herrmann from comment #4)
> What exactly has been fixed here?
> 
> Using I20160125-0400 the scenario from comment 1 is still or again broken.
> Just try to *type* the following method:
> 
> 	void test(char[] arg) {
> 		String.valueOf(arg).equals("foo");
> 	}
> 
> You can't!
> It gets:
> 
> 	void test(char[] arg) {
> 		String.copyValueOf(arg).contentEquals("foo");
> 	}

I cannot reproduce this using this build (without any other plug-ins):
http://download.eclipse.org/eclipse/downloads/drops4/I20160125-2000/

Bug 483512 is closer to what you see, but even with 'Insert common prefixes automatically' enabled, I can't reproduce this.

If you can still reproduce the problem with I20160125-2000 or newer, then please file a new bug with more detailed steps.
Comment 6 Dani Megert CLA 2016-01-26 03:42:38 EST
(In reply to Dani Megert from comment #5)
> Bug 483512 is closer to what you see, but even with 'Insert common prefixes
> automatically' enabled, I can't reproduce this.

Sorry, that bug is not related.
Comment 7 Stephan Herrmann CLA 2016-01-26 08:17:11 EST
(In reply to Dani Megert from comment #5)
> (In reply to Stephan Herrmann from comment #4)
> > What exactly has been fixed here?
> > 
> > Using I20160125-0400 the scenario from comment 1 is still or again broken.
> > Just try to *type* the following method:
> > 
> > 	void test(char[] arg) {
> > 		String.valueOf(arg).equals("foo");
> > 	}
> > 
> > You can't!
> > It gets:
> > 
> > 	void test(char[] arg) {
> > 		String.copyValueOf(arg).contentEquals("foo");
> > 	}
> 
> I cannot reproduce this using this build (without any other plug-ins):
> http://download.eclipse.org/eclipse/downloads/drops4/I20160125-2000/

When I re-opened the bug I was sure I used a pristine SDK, workspace, project everything. When re-testing today, I see proposals sorted as intended and all works fine.

Sorry for the noise.
Comment 8 Dani Megert CLA 2016-01-26 12:12:10 EST
Verified in eclipse-SDK-I20160126-0800-win32-x86_64.