Bug 102875 - [assist] code assist should propose types even if there's no initial character(s)
Summary: [assist] code assist should propose types even if there's no initial characte...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M1   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 92555
Blocks:
  Show dependency tree
 
Reported: 2005-07-06 11:44 EDT by Dani Megert CLA
Modified: 2007-06-21 09:36 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2005-07-06 11:44:20 EDT
R3.1

Have CU A.java:

class Outer {}
public class A {
        class Inner {}
	int i;
	void foo() {
		int j;
		<caret>
	}
}

Code assist returns 'i' and 'j' but not inner type 'Inner'. In addition it
should also propose 'Outer'.

This is a code assist deficiency which gets mentioned often (recently on JavaLobby).
Comment 1 David Audel CLA 2005-07-06 12:27:17 EDT
Dani - In this case, Code assist should return all types or only types in the
same compilation unit ?
Comment 2 Philipe Mulet CLA 2005-07-06 12:39:48 EDT
This behavior was changed as part of some polish work.
We could provide an option for backward compatibility. 
Comment 3 Dani Megert CLA 2005-07-06 15:10:47 EDT
All types would be too much. Those defined in the CU plus those used in the CU
would be a good guess.
Comment 4 Philipe Mulet CLA 2005-07-06 16:29:31 EDT
I would just revert the old behavior.
Now the problem is that introducing an option could be problematic for 3.1.1, so
we should simply revert the old behavior there, and make it optional only in 3.2
branch (leaving empty type completion on by default).
Comment 5 Dani Megert CLA 2005-07-07 03:15:17 EDT
>This behavior was changed as part of some polish work.
Can you explain which one that was and whether this polish work would be removed
as well? If so, we'd have to decide what's worse.
Comment 6 David Audel CLA 2005-07-07 07:09:47 EDT
The old behavior:
When completion token is empty only expected types and enclosing types are
proposed. An expected type is a type that can be guessed like inside a variable
initialization (X x = |) or an assignemnt (x = |).

The current (polish) behavior:
When completion token is empty no types are proposed, unless the completion is
inside a constructor invocation name (X x = new |) . If the completion is inside
a constructor then only expected types are proposed.

The polish item was:
Either present all types on an empty prefix or none.
The current behavior is to show only some types (parent type and current
inner types). This is irritating and lead to unwanted auto inserts. e.g bug
92555.
Comment 7 David Audel CLA 2005-09-08 10:07:14 EDT
To complete an empty token there is a lot of possibilities.
1) propose all types.
   -> too much proposals.
2) propose nothing.
   -> doesn't seems to be a good solution (bug 95505).
3) propose only expected types.
4) propose only enclosing types.
5) propose expected types and enclosing types.
   -> it is the old behavior which was removed during the 3.1 polish work.
6) propose nothing or expected types if the completion is inside a constructor name.
   -> it is the current behavior which was added during the 3.1 polish work.
7) propose expected types or propose enclosing types if there is no expected types.
8) if the completion is inside a constructor name then propose only expected
types or enclosing types if there is no expected type.
   otherwise propose enclosing type and expected type.
9) ...

For 3.2 we can add an option to switch between several of these possibilities
but for 3.1.1 we must choose only one of them.
I think that the current behavior is sufficient (6). My second choice would be
(5) or (8) but (6) is slightly better.
If the behavior is (5) or (8) then with the following test case only X will be
proposed (and inserted if automatic insertion is enabled) and this completion
will be rarely the wished one. That's why i prefer (6).
class X {
  |
}
Another reason to keep (6) is because change the current behavior could
potentially introduce some new bug in 3.1.1.

Daniel, tom, what is your opinion about that for 3.1.1 ?
Comment 8 Tom Hofmann CLA 2005-09-08 10:27:27 EDT
- I like the way it is currently (6).
- I see that other opinions are valid as well... 
- I wouldn't change for 3.1.1
- An option may make sense for 3.2
Comment 9 Dani Megert CLA 2005-09-08 11:12:34 EDT
I'd simply like to get the 3.0.2 behavior back where I get 'A', 'Inner' and
'Outer' i.e. 5) but I don't think it is something we must have for 3.1.1.

Personally I'm against adding a new preference even if we decide to go with 6)

Wasn't it possible to only change the annotation code assist scenario as
outlined in bug 92555?
Comment 10 David Audel CLA 2005-09-08 11:41:26 EDT
I removed the 3.1.1 target milestone.

Daniel - I don't understand what you mean by 'code assist scenario as
outlined in bug 92555'.

Comment 11 Dani Megert CLA 2005-09-08 11:47:29 EDT
Ah, I see: you only mentioned bug 92555 as an example and not as being the
polish item itself.
Comment 12 Dani Megert CLA 2006-07-11 06:34:15 EDT
Discussed at the JDT Summit: the original polish bug was about completion after '@' where annotation types should have been proposed or nothing and not all expected types. The polish work got extended to all empty completion scenarios which is not good. We should
- check whether the '@' scenario (bug 92555) can be improved
- bring back expected types in the other empty completion cases
Comment 13 Tom Hofmann CLA 2006-07-11 10:39:06 EDT
Perhaps I am missing something, but: expected type completion with empty prefix works fine for me in I20060704:

// 'String' gets proposed
class X {
  void m() {
    String s= new |
  }
}

The behavior requested in comment 0 is a dup of bug 95505, which was fixed by bringing expected types back (as above), but did not bring completion for inner or enclosing types back, which is a good thing IMO.

So, I believe this is fixed
Comment 14 Dani Megert CLA 2006-07-12 04:27:52 EDT
Not fixed, simply check comment 0. David, please continue as discussed at the summit.
Comment 15 Tom Hofmann CLA 2006-07-12 04:36:58 EDT
(In reply to comment #14)
> Not fixed, simply check comment 0. David, please continue as discussed at the
> summit.

Hm, as outlined in bug 95505, I think the behavior requested in comment 0 is inconsistent and arbitrary. But if I am the only one that feels this way... go ahead.
Comment 16 Dani Megert CLA 2006-07-12 04:53:23 EDT
Thanks for the blessing Tom ;-)
Comment 17 David Audel CLA 2006-07-12 09:11:09 EDT
Ok, completion engine will propose types which are in the current compilation unit.
Comment 18 David Audel CLA 2006-07-18 05:06:46 EDT
Released for 3.3 M1.

The released behavior is the old behavior: when completion token is empty, enclosing types and expected types are proposed.
Comment 19 Dani Megert CLA 2006-07-18 05:09:33 EDT
I assume that you verified not to break bug 92555.
Comment 20 David Audel CLA 2006-07-18 05:18:55 EDT
Only annotations are proposed behind a @.
Comment 21 Frederic Fusier CLA 2006-08-04 10:17:32 EDT
Verified for 3.3 M1 using build I20060804-0010.

One thing is that while verifying if bug 92555 was not broken, I noticed that
public class FooTest {
	@<|>
}
does not give any proposal and I don't know if this is the expected behavior or not...