Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoopur Gupta2015-11-20 15:48:26 +0000
committerDani Megert2015-12-07 14:08:04 +0000
commited9bc992c5e7369f0146149b6431951010069c3e (patch)
treec0ffc7d167694df7c35a312af9e1eae5befd7450 /org.eclipse.jface.text
parent0d555d0f718246a3d98a4f027a532407bb56ba0e (diff)
downloadeclipse.platform.text-ed9bc992c5e7369f0146149b6431951010069c3e.tar.gz
eclipse.platform.text-ed9bc992c5e7369f0146149b6431951010069c3e.tar.xz
eclipse.platform.text-ed9bc992c5e7369f0146149b6431951010069c3e.zip
Bug 470203: [content assist] color/style substring code completion
proposals Change-Id: I0d5876cb224206336663d24c206db4ae7b614d70 Signed-off-by: Noopur Gupta <noopur_gupta@in.ibm.com>
Diffstat (limited to 'org.eclipse.jface.text')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java9
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposal.java9
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension7.java50
3 files changed, 67 insertions, 1 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 697c52fbaf7..caae6027fbb 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
@@ -842,6 +842,15 @@ class CompletionProposalPopup implements IContentAssistListener {
try {
if (fIsColoredLabelsSupportEnabled && current instanceof ICompletionProposalExtension6) {
StyledString styledString= ((ICompletionProposalExtension6)current).getStyledDisplayString();
+ if (current instanceof ICompletionProposalExtension3 && current instanceof ICompletionProposalExtension7) {
+ Font font;
+ if (Helper.okToUse(fProposalShell)) {
+ font= fProposalShell.getFont();
+ } else {
+ font= JFaceResources.getDefaultFont();
+ }
+ styledString= ((ICompletionProposalExtension7)current).emphasizeMatch(fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset, font);
+ }
displayString= styledString.getString();
styleRanges= styledString.getStyleRanges();
} else
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 47fb65e22ff..29b3372318b 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, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 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
@@ -65,6 +65,13 @@ import org.eclipse.jface.text.IDocument;
* <li>Allow styled ranges in the display string.</li>
* </ul>
* </li>
+ * <li>{@link org.eclipse.jface.text.contentassist.ICompletionProposalExtension7} since version 3.11 introducing
+ * the following function:
+ * <ul>
+ * <li>Emphasize ranges in the styled display string of the proposal that match the token at the
+ * current caret offset.</li>
+ * </ul>
+ * </li>
* </ul>
* </p>
* <p>
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
new file mode 100644
index 00000000000..cdb6604bfa9
--- /dev/null
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ICompletionProposalExtension7.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jface.text.contentassist;
+
+import org.eclipse.swt.graphics.Font;
+
+import org.eclipse.jface.viewers.StyledString;
+
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * Extends the functionality of {@link org.eclipse.jface.text.contentassist.ICompletionProposal}
+ * with the following function:
+ * <ul>
+ * <li>Emphasize ranges in the styled display string of the proposal that match the token at the
+ * 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.
+ * </p>
+ *
+ * @since 3.11
+ */
+public interface ICompletionProposalExtension7 {
+ /**
+ * Returns the styled display string for this proposal with emphasized ranges that match the
+ * token at the current caret offset. This can for example be used to emphasize prefix, camel
+ * case or substring matches in the display string. Clients can emphasize the matches using any
+ * font style. It is encouraged to use the bold font as the style.
+ *
+ * @param document the document where content assist is invoked
+ * @param offset the offset in the document at current caret location
+ * @param font the font used to display this completion proposal
+ *
+ * @return the styled display string for this proposal with emphasized ranges matching the token
+ * at the given offset
+ */
+ StyledString emphasizeMatch(IDocument document, int offset, Font font);
+}

Back to the top