1
votes

The following example code behaves nicely with Content Assist:

public void test(String a) {
    String b =
}

With the cursor placed after the =, Eclipse will suggest a at the top of the Content Assist.

The following will not behave nicely:

public void test(CustomType a) {
    CustomType b =
}

Instead of a being on top, instead CustomType will be on top, with a just below it. Why is this? It's driving me crazy. It clearly knows that a is relevant, so why suggest the class? I can't assign a variable of type A to the class A.

I can get around the suggestion by disabling Java Proposals (any of them) and enabling Java Non-Type Proposals in the Advanced settings of the Content Assist. However, this has the downside of disabling auto completion for types completely, which is even worse.

I've noticed this problem in Luna, Mars, and Neon.

Is it a bug? Is there a workaround for this?

1
Is there already an import statement for CustomType? - nitind
Yes, it already appears as a parameter in the short form and the Eclipse compiler reports no errors. - Casper Færgemand
This sometimes happens even with standard Java types. I've tried the above scenario with a Set<String> with the same result. Strangely, when using List<String> instead, content assist does suggest the variable a first. I suggest checking Eclipse JDT's Bugzilla whether a fitting bug already exists, if not create it. - Johannes Dorn

1 Answers

2
votes

This looks to be a bug in Eclipse's JDT.

I have created an entry in their bugzilla.

I don't think there is a workaround for this.