What is necessary to get classes provided via custom classpath container visible in the code completion?
I have successfully implemented a custom classpath container, that adds libraries to a project. It adds all jars in a specific folder to the build path unless there is a project with the same name in the workspace, in that case the project is referenced.
Now this obviously seems to work, when I refer to a class from one of those jars, the code compiles, but I do not see the class in the code completion suggestions. When I have the correct project in my workspace, then I see such a class in the code completion.
I have done the following steps to reach this, while I was partly considering a tutorial from IBM:
When I have added the container to a project I see the jars in the packages explorer as I expected it. (Jar there only if no corresponding project is available, Logging shows expected results)
I can use classes from jars integrated via classpath container without compiler errors, they are just not available for code completion and in Quick Fixes to add the right import. So I guess I maybe just miss contributing to some extension point.
The answer basically is: You do not need to do anything more than implementing the three parts. But you have to do it the right way.
The ClasspathContainerPreferencePage to prepare the container for adding it to the project.
The ClasspathContainer as entity getting added to the project. For this one it is really important to implement all needed methods right. For me the problem was that I returned a wrong constant value in the method getKind(). Instead of returning IClasspathEntry.CPE_CONTAINER I just needed to use IClasspathContainer.K_APPLICATION and the code completion worked out of the box:
public int getKind() {
return IClasspathContainer.K_APPLICATION;
}
And finally a ClasspathContainerInitializer for preparing and updating the container.
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