|
Lines 8-13
Link Here
|
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
* Paul Fullbright <paul.fullbright@oracle.com> - content assist category enablement - http://bugs.eclipse.org/345213 |
10 |
* Paul Fullbright <paul.fullbright@oracle.com> - content assist category enablement - http://bugs.eclipse.org/345213 |
|
|
11 |
* Marcel Bruch <bruch@cs.tu-darmstadt.de> - [content assist] Allow to re-sort proposals - https://bugs.eclipse.org/bugs/show_bug.cgi?id=350991 |
| 11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
| 12 |
package org.eclipse.jdt.internal.ui.text.java; |
13 |
package org.eclipse.jdt.internal.ui.text.java; |
| 13 |
|
14 |
|
|
Lines 29-35
Link Here
|
| 29 |
import org.eclipse.swt.widgets.Shell; |
30 |
import org.eclipse.swt.widgets.Shell; |
| 30 |
|
31 |
|
| 31 |
import org.eclipse.core.runtime.Assert; |
32 |
import org.eclipse.core.runtime.Assert; |
|
|
33 |
import org.eclipse.core.runtime.CoreException; |
| 32 |
import org.eclipse.core.runtime.IProgressMonitor; |
34 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
35 |
import org.eclipse.core.runtime.InvalidRegistryObjectException; |
| 33 |
import org.eclipse.core.runtime.NullProgressMonitor; |
36 |
import org.eclipse.core.runtime.NullProgressMonitor; |
| 34 |
import org.eclipse.core.runtime.Platform; |
37 |
import org.eclipse.core.runtime.Platform; |
| 35 |
import org.eclipse.core.runtime.SubProgressMonitor; |
38 |
import org.eclipse.core.runtime.SubProgressMonitor; |
|
Lines 63-68
Link Here
|
| 63 |
import org.eclipse.jdt.internal.corext.util.Messages; |
66 |
import org.eclipse.jdt.internal.corext.util.Messages; |
| 64 |
|
67 |
|
| 65 |
import org.eclipse.jdt.ui.PreferenceConstants; |
68 |
import org.eclipse.jdt.ui.PreferenceConstants; |
|
|
69 |
import org.eclipse.jdt.ui.text.java.AbstractProposalSorter; |
| 66 |
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; |
70 |
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; |
| 67 |
|
71 |
|
| 68 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
72 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
|
Lines 277-292
Link Here
|
| 277 |
* @return the list of proposals |
281 |
* @return the list of proposals |
| 278 |
*/ |
282 |
*/ |
| 279 |
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) { |
283 |
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) { |
|
|
284 |
boolean needsSortingAfterFiltering= false; |
| 280 |
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>(); |
285 |
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>(); |
| 281 |
List<CompletionProposalCategory> providers= getCategories(); |
286 |
List<CompletionProposalCategory> providers= getCategories(); |
| 282 |
for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { |
287 |
for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { |
| 283 |
CompletionProposalCategory cat= it.next(); |
288 |
CompletionProposalCategory cat= it.next(); |
| 284 |
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1)); |
289 |
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1)); |
| 285 |
proposals.addAll(computed); |
290 |
proposals.addAll(computed); |
|
|
291 |
needsSortingAfterFiltering= needsSortingAfterFiltering || (cat.isSortingAfterFilteringNeeded() && !computed.isEmpty()); |
| 286 |
if (fErrorMessage == null) |
292 |
if (fErrorMessage == null) |
| 287 |
fErrorMessage= cat.getErrorMessage(); |
293 |
fErrorMessage= cat.getErrorMessage(); |
| 288 |
} |
294 |
} |
| 289 |
|
295 |
if (needsSortingAfterFiltering) |
|
|
296 |
installProposalSorter(); |
| 290 |
return proposals; |
297 |
return proposals; |
| 291 |
} |
298 |
} |
| 292 |
|
299 |
|
|
Lines 630-633
Link Here
|
| 630 |
return (KeySequence) binding; |
637 |
return (KeySequence) binding; |
| 631 |
return null; |
638 |
return null; |
| 632 |
} |
639 |
} |
|
|
640 |
|
| 641 |
/** |
| 642 |
* Installs the proposal sorter in the current completion assistant. |
| 643 |
* |
| 644 |
* @since 3.8 |
| 645 |
*/ |
| 646 |
private void installProposalSorter() { |
| 647 |
AbstractProposalSorter sorter= null; |
| 648 |
ProposalSorterHandle currentSorter= ProposalSorterRegistry.getDefault().getCurrentSorter(); |
| 649 |
try { |
| 650 |
sorter= currentSorter.getSorter(); |
| 651 |
} catch (InvalidRegistryObjectException x) { |
| 652 |
JavaPlugin.log(currentSorter.createExceptionStatus(x)); |
| 653 |
} catch (CoreException x) { |
| 654 |
JavaPlugin.log(currentSorter.createExceptionStatus(x)); |
| 655 |
} catch (RuntimeException x) { |
| 656 |
JavaPlugin.log(currentSorter.createExceptionStatus(x)); |
| 657 |
} |
| 658 |
fAssistant.setSorter(sorter); |
| 659 |
} |
| 660 |
|
| 633 |
} |
661 |
} |