Community
Participate
Working Groups
In the next code snippet public class AutoCompleteBug { interface I { void doIt(); } class C1 implements I { public void doIt() { } } class C2 extends C1 { @Override public void doIt() { super.doIt(); } } } when te cursor is placed in C2.doIt, just before the '(' and Ctrl-space is pressed, the auto complete feature adds "Void" to the method name, resulting in class C2 extends C1 { @Override public void doItVoid() { super.doIt(); } } which is illegal. In this case the autocomplete should do nothing. Usecase and how I discovered this: I have a base class with three methods class Base { method() method_1() method_2() } In a subclass class Sub extends Base { @Override method() } I place the cursor in Sub, method 'method', just before the '(', press ctrl-space, I would like to see the following choices: method() method_1() method_2() Eclipse SDK Version: 3.2.0 Build id: I20060331-2000
Moving to jdt.core At the location there's a single proposal: Local variable 'doItVoid'. Very strange.
This completion proposal is almost valid. If the type was Object instead of void then a valid proposal would be 'doItObject'. But with void it would better to propose nothing. 'doItObject' would be valid because completion doesn't take into account characters after the completion location. So the proposals must be the same as the proposals of the following test case. ----------------------------------------- public class AutoCompleteBug { interface I { Object doIt(); } class C1 implements I { public Object doIt() { return null; } } class C2 extends C1 { @Override public void doIt // complete here } } ----------------------------------------- In this case the completed element is a field name and we compute the field name from the type of this field. But if the field type is void (as in your test case) this cannot be a field, so we should do nothing instead of propose 'doItVoid'.
Created attachment 72669 [details] Proposed fix
Released for 3.4M1. Test added CompletionTests#testCompletionVariableName39()
Verified for 3.4M1 using build I20070802-0800. Note that only the 'Void' completion is fixed (summary of the bug). In other comment 0 test case: class Base { void method() {} void method_1() {} void method_2() {} } class Sub extends Base { @Override void method // <- complete here... } there's still no completion proposal. I'm not sure if this is the expected behavior or not.