|
Lines 63-68
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
Link Here
|
| 63 |
import org.eclipse.jdt.internal.corext.util.Messages; |
63 |
import org.eclipse.jdt.internal.corext.util.Messages; |
| 64 |
|
64 |
|
| 65 |
import org.eclipse.jdt.ui.PreferenceConstants; |
65 |
import org.eclipse.jdt.ui.PreferenceConstants; |
|
|
66 |
import org.eclipse.jdt.ui.text.java.AbstractProposalSorter; |
| 66 |
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; |
67 |
import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; |
| 67 |
|
68 |
|
| 68 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
69 |
import org.eclipse.jdt.internal.ui.JavaPlugin; |
|
Lines 277-292
public class ContentAssistProcessor implements IContentAssistProcessor {
Link Here
|
| 277 |
* @return the list of proposals |
278 |
* @return the list of proposals |
| 278 |
*/ |
279 |
*/ |
| 279 |
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) { |
280 |
private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) { |
|
|
281 |
boolean requiresReordering= false; |
| 280 |
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>(); |
282 |
List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>(); |
| 281 |
List<CompletionProposalCategory> providers= getCategories(); |
283 |
List<CompletionProposalCategory> providers= getCategories(); |
| 282 |
for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { |
284 |
for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { |
| 283 |
CompletionProposalCategory cat= it.next(); |
285 |
CompletionProposalCategory cat= it.next(); |
| 284 |
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1)); |
286 |
List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1)); |
| 285 |
proposals.addAll(computed); |
287 |
proposals.addAll(computed); |
|
|
288 |
requiresReordering|= cat.requiresReordering() && !computed.isEmpty(); |
| 286 |
if (fErrorMessage == null) |
289 |
if (fErrorMessage == null) |
| 287 |
fErrorMessage= cat.getErrorMessage(); |
290 |
fErrorMessage= cat.getErrorMessage(); |
| 288 |
} |
291 |
} |
| 289 |
|
292 |
if (requiresReordering) { |
|
|
293 |
installProposalSorter(); |
| 294 |
} |
| 290 |
return proposals; |
295 |
return proposals; |
| 291 |
} |
296 |
} |
| 292 |
|
297 |
|
|
Lines 630-633
public class ContentAssistProcessor implements IContentAssistProcessor {
Link Here
|
| 630 |
return (KeySequence) binding; |
635 |
return (KeySequence) binding; |
| 631 |
return null; |
636 |
return null; |
| 632 |
} |
637 |
} |
|
|
638 |
|
| 639 |
private void installProposalSorter() { |
| 640 |
AbstractProposalSorter sorter= null; |
| 641 |
try { |
| 642 |
sorter= ProposalSorterRegistry.getDefault().getCurrentSorter().getSorter(); |
| 643 |
} catch (Exception e) { |
| 644 |
// TODO log? What's the common approach here? |
| 645 |
} |
| 646 |
fAssistant.setSorter(sorter); |
| 647 |
} |
| 648 |
|
| 633 |
} |
649 |
} |