Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 257381 Details for
Bug 470203
[content assist] color/style matching characters in completion proposals
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch
eclipse.jdt.ui.patch (text/plain), 8.22 KB, created by
Noopur Gupta
on 2015-10-20 09:51:48 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Noopur Gupta
Created:
2015-10-20 09:51:48 EDT
Size:
8.22 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Strings.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Strings.java >index 602adc1..ab58e5f 100644 >--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Strings.java >+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/util/Strings.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 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 >@@ -16,6 +16,7 @@ > > import org.eclipse.jface.action.LegacyActionTools; > import org.eclipse.jface.viewers.StyledString; >+import org.eclipse.jface.viewers.StyledString.Styler; > > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.DefaultLineTracker; >@@ -49,6 +50,25 @@ > > private static final String JAVA_ELEMENT_DELIMITERS= TextProcessor.getDefaultDelimiters() + "<>(),?{} "; //$NON-NLS-1$ > >+ public static void markMatchingRegions(StyledString styledString, int index, int[] matchingRegions, Styler styler) { >+ if (matchingRegions != null) { >+ int offset= -1; >+ int length= 0; >+ for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) { >+ if (offset == -1) >+ offset= index + matchingRegions[i]; >+ >+ // Concatenate adjacent regions >+ if (i + 2 < matchingRegions.length && matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) { >+ length= length + matchingRegions[i + 1]; >+ } else { >+ styledString.setStyle(offset, length + matchingRegions[i + 1], styler); >+ offset= -1; >+ length= 0; >+ } >+ } >+ } >+ } > > /** > * Adds special marks so that that the given styled string is readable in a BiDi environment. >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java >index ae491e1..afe042f 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/dialogs/FilteredTypesSelectionDialog.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2012 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 >@@ -788,7 +788,7 @@ > if (namePattern != null && !"*".equals(namePattern)) { //$NON-NLS-1$ > String typeName= index == -1 ? text : text.substring(0, index); > int[] matchingRegions= SearchPattern.getMatchingRegions(namePattern, typeName, fFilter.getMatchRule()); >- markMatchingRegions(string, 0, matchingRegions, fBoldStyler); >+ Strings.markMatchingRegions(string, 0, matchingRegions, fBoldStyler); > } > > if (index != -1) { >@@ -803,30 +803,10 @@ > else > packageName= text.substring(index, endIndex); > int[] matchingRegions= SearchPattern.getMatchingRegions(packagePattern, packageName, fFilter.getPackageFlags()); >- markMatchingRegions(string, index, matchingRegions, fBoldQualifierStyler); >+ Strings.markMatchingRegions(string, index, matchingRegions, fBoldQualifierStyler); > } > } > return string; >- } >- >- private void markMatchingRegions(StyledString string, int index, int[] matchingRegions, Styler styler) { >- if (matchingRegions != null) { >- int offset= -1; >- int length= 0; >- for (int i= 0; i + 1 < matchingRegions.length; i= i + 2) { >- if (offset == -1) >- offset= index + matchingRegions[i]; >- >- // Concatenate adjacent regions >- if (i + 2 < matchingRegions.length && matchingRegions[i] + matchingRegions[i + 1] == matchingRegions[i + 2]) { >- length= length + matchingRegions[i + 1]; >- } else { >- string.setStyle(offset, length + matchingRegions[i + 1], styler); >- offset= -1; >- length= 0; >- } >- } >- } > } > > /** >diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java >index 709824c..ea649d2 100644 >--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java >+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java >@@ -25,10 +25,12 @@ > import org.eclipse.swt.custom.StyledText; > import org.eclipse.swt.events.VerifyEvent; > import org.eclipse.swt.graphics.Color; >+import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.RGB; >+import org.eclipse.swt.graphics.TextStyle; > import org.eclipse.swt.widgets.Shell; > > import org.eclipse.core.runtime.Assert; >@@ -43,6 +45,7 @@ > import org.eclipse.jface.preference.PreferenceConverter; > import org.eclipse.jface.resource.JFaceResources; > import org.eclipse.jface.viewers.StyledString; >+import org.eclipse.jface.viewers.StyledString.Styler; > > import org.eclipse.jface.text.BadLocationException; > import org.eclipse.jface.text.BadPositionCategoryException; >@@ -86,8 +89,10 @@ > import org.eclipse.jdt.core.JavaCore; > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.compiler.CharOperation; >+import org.eclipse.jdt.core.search.SearchPattern; > > import org.eclipse.jdt.internal.corext.javadoc.JavaDocLocations; >+import org.eclipse.jdt.internal.corext.util.Strings; > > import org.eclipse.jdt.ui.PreferenceConstants; > import org.eclipse.jdt.ui.text.IJavaPartitions; >@@ -212,6 +217,8 @@ > > } > >+ private String fPrefix; >+ private int fPrefixMatchRule; > private StyledString fDisplayString; > private String fReplacementString; > private int fReplacementOffset; >@@ -230,6 +237,17 @@ > private boolean fToggleEating; > private ITextViewer fTextViewer; > >+ private final Styler BOLD_STYLER= new Styler() { >+ @Override >+ public void applyStyles(TextStyle textStyle) { >+ Font font= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); >+ FontData[] data= font.getFontData(); >+ for (int i= 0; i < data.length; i++) { >+ data[i].setStyle(SWT.BOLD); >+ } >+ textStyle.font= new Font(font.getDevice(), data); >+ } >+ }; > > /** > * The control creator. >@@ -880,8 +898,24 @@ > protected boolean isPrefix(String prefix, String string) { > if (prefix == null || string ==null || prefix.length() > string.length()) > return false; >+ int prefixMatchRule= getPrefixMatchRule(prefix, string); >+ if (prefixMatchRule != -1) { >+ fPrefix= prefix; >+ fPrefixMatchRule= prefixMatchRule; >+ return true; >+ } >+ return false; >+ } >+ >+ private int getPrefixMatchRule(String prefix, String string) { > String start= string.substring(0, prefix.length()); >- return start.equalsIgnoreCase(prefix) || isCamelCaseMatching() && CharOperation.camelCaseMatch(prefix.toCharArray(), string.toCharArray()); >+ if (start.equalsIgnoreCase(prefix)) { >+ return SearchPattern.R_PREFIX_MATCH; >+ } else if (isCamelCaseMatching() && CharOperation.camelCaseMatch(prefix.toCharArray(), string.toCharArray())) { >+ return SearchPattern.R_CAMELCASE_MATCH; >+ } else { >+ return -1; >+ } > } > > /** >@@ -1178,6 +1212,17 @@ > */ > @Override > public StyledString getStyledDisplayString() { >+ String string= fDisplayString.getString(); >+ if (fPrefix == null && fInvocationContext != null) { >+ fPrefix= getPrefix(fInvocationContext.getDocument(), fInvocationContext.getInvocationOffset()); >+ fPrefixMatchRule= getPrefixMatchRule(fPrefix, string); >+ } >+ if (fPrefix != null && !fPrefix.isEmpty()) { >+ int[] matchingRegions= SearchPattern.getMatchingRegions(fPrefix, string, fPrefixMatchRule); >+ StyledString displayString= new StyledString(string); >+ Strings.markMatchingRegions(displayString, 0, matchingRegions, BOLD_STYLER); >+ return displayString; >+ } > return fDisplayString; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 470203
:
257381
|
259148