Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2011-12-13 15:40:42 +0000
committerDani Megert2011-12-13 15:40:42 +0000
commitea87859a5d35cb349a6bc0de0278150a04f6bab2 (patch)
treeb559faa0613ae1ecfc7339f8226f9faca8a1e98f
parent449fac0b6bca86cb839deb57f948dbb3b1cccb50 (diff)
downloadeclipse.platform.text-ea87859a5d35cb349a6bc0de0278150a04f6bab2.tar.gz
eclipse.platform.text-ea87859a5d35cb349a6bc0de0278150a04f6bab2.tar.xz
eclipse.platform.text-ea87859a5d35cb349a6bc0de0278150a04f6bab2.zip
Fixed bug 348277: [api] Expose PatternConstructor
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java29
1 files changed, 27 insertions, 2 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java
index eebf23115eb..1417a673c8c 100644
--- a/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java
+++ b/org.eclipse.search/new search/org/eclipse/search/core/text/TextSearchEngine.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -8,19 +8,21 @@
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
-
package org.eclipse.search.core.text;
import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.resources.IFile;
+import org.eclipse.search.internal.core.text.PatternConstructor;
import org.eclipse.search.internal.core.text.TextSearchVisitor;
import org.eclipse.search.internal.ui.SearchPlugin;
+
/**
* A {@link TextSearchEngine} searches the content of a workspace file resources
* for matches to a given search pattern.
@@ -84,4 +86,27 @@ public abstract class TextSearchEngine {
*/
public abstract IStatus search(IFile[] scope, TextSearchRequestor requestor, Pattern searchPattern, IProgressMonitor monitor);
+
+ /**
+ * Creates a pattern for the given search string and the given options.
+ *
+ * @param pattern the search pattern. If <code>isRegex</code> is:
+ * <ul>
+ * <li><code>false</code>: a string including '*' and '?' wildcards and '\' for
+ * escaping the literals '*', '?' and '\'</li>
+ * <li><code>true</code>: a regex as specified by {@link Pattern} plus "\R" denoting
+ * a line delimiter (platform independent)</li>
+ * </ul>
+ * @param isRegex <code>true</code> if the given string follows the {@link Pattern} including
+ * "\R"
+ * @param isCaseSensitive Set to <code>true</code> to create a case insensitive pattern
+ * @return the created pattern
+ * @throws PatternSyntaxException if "\R" is at an illegal position
+ * @see Pattern
+ * @since 3.8
+ */
+ public static Pattern createPattern(String pattern, boolean isCaseSensitive, boolean isRegex) throws PatternSyntaxException {
+ return PatternConstructor.createPattern(pattern, isRegex, true, isCaseSensitive, false);
+ }
+
}

Back to the top