Question

I'm in the process of implementing a task tool. As a part of this I'm making an Eclipse plug-in to reflect certain code level issues.

In the Eclipse plug-in my aim is to attach some visual aids to different Java elements according to their host task's status. I've been successful in adding multi-colored markers to the vertical ruler of the default Java editor as well as the resource icons displayed by the Overview. However, I have not been able to change the icons in the Java content assist.

At first I thought that by using the extension point org.eclipse.ui.decorators and having its enablement set as org.eclipse.jdt.core.IJavaElement, the content assistant would also be affected, as this was the case with element icons in the Overview. I've tried several other enablement classes ranging all the way to ICompletionProposal.

Since this approach, a bunch of others and extending the default Java content assist, won't work. I've decided to implement my own content assist.

The idea now is to somehow take the default Java content assist's results and run some checks on the proposed elements and in case of a match change the icon displayed in the content assist, to reflect the associated task's level.

I've tried to look through the source for Eclipse's default Java editor and the Mylyn project, but I can't understand how they provide their Java content assists and how to access / redo them.

The end result I'm looking to get: LINK

The actual question

When providing a new content assist (category) for the default Java editor in Eclipse, how does one get a list of proposals that the default Java content assistant would produce for that point?


My first question and certainly a long intro, please let me know if I should edit this in any way and most importantly thanks for all the help in advance!

-J3lly

Was it helpful?

Solution

Take a look at the following extension point : org.eclipse.jdt.ui.javaCompletionProposalComputer

To implement your own Content Assist you have to write a class that implements org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer. In your case, since you want to modify the behavior of the default Java Content Assist, you should override one of the internal implementations org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer, org.eclipse.jdt.internal.ui.text.java.JavaAllCompletionProposalComputer or any other implementation depending on which Content Assist you want to modify.

Now all you have to do is override the method computeCompletionProposals which returns the list of completion proposals. The overridden method should call super.computeCompletionProposals(...) to get the default completion proposals, then you can modify them according to your needs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top