diff options
author | Dani Megert | 2012-03-14 10:11:01 +0000 |
---|---|---|
committer | Dani Megert | 2012-03-14 10:11:01 +0000 |
commit | 34c656445e49e127c5c4a4e8153b782a5731d1ce (patch) | |
tree | 6e7a4621442f1150090b69f5f3b59e54a6f17564 | |
parent | b243be1cdfecff6dc8850fd2bffd2d955808ac18 (diff) | |
download | eclipse.platform.text-34c656445e49e127c5c4a4e8153b782a5731d1ce.tar.gz eclipse.platform.text-34c656445e49e127c5c4a4e8153b782a5731d1ce.tar.xz eclipse.platform.text-34c656445e49e127c5c4a4e8153b782a5731d1ce.zip |
Polished fix for bug 350991: [content assist][api] Allow to re-sortv20120314-1011
proposals
3 files changed, 21 insertions, 21 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java index f6fb7de2ed5..b748eabe4f1 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java @@ -433,8 +433,8 @@ class CompletionProposalPopup implements IContentAssistListener { private boolean fIsColoredLabelsSupportEnabled= false; /** - * The most recent sorter. Used when sorting proposals after filtering is requested by a completion engine. The sorter may - * be <code>null</code>. + * The sorter to be used for sorting the proposals or <code>null</code> if no sorting is + * requested. * * @since 3.8 */ @@ -1118,7 +1118,9 @@ class CompletionProposalPopup implements IContentAssistListener { proposals= new ICompletionProposal[] { fEmptyProposal }; } - sortProposals(proposals); + if (fSorter != null) + sortProposals(proposals); + fFilteredProposals= proposals; final int newLen= proposals.length; if (USE_VIRTUAL) { @@ -1845,29 +1847,29 @@ class CompletionProposalPopup implements IContentAssistListener { } /** - * Sets the sorter to use when resorting is required by one of the completion engines. + * Sets the proposal sorter. * - * @param sorter the new sorter to be used, or <code>null</code> if no sorter is needed + * @param sorter the sorter to be used, or <code>null</code> if no sorting is requested * @since 3.8 + * @see ContentAssistant#setSorter(ICompletionProposalSorter) */ public void setSorter(ICompletionProposalSorter sorter) { fSorter= sorter; } /** - * Sorts the given proposal array if a sorter is configured. Does nothing otherwise. + * Sorts the given proposal array. * * @param proposals the new proposals to display in the popup window + * @throws NullPointerException if no sorter has been set * @since 3.8 */ private void sortProposals(final ICompletionProposal[] proposals) { - if (fSorter != null) { - Arrays.sort(proposals, new Comparator() { - public int compare(Object o1, Object o2) { - return fSorter.compare((ICompletionProposal)o1, - (ICompletionProposal)o2); - } - }); - } + Arrays.sort(proposals, new Comparator() { + public int compare(Object o1, Object o2) { + return fSorter.compare((ICompletionProposal)o1, + (ICompletionProposal)o2); + } + }); } } diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java index 20d78b4b0d0..56a03cdb5b5 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContentAssistant.java @@ -987,7 +987,8 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt private boolean fIsColoredLabelsSupportEnabled= false; /** - * The sorter used to sort completion proposals when filtering was triggered. + * The sorter to be used for sorting the proposals or <code>null</code> if no sorting is + * requested. * * @since 3.8 */ @@ -2471,12 +2472,10 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt } /** - * Sets the sorter used to sort proposal completions after filtering is triggered. + * Sets the proposal sorter. * - * @param sorter the sorter used for reordering the proposals, or <code>null</code> if no - * proposal reordering is needed + * @param sorter the sorter to be used, or <code>null</code> if no sorting is requested * @since 3.8 - * @see CompletionProposalPopup#setSorter(ICompletionProposalSorter) */ public void setSorter(ICompletionProposalSorter sorter) { fSorter= sorter; diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalSorter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalSorter.java index 90b08da768a..3ca673b8ac5 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalSorter.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalSorter.java @@ -30,8 +30,7 @@ public interface ICompletionProposalSorter { * @param p1 the first proposal to be compared * @param p2 the second proposal to be compared * @return a negative integer, zero, or a positive integer as the first argument is less than, - * equal to, or greater than the second. - * + * equal to, or greater than the second * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(ICompletionProposal p1, ICompletionProposal p2); |