Does anybody know the reason why the this keyword (Java) is marked as static final in the content assist in Eclipse? final makes sense to me, but why static?

The screenshot was made with Eclipse 2020-03, but I'm observing this behavior since many years.
Solution. Go to Window -> Preferences -> Editor -> Content Assist -> Advanced and enable Parsing-based Proposals. Click Apply. Content assist should start working immediately.
To enable the Content Assist window to open automatically, go to the Content Assist Preferences page, accessed from Window | Preferences | PHP | Editor | Content Assist and mark the 'Enable auto-activation' checkbox.
Open menu Window, then Preferences. Follow path Java -> Editor -> Content assist. Now mess around with the settings to find your ideal setup. I believe what you'll want is to deactivate Insert single proposals automatically.
The code doing this is in org.eclipse.jdt.internal.ui.text.java.ParameterGuesser
// add 'this'
if (currentType != null && !(fEnclosingElement instanceof IMethod && Flags.isStatic(((IMethod) fEnclosingElement).getFlags()))) {
String fullyQualifiedName= currentType.getFullyQualifiedName('.');
if (fullyQualifiedName.equals(expectedType)) {
ImageDescriptor desc= new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.FINAL | JavaElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
res.add(new Variable(fullyQualifiedName, "this", Variable.LITERALS, false, res.size(), new char[] {'.'}, desc)); //$NON-NLS-1$
}
}
The key thing in that code is
JavaElementImageDescriptor.FINAL | JavaElementImageDescriptor.STATIC
as the flags to JavaElementImageDescriptor which is hard coding the display of the static and final overlay images. So these are always displayed for this.
As to why that was chosen the code doesn't give any reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With