This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch java13-build
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/java13-build by this push:
new 082fe05 Fix method conflicts
082fe05 is described below
commit 082fe05eaeb0eb1d2f4ca520a212556d90fd7d2f
Author: Daniel Sun <[email protected]>
AuthorDate: Mon Jan 13 19:08:04 2020 +0800
Fix method conflicts
---
.../java/org/codehaus/groovy/runtime/StringGroovyMethods.java | 10 ++++++++++
src/test/groovy/lang/ScriptSourcePositionInAstTest.groovy | 4 ++--
src/test/groovy/lang/StripMarginTest.groovy | 4 ++--
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java
index 8500643..1d0ea55 100644
--- a/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/StringGroovyMethods.java
@@ -2600,6 +2600,16 @@ public class StringGroovyMethods extends
DefaultGroovyMethodsSupport {
}
/**
+ * Same logic to {@link #stripIndent(CharSequence)}, but just to avoid
conflicts with Java13's stripIndent
+ * @param self The CharSequence to strip the leading spaces from
+ * @param forceGroovyBehavior force groovy behavior to avoid conflicts
with Java13's stripIndent
+ * @since 3.0.0
+ */
+ public static String stripIndent(CharSequence self, boolean
forceGroovyBehavior) {
+ return stripIndent(self);
+ }
+
+ /**
* Strip <tt>numChar</tt> leading characters from
* every line in a CharSequence.
* <pre class="groovyTestCase">
diff --git a/src/test/groovy/lang/ScriptSourcePositionInAstTest.groovy
b/src/test/groovy/lang/ScriptSourcePositionInAstTest.groovy
index 9c96f21..a883535 100644
--- a/src/test/groovy/lang/ScriptSourcePositionInAstTest.groovy
+++ b/src/test/groovy/lang/ScriptSourcePositionInAstTest.groovy
@@ -49,7 +49,7 @@ class ScriptSourcePositionInAstTest extends GroovyTestCase {
assert positionsForScript("""\
println 'hello'
println 'bye'
- """.stripIndent()) == [[1, 1], [2, 14]]
+ """.stripIndent(true)) == [[1, 1], [2, 14]]
}
void testScriptWithClasses() {
@@ -58,6 +58,6 @@ class ScriptSourcePositionInAstTest extends GroovyTestCase {
println 'hello'
println 'bye'
class Baz{}
- """.stripIndent()) == [[2, 1], [3, 14]]
+ """.stripIndent(true)) == [[2, 1], [3, 14]]
}
}
diff --git a/src/test/groovy/lang/StripMarginTest.groovy
b/src/test/groovy/lang/StripMarginTest.groovy
index 9862b4b..e37e2fd 100644
--- a/src/test/groovy/lang/StripMarginTest.groovy
+++ b/src/test/groovy/lang/StripMarginTest.groovy
@@ -57,7 +57,7 @@ class StripMarginTest extends GroovyTestCase {
def method() {
return 'bar'
}
- """.stripIndent()
+ """.stripIndent(true)
def expected = """
return 'foo'
@@ -79,7 +79,7 @@ def method() {
def method() {
return 'bar'
}
- """.stripIndent()
+ """.stripIndent(true)
def expected = """\
return 'foo'