7

As part of my plugin project, I'm thinking about interfacing with the content assist list displayed by Eclipse on Java files (I'm trying to re-order the list according to some external data).

I've seen some tutorials about creating a new content assist, but nothing about changing an existing one. Is that even possible? If it is, where should I start for modifying Java's Content Assist?

Oak
  • 26,231
  • 8
  • 93
  • 152

2 Answers2

3

You can change the order of the content assist items with the extionsion point org.eclipse.jdt.ui.javaCompletionProposalSorters which lets you register your own implementation of ICompletionProposalSorter.

The example below is from the plugin org.eclipse.jdt.ui which provides two completion proposal sorters:

<extension
    point="org.eclipse.jdt.ui.javaCompletionProposalSorters">
    <proposalSorter
        id="org.eclipse.jdt.ui.RelevanceSorter"
        name="%RelevanceSorter.name"
        class="org.eclipse.jdt.internal.ui.text.java.RelevanceSorter"/>
    <proposalSorter
        id="org.eclipse.jdt.ui.AlphabeticSorter"
        name="%AlphabeticSorter.name"
        class="org.eclipse.jdt.internal.ui.text.java.AlphabeticSorter"/>
</extension>

The implementations of AlphabeticSorter and RelevanceSorter might help you getting started with writing your own sorter.

Acanda
  • 672
  • 5
  • 12
3

Is that even possible?

No it's not. A good starting point for writing your own java-content assist is the Mylyn source-code. Mylyn is contributing an own (task-focussed) java content assist. Take a look at the bundle org.eclipse.mylyn.java.ui

HTH

Tom Seidel
  • 9,525
  • 1
  • 26
  • 38