Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.text.tests/META-INF/MANIFEST.MF40
-rw-r--r--org.eclipse.text.tests/pom.xml2
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java26
-rw-r--r--org.eclipse.text/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.text/pom.xml2
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java10
6 files changed, 55 insertions, 27 deletions
diff --git a/org.eclipse.text.tests/META-INF/MANIFEST.MF b/org.eclipse.text.tests/META-INF/MANIFEST.MF
index c831a188653..acc31a08a3c 100644
--- a/org.eclipse.text.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.text.tests/META-INF/MANIFEST.MF
@@ -1,20 +1,20 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %Plugin.name
-Bundle-SymbolicName: org.eclipse.text.tests
-Bundle-Version: 3.11.0.qualifier
-Bundle-Vendor: %Plugin.providerName
-Bundle-Localization: plugin
-Export-Package:
- org.eclipse.text.tests,
- org.eclipse.text.tests.link,
- org.eclipse.text.tests.templates
-Require-Bundle:
- org.eclipse.core.commands;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
- org.eclipse.text;bundle-version="[3.5.0,4.0.0)",
- org.junit;bundle-version="4.12.0"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.8
-Eclipse-BundleShape: dir
-Import-Package: com.ibm.icu.text,
- com.ibm.icu.util
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Plugin.name
+Bundle-SymbolicName: org.eclipse.text.tests
+Bundle-Version: 3.12.0.qualifier
+Bundle-Vendor: %Plugin.providerName
+Bundle-Localization: plugin
+Export-Package:
+ org.eclipse.text.tests,
+ org.eclipse.text.tests.link,
+ org.eclipse.text.tests.templates
+Require-Bundle:
+ org.eclipse.core.commands;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.core.runtime;bundle-version="[3.5.0,4.0.0)",
+ org.eclipse.text;bundle-version="[3.6.3,4.0.0)",
+ org.junit;bundle-version="4.12.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Eclipse-BundleShape: dir
+Import-Package: com.ibm.icu.text,
+ com.ibm.icu.util
diff --git a/org.eclipse.text.tests/pom.xml b/org.eclipse.text.tests/pom.xml
index ed2086d062d..329216e1192 100644
--- a/org.eclipse.text.tests/pom.xml
+++ b/org.eclipse.text.tests/pom.xml
@@ -19,7 +19,7 @@
</parent>
<groupId>org.eclipse.text</groupId>
<artifactId>org.eclipse.text.tests</artifactId>
- <version>3.11.0-SNAPSHOT</version>
+ <version>3.12.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
<properties>
<testSuite>${project.artifactId}</testSuite>
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java
index 01e6ad5e1e4..a51c2b55c4c 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/FindReplaceDocumentAdapterTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Cagatay Calli <ccalli@gmail.com> - [find/replace] retain caps when replacing - https://bugs.eclipse.org/bugs/show_bug.cgi?id=28949
* Cagatay Calli <ccalli@gmail.com> - [find/replace] define & fix behavior of retain caps with other escapes and text before \C - https://bugs.eclipse.org/bugs/show_bug.cgi?id=217061
+ * Florian Ingerl <imelflorianingerl@gmail.com> - [find/replace] replace doesn't work when using a regex with a lookahead or boundary matchers - https://bugs.eclipse.org/bugs/show_bug.cgi?id=109481
*******************************************************************************/
package org.eclipse.text.tests;
@@ -500,4 +501,27 @@ public class FindReplaceDocumentAdapterTest {
}
fail();
}
+
+ @Test
+ public void testRegexReplaceWithLookarounds() throws Exception {
+ fDocument.set("1<2<3<4");
+ replaceAllRegex("(?<=(\\d))\\<(\\d)(?=\\<(\\d))", "<($1+$3)/2=$2", true);
+ assertEquals("1<(1+3)/2=2<(2+4)/2=3<4", fDocument.get());
+
+ fDocument.set("1<2<3<4");
+ replaceAllRegex("(?<=(\\d)\\<)(\\d)\\<(?=(\\d))", "$2=($1+$3)/2<", false);
+ assertEquals("1<2=(1+3)/2<3=(2+4)/2<4", fDocument.get());
+ }
+
+ private void replaceAllRegex(String findString, String replaceString, boolean forwardSearch) throws BadLocationException {
+ FindReplaceDocumentAdapter findReplaceDocumentAdapter= new FindReplaceDocumentAdapter(fDocument);
+
+ int index= forwardSearch ? 0 : fDocument.getLength();
+ while(index!=-1) {
+ if(findReplaceDocumentAdapter.find(index, findString, forwardSearch, true, false, true)==null)
+ break;
+ IRegion region= findReplaceDocumentAdapter.replace(replaceString, true);
+ index= forwardSearch ? region.getOffset() + region.getLength() : region.getOffset() - 1;
+ }
+ }
}
diff --git a/org.eclipse.text/META-INF/MANIFEST.MF b/org.eclipse.text/META-INF/MANIFEST.MF
index 811b45c13fe..b0918b1119a 100644
--- a/org.eclipse.text/META-INF/MANIFEST.MF
+++ b/org.eclipse.text/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.text
-Bundle-Version: 3.6.200.qualifier
+Bundle-Version: 3.6.300.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package:
diff --git a/org.eclipse.text/pom.xml b/org.eclipse.text/pom.xml
index 2556d5a9ae7..e2ebc0e8bae 100644
--- a/org.eclipse.text/pom.xml
+++ b/org.eclipse.text/pom.xml
@@ -18,6 +18,6 @@
</parent>
<groupId>org.eclipse.text</groupId>
<artifactId>org.eclipse.text</artifactId>
- <version>3.6.200-SNAPSHOT</version>
+ <version>3.6.300-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
index d80a2f9cc16..7fc5049fee1 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2017 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
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Cagatay Calli <ccalli@gmail.com> - [find/replace] retain caps when replacing - https://bugs.eclipse.org/bugs/show_bug.cgi?id=28949
* Cagatay Calli <ccalli@gmail.com> - [find/replace] define & fix behavior of retain caps with other escapes and text before \C - https://bugs.eclipse.org/bugs/show_bug.cgi?id=217061
+ * Florian Ingerl <imelflorianingerl@gmail.com> - [find/replace] replace doesn't work when using a regex with a lookahead or boundary matchers - https://bugs.eclipse.org/bugs/show_bug.cgi?id=109481
*******************************************************************************/
package org.eclipse.jface.text;
@@ -194,8 +195,11 @@ public class FindReplaceDocumentAdapter implements CharSequence {
String prevMatch= fFindReplaceMatcher.group();
try {
replaceText= interpretReplaceEscapes(replaceText, prevMatch);
- Matcher replaceTextMatcher= pattern.matcher(prevMatch);
- replaceText= replaceTextMatcher.replaceFirst(replaceText);
+ Matcher replaceTextMatcher= pattern.matcher(this);
+ replaceTextMatcher.find(fFindReplaceMatcher.start());
+ StringBuffer sb= new StringBuffer();
+ replaceTextMatcher.appendReplacement(sb, replaceText);
+ replaceText= sb.substring(fFindReplaceMatcher.start());
} catch (IndexOutOfBoundsException ex) {
throw new PatternSyntaxException(ex.getLocalizedMessage(), replaceText, -1);
}

Back to the top