Community
Participate
Working Groups
I20061031-0656 Content Assist for undeclared local variable should prioritize unbound names. In this example, there's a resolved binding for vDefined, but none for vUnknown. Therefore, vUnknown should have higher priority than the other. public class Tst { int vDefined; void m(final int arg) { int v // content assist proposes vDefined first System.out.println(vUnknown); System.out.println(vDefined); } }
+1
I think that vUnknown should not have higher relevance but that vDefined should not be proposed because it's an existing field.
Yes, not proposing names with an unquestionable binding would also be fine with me.
Mmh, this would destroy the following scenario/usage int foo= 3; and would like to use code assist to add foo2? Currently I can do int f<code assist> ==> int foo<type '2'>
Answer to comment 4: If i correctly understand, you want to propose 'foo' in a scenario like { int foo = 3; int fo| // do ctrl + space at | foo = 25; } and then type '2' to have { int foo = 3; int foo2 foo = 25; } For me this doesn't look like an undeclared name proposal. It look like a proposal of an already defined named and would be another feature. This new features could be useful for users and should work even of there is no undeclared name. e.g. { int foo = 3; int fo| // do ctrl + space at | } Therefore if you are agree with me, we should file a features request in JDT/Core.
I thought this would be a regression to 3.2 but since it wasn't possible there I suggest to simply go along comment 2.
I think that you mistake for this scenario class Foo { { Foo foo = null; Foo fo| // do ctrl + space at | } } In this case 'foo2' is still proposed.
Created attachment 53306 [details] Proposed fix Already defined variables won't be proposed.
Released for 3.3 M4. Test added CompletionTests#testCompletionVariableName34()
Verified for 3.3M4 with I20061211-1119