Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2020-05-21 18:52:14 +0000
committerAlexander Kurtakov2020-05-21 18:52:14 +0000
commitee3784aab7259c37726cc6cf026afe0d9f2f7059 (patch)
tree4335b1ef7f1669e886d6c26d78978a1bf7ae4b42
parent0def880e929be4b7c72c38b34aa8554a94614bfd (diff)
downloadrt.equinox.p2-ee3784aab7259c37726cc6cf026afe0d9f2f7059.tar.gz
rt.equinox.p2-ee3784aab7259c37726cc6cf026afe0d9f2f7059.tar.xz
rt.equinox.p2-ee3784aab7259c37726cc6cf026afe0d9f2f7059.zip
Bug 563121 - Fix p2 PatternFilter.I20200523-0600I20200522-1800
Change-Id: I61fec3df35df1774bc5586bc6354942f09482068 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java35
1 files changed, 7 insertions, 28 deletions
diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java
index 7724931da..eb2994052 100644
--- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java
+++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/PatternFilter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2017 IBM Corporation and others.
+ * Copyright (c) 2004, 2020 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -14,8 +14,9 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.ui.discovery.util;
-import java.text.BreakIterator;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
import org.eclipse.jface.viewers.*;
import org.eclipse.ui.internal.misc.StringMatcher;
@@ -58,6 +59,8 @@ public class PatternFilter extends ViewerFilter {
private static Object[] EMPTY = new Object[0];
+ private static final Pattern NON_WORD = Pattern.compile("\\W+", Pattern.UNICODE_CHARACTER_CLASS); //$NON-NLS-1$
+
@Override
public final Object[] filter(Viewer viewer, Object parent, Object[] elements) {
// we don't want to optimize if we've extended the filter ... this
@@ -270,31 +273,7 @@ public class PatternFilter extends ViewerFilter {
* @return an array of words
*/
private String[] getWords(String text) {
- List<String> words = new ArrayList<>();
- // Break the text up into words, separating based on whitespace and
- // common punctuation.
- // Previously used String.split(..., "\\W"), where "\W" is a regular
- // expression (see the Javadoc for class Pattern).
- // Need to avoid both String.split and regular expressions, in order to
- // compile against JCL Foundation (bug 80053).
- // Also need to do this in an NL-sensitive way. The use of BreakIterator
- // was suggested in bug 90579.
- BreakIterator iter = BreakIterator.getWordInstance();
- iter.setText(text);
- int i = iter.first();
- while (i != java.text.BreakIterator.DONE && i < text.length()) {
- int j = iter.following(i);
- if (j == java.text.BreakIterator.DONE) {
- j = text.length();
- }
- // match the word
- if (Character.isLetterOrDigit(text.charAt(i))) {
- String word = text.substring(i, j);
- words.add(word);
- }
- i = j;
- }
- return words.toArray(new String[words.size()]);
+ return NON_WORD.split(text, 0);
}
/**

Back to the top