1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 12 package org.eclipse.jface.text; 13 14 /** 15 * Extension interface for {@link org.eclipse.jface.text.IFindReplaceTarget}. 16 * <p> 17 * Extends the find replace target's <code>findAndSelect</code> and 18 * <code>replaceSelection</code> methods to allow and be aware of regular 19 * expression find/replace. 20 * 21 * @since 3.0 22 */ 23 public interface IFindReplaceTargetExtension3 { 24 25 /** 26 * Searches for a string starting at the given offset and using the specified search 27 * directives. If a string has been found it is selected and its start offset is 28 * returned. If regExSearch is <code>true</code> the findString is 29 * interpreted as a regular expression. 30 * 31 * @param offset the offset at which searching starts 32 * @param findString the specification of what should be found 33 * @param searchForward <code>true</code> searches forward, <code>false</code> backwards 34 * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search 35 * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself. 36 * Must not be used in combination with <code>regExSearch</code>. 37 * @param regExSearch if <code>true</code> findString represents a regular expression 38 * Must not be used in combination with <code>wholeWord</code>. 39 * @return the position of the specified string, or -1 if the string has not been found 40 * @throws java.util.regex.PatternSyntaxException if regExSearch is <code>true</code> and findString is an invalid regular expression 41 */ 42 int findAndSelect(int offset, String findString, boolean searchForward, boolean caseSensitive, boolean wholeWord, boolean regExSearch); 43 44 /** 45 * Replaces the currently selected range of characters with the given text. 46 * If regExReplace is <code>true</code> the text is interpreted as a 47 * regular expression that is used to process the selected text in order to 48 * produce the actual replacement of the selected text. 49 * <p> 50 * This target must be editable. Otherwise nothing happens. 51 * 52 * @param text the specification of the substitution text 53 * @param regExReplace if <code>true</code> text represents a regular 54 * expression 55 * @throws IllegalStateException in case of regular expressions, this call 56 * is not preceded by a call to <code>findAndSelect</code> 57 * @throws java.util.regex.PatternSyntaxException if regExReplace is 58 * <code>true</code> and text is an invalid regular expression 59 */ 60 void replaceSelection(String text, boolean regExReplace); 61 } 62