diff options
author | Noopur Gupta | 2016-02-22 11:48:24 +0000 |
---|---|---|
committer | Noopur Gupta | 2016-02-26 15:12:42 +0000 |
commit | 2c9d9e8dafa4d12d37e78445ec3102468faee9ff (patch) | |
tree | 240206a2339ec88d2ae9970f201c0f6db0ebea24 /org.eclipse.jface.text | |
parent | 90ec1d143b76de42d1a98c01e142ae90ebc0aec8 (diff) | |
download | eclipse.platform.text-2c9d9e8dafa4d12d37e78445ec3102468faee9ff.tar.gz eclipse.platform.text-2c9d9e8dafa4d12d37e78445ec3102468faee9ff.tar.xz eclipse.platform.text-2c9d9e8dafa4d12d37e78445ec3102468faee9ff.zip |
Fixed bug 487584: [api] clarifyI20160301-1230I20160301-0800
ICompletionProposalExtension7#emphasizeMatch(..), avoid call to
getStyledDisplayString()
Change-Id: I516fda471e8ae701c0624403c72da8d8a2a8d609
Signed-off-by: Noopur Gupta <noopur_gupta@in.ibm.com>
Diffstat (limited to 'org.eclipse.jface.text')
5 files changed, 27 insertions, 25 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 e5601468954..1fe869afdec 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 @@ -857,23 +857,23 @@ class CompletionProposalPopup implements IContentAssistListener { StyleRange[] styleRanges= null; Image image= null; try { - if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension6) { - StyledString styledString= ((ICompletionProposalExtension6)current).getStyledDisplayString(); - if (current instanceof ICompletionProposalExtension3 && current instanceof ICompletionProposalExtension7) { - if (Helper.okToUse(fProposalShell)) { - BoldStylerProvider boldStylerProvider= fContentAssistant.getBoldStylerProvider(); - if (boldStylerProvider == null) { - boldStylerProvider= new BoldStylerProvider(fProposalShell.getFont()); - fContentAssistant.setBoldStylerProvider(boldStylerProvider); - } - styledString= ((ICompletionProposalExtension7) current).emphasizeMatch(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset, - boldStylerProvider); - } + if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension7 && Helper.okToUse(fProposalShell)) { + BoldStylerProvider boldStylerProvider= fContentAssistant.getBoldStylerProvider(); + if (boldStylerProvider == null) { + boldStylerProvider= new BoldStylerProvider(fProposalShell.getFont()); + fContentAssistant.setBoldStylerProvider(boldStylerProvider); } + StyledString styledString= ((ICompletionProposalExtension7) current).getStyledDisplayString(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset, + boldStylerProvider); displayString= styledString.getString(); styleRanges= styledString.getStyleRanges(); - } else + } else if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension6) { + StyledString styledString= ((ICompletionProposalExtension6) current).getStyledDisplayString(); + displayString= styledString.getString(); + styleRanges= styledString.getStyleRanges(); + } else { displayString= current.getDisplayString(); + } } catch (RuntimeException e) { // On failures to retrieve the proposal's text, insert a dummy entry and log the error. displayString= JFaceTextMessages.getString("CompletionProposalPopup.error_retrieving_proposal"); //$NON-NLS-1$ 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 89c1e73af99..be4c49185aa 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 @@ -1353,7 +1353,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt * * @param boldStylerProvider the bold styler provider * - * @see ICompletionProposalExtension7#emphasizeMatch(IDocument, int, BoldStylerProvider) + * @see ICompletionProposalExtension7#getStyledDisplayString(IDocument, int, BoldStylerProvider) * @since 3.11 */ void setBoldStylerProvider(BoldStylerProvider boldStylerProvider) { @@ -1364,7 +1364,7 @@ public class ContentAssistant implements IContentAssistant, IContentAssistantExt * Returns the {@link BoldStylerProvider} used to emphasize matches in a proposal's styled * display string. * - * @see ICompletionProposalExtension7#emphasizeMatch(IDocument, int, BoldStylerProvider) + * @see ICompletionProposalExtension7#getStyledDisplayString(IDocument, int, BoldStylerProvider) * * @return the {@link BoldStylerProvider}, or <code>null</code> if not set * @since 3.11 diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java index 29b3372318b..cf545e9e50d 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2015 IBM Corporation and others. + * Copyright (c) 2000, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -123,7 +123,8 @@ public interface ICompletionProposal { * * @return the string to be displayed * - * @see ICompletionProposalExtension6#getStyledDisplayString() + * @see ICompletionProposalExtension6#getStyledDisplayString() + * @see ICompletionProposalExtension7#getStyledDisplayString(IDocument, int, BoldStylerProvider) */ String getDisplayString(); diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension6.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension6.java index a98bb719da9..2513317f300 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension6.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension6.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 IBM Corporation and others. + * Copyright (c) 2008, 2016 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,7 +17,7 @@ import org.eclipse.jface.viewers.StyledString; * Extends {@link org.eclipse.jface.text.contentassist.ICompletionProposal} with the following * function: * <ul> - * <li>Allow styled ranges in the display string.</li> + * <li>Allow styled ranges in the display string.</li> * </ul> * * @since 3.4 @@ -30,7 +30,10 @@ public interface ICompletionProposalExtension6 { * <p> * <strong>Note:</strong> {@link ICompletionProposal#getDisplayString()} still needs to be * correctly implemented as this method might be ignored in case of uninstalled owner draw - * support. + * support. If {@link ICompletionProposalExtension7} is implemented by this proposal then + * instead of using this method, the result from + * {@link ICompletionProposalExtension7#getStyledDisplayString(org.eclipse.jface.text.IDocument, int, BoldStylerProvider)} + * is used to display the proposal. * </p> * * @return the string builder used to display this proposal diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension7.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension7.java index 399b483000e..3ba223a7d9e 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension7.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension7.java @@ -23,10 +23,8 @@ import org.eclipse.jface.text.IDocument; * current caret offset.</li> * </ul> * <p> - * <strong>Note:</strong> This proposal needs to implement {@link ICompletionProposalExtension3} to - * receive the starting offset of the token used to invoke content assist. It also needs to - * implement {@link ICompletionProposalExtension6} to receive the styled display string of the - * proposal into which the matches can be emphasized. + * <strong>Note:</strong> {@link ICompletionProposal#getDisplayString()} still needs to be correctly + * implemented as this method might be ignored in case of uninstalled owner draw support. * </p> * * @since 3.11 @@ -45,5 +43,5 @@ public interface ICompletionProposalExtension7 { * @return the styled display string for this proposal with emphasized ranges matching the token * at the given offset */ - StyledString emphasizeMatch(IDocument document, int offset, BoldStylerProvider boldStylerProvider); + StyledString getStyledDisplayString(IDocument document, int offset, BoldStylerProvider boldStylerProvider); } |