use of org.eclipse.jface.text.FindReplaceDocumentAdapter in project eclipse.platform.text by eclipse.
the class FindReplaceDocumentAdapterTest method testRegexRetainCase.
/*
* @since 3.4
*/
@Test
public void testRegexRetainCase() throws Exception {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fDocument);
fDocument.set("foo");
regexReplace("foo", "xyz\\Cbar\\Cfar", findReplaceDocumentAdapter);
assertEquals("xyzbarfar", fDocument.get());
fDocument.set("FOO");
regexReplace("FOO", "xyz\\Cbar\\Cfar", findReplaceDocumentAdapter);
assertEquals("xyzBARFAR", fDocument.get());
fDocument.set("Foo");
regexReplace("Foo", "xyz\\Cbar\\Cfar", findReplaceDocumentAdapter);
assertEquals("xyzBarFar", fDocument.get());
/* Current behavior - may seem strange but it's expected
* Retain case does not apply inside groups for now.
*/
fDocument.set("Foox");
regexReplace("F(oo)x", "\\C$1", findReplaceDocumentAdapter);
assertEquals("oo", fDocument.get());
fDocument.set("Foo");
regexReplace("Foo", "xyz\\Cna\\u00EFve\\xFF\\C\\xFF", findReplaceDocumentAdapter);
assertEquals("xyzNa\u00EFve\u00FF\u0178", fDocument.get());
fDocument.set("FOO");
regexReplace("FOO", "xyz\\Cna\\u00EFve\\xFF", findReplaceDocumentAdapter);
assertEquals("xyzNA\u00CFVE\u0178", fDocument.get());
fDocument.set("A");
regexReplace("A", "\\Ci", findReplaceDocumentAdapter);
assertEquals("I", fDocument.get());
Locale currentLocale = Locale.getDefault();
try {
Locale.setDefault(new Locale("tr"));
fDocument.set("A");
regexReplace("A", "\\Ci", findReplaceDocumentAdapter);
assertEquals("\u0130", fDocument.get());
fDocument.set("a");
regexReplace("a", "\\CI", findReplaceDocumentAdapter);
assertEquals("\u0131", fDocument.get());
} finally {
Locale.setDefault(currentLocale);
}
}
use of org.eclipse.jface.text.FindReplaceDocumentAdapter in project eclipse.platform.text by eclipse.
the class FindReplaceDocumentAdapterTest method _testRegexReplace.
@Test
@Ignore
public void _testRegexReplace() throws Exception {
fDocument.set("UnixWindowsMacInferred\n" + "Chars");
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fDocument);
regexReplace("Unix", "$0\\n", findReplaceDocumentAdapter);
regexReplace("(Windows)", "$1\\r\\n", findReplaceDocumentAdapter);
regexReplace("(M)ac", "\\0\\r", findReplaceDocumentAdapter);
regexReplace("(Inferred)", "\\1\\R", findReplaceDocumentAdapter);
regexReplace("Chars", "\\\\, \\xF6, \\u00F6, \\t, \\n, \\r, \\f, \\a, \\e, \\cF", findReplaceDocumentAdapter);
String text = "Unix\nWindows\r\nMac\rInferred\n\n\\, \u00F6, \u00F6, \t, \n, \r, \f, \u0007, \u001B, \u0006";
assertEquals(text, fDocument.get());
}
use of org.eclipse.jface.text.FindReplaceDocumentAdapter in project eclipse.platform.text by eclipse.
the class FindReplaceDocumentAdapterTest method testRegexReplace2.
@Test
public void testRegexReplace2() throws Exception {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fDocument);
fDocument.set("foo");
regexReplace("foo", "\\00", findReplaceDocumentAdapter);
assertEquals("foo0", fDocument.get());
fDocument.set("foo");
regexReplace("foo", "\\010", findReplaceDocumentAdapter);
assertEquals("foo10", fDocument.get());
fDocument.set("foo");
regexReplace("foo", "$00", findReplaceDocumentAdapter);
assertEquals("foo0", fDocument.get());
fDocument.set("foo");
regexReplace("foo", "$010", findReplaceDocumentAdapter);
assertEquals("foo10", fDocument.get());
}
use of org.eclipse.jface.text.FindReplaceDocumentAdapter in project eclipse.platform.text by eclipse.
the class FindReplaceDocumentAdapterTest method testRegexReplace3.
@Test
public void testRegexReplace3() throws Exception {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fDocument);
fDocument.set("foo");
regexReplace("(f)oo", "\\10", findReplaceDocumentAdapter);
assertEquals("f0", fDocument.get());
fDocument.set("foo");
regexReplace("(f)oo", "$10", findReplaceDocumentAdapter);
assertEquals("f0", fDocument.get());
}
use of org.eclipse.jface.text.FindReplaceDocumentAdapter in project eclipse.platform.text by eclipse.
the class FindReplaceDocumentAdapterTest method testFindCaretInMiddleOfWord.
@Test
public void testFindCaretInMiddleOfWord() {
FindReplaceDocumentAdapter findReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fDocument);
try {
// Find forward when caret is inside word
// $NON-NLS-1$
IRegion r = findReplaceDocumentAdapter.find(12, "TestPackage", true, false, false, false);
assertNull(r);
// Find backward when caret is inside word
// $NON-NLS-1$
r = findReplaceDocumentAdapter.find(12, "TestPackage", false, false, false, false);
assertNull(r);
} catch (BadLocationException e) {
Assert.assertTrue(false);
}
}
Aggregations