groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 995479cd5 -> 7ba35700e Minor refactoring (cherry picked from commit e6db311) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7ba35700 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7ba35700 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7ba35700 Branch: refs/heads/GROOVY_2_6_X Commit: 7ba35700e618611d017cc4ea7bec7e6c4fb7d345 Parents: 995479c Author: sunlan <sun...@apache.org> Authored: Sun Sep 17 04:47:53 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 17 04:48:35 2017 +0800 -- .../org/codehaus/groovy/control/SourceUnit.java | 21 ++-- 1 file changed, 2 insertions(+), 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/7ba35700/src/main/org/codehaus/groovy/control/SourceUnit.java -- diff --git a/src/main/org/codehaus/groovy/control/SourceUnit.java b/src/main/org/codehaus/groovy/control/SourceUnit.java index 2dcb82a..8f3ce5e 100644 --- a/src/main/org/codehaus/groovy/control/SourceUnit.java +++ b/src/main/org/codehaus/groovy/control/SourceUnit.java @@ -223,31 +223,14 @@ public class SourceUnit extends ProcessingUnit { // // Create a reader on the source and run the parser. -Reader reader = null; -try { -reader = source.getReader(); - +try (Reader reader = source.getReader()) { // let's recreate the parser each time as it tends to keep around state parserPlugin = getConfiguration().getPluginFactory().createParserPlugin(); cst = parserPlugin.parseCST(this, reader); - -reader.close(); - -} -catch (IOException e) { +} catch (IOException e) { getErrorCollector().addFatalError(new SimpleMessage(e.getMessage(), this)); } -finally { -if (reader != null) { -try { -reader.close(); -} -catch (IOException e) { -// Ignore -} -} -} } /**
groovy git commit: Simplify hashCode of Tuple
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X bcf47ad3a -> 995479cd5 Simplify hashCode of Tuple (cherry picked from commit 6a8518dbf78575adc5e9602614b9a739e0e3d086) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/995479cd Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/995479cd Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/995479cd Branch: refs/heads/GROOVY_2_6_X Commit: 995479cd575f8186e8855c1a6c6c324949afafd1 Parents: bcf47ad Author: sunlan <sun...@apache.org> Authored: Sun Sep 17 04:10:08 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 17 04:10:08 2017 +0800 -- src/main/groovy/lang/Tuple.java | 20 ++-- 1 file changed, 6 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/995479cd/src/main/groovy/lang/Tuple.java -- diff --git a/src/main/groovy/lang/Tuple.java b/src/main/groovy/lang/Tuple.java index 06d501a..aef53f6 100644 --- a/src/main/groovy/lang/Tuple.java +++ b/src/main/groovy/lang/Tuple.java @@ -22,6 +22,7 @@ import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation; import java.util.AbstractList; import java.util.List; +import java.util.Objects; /** * Represents a list of Objects. @@ -30,7 +31,6 @@ import java.util.List; */ public class Tuple extends AbstractList { private final E[] contents; -private int hashCode; public Tuple(E... contents) { if (contents == null) throw new NullPointerException(); @@ -47,6 +47,7 @@ public class Tuple extends AbstractList { return contents.length; } +@SuppressWarnings("unchecked") @Override public List subList(int fromIndex, int toIndex) { int size = toIndex - fromIndex; @@ -65,8 +66,9 @@ public class Tuple extends AbstractList { if (o == null || !(o instanceof Tuple)) return false; Tuple that = (Tuple) o; -if (size() != that.size()) return false; -for (int i = 0; i < size(); i++) { +int size = size(); +if (size != that.size()) return false; +for (int i = 0; i < size; i++) { if (!DefaultTypeTransformation.compareEqual(get(i), that.get(i))) { return false; } @@ -76,16 +78,6 @@ public class Tuple extends AbstractList { @Override public int hashCode() { -if (hashCode == 0) { -for (int i = 0; i < size(); i++) { -Object value = get(i); -int hash = (value != null) ? value.hashCode() : 0xbabe; -hashCode ^= hash; -} -if (hashCode == 0) { -hashCode = 0xbabe; -} -} -return hashCode; +return Objects.hash(contents); } }
groovy git commit: Cleanup the code
Repository: groovy Updated Branches: refs/heads/master 12b36d9a5 -> 3093abd2a Cleanup the code Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3093abd2 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3093abd2 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3093abd2 Branch: refs/heads/master Commit: 3093abd2a3d52588ab0edd22404dc09ca088b0a7 Parents: 12b36d9 Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 17:09:55 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 17:09:55 2017 +0800 -- .../main/java/org/apache/groovy/parser/antlr4/AstBuilder.java| 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/3093abd2/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index e228a4d..5abc847 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -122,8 +122,6 @@ import org.objectweb.asm.Opcodes; import java.io.BufferedReader; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -4318,6 +4316,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov parser.addErrorListener(this.createANTLRErrorListener()); } +/* private String createExceptionMessage(Throwable t) { StringWriter sw = new StringWriter(); @@ -4327,6 +4326,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov return sw.toString(); } +*/ private class DeclarationListStatement extends Statement { private final List declarationStatements;
groovy git commit: Cleanup the code
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 4d86df419 -> 21c4bd997 Cleanup the code Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/21c4bd99 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/21c4bd99 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/21c4bd99 Branch: refs/heads/GROOVY_2_6_X Commit: 21c4bd997f665ba02011505b7b8d73b3a2797b43 Parents: 4d86df4 Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 17:32:13 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 17:32:13 2017 +0800 -- .../main/java/org/apache/groovy/parser/antlr4/AstBuilder.java| 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/21c4bd99/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index c766283..ed80d1a 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -121,8 +121,6 @@ import org.objectweb.asm.Opcodes; import java.io.BufferedReader; import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; @@ -4396,6 +4394,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov parser.addErrorListener(this.createANTLRErrorListener()); } +/* private String createExceptionMessage(Throwable t) { StringWriter sw = new StringWriter(); @@ -4405,6 +4404,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov return sw.toString(); } +*/ private class DeclarationListStatement extends Statement { private final List declarationStatements;
groovy git commit: Minor fix for getting java executable
Repository: groovy Updated Branches: refs/heads/master 72b1d607b -> 12b36d9a5 Minor fix for getting java executable Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/12b36d9a Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/12b36d9a Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/12b36d9a Branch: refs/heads/master Commit: 12b36d9a5137e6c1ac685f2e4e6fdb8089510573 Parents: 72b1d60 Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 16:34:00 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 16:34:00 2017 +0800 -- src/bin/startGroovy.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/12b36d9a/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index afc6c95..2c7aee7 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -266,7 +266,7 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%" -for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( +for /f "tokens=3" %%g in ('%JAVA_EXE% -version 2^>^&1 ^| findstr /i "version"') do ( SET JAVA_VERSION=%%g ) for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a
groovy git commit: Minor fix for getting java executable
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X ca05e9ff8 -> 4d86df419 Minor fix for getting java executable (cherry picked from commit 12b36d9) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4d86df41 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4d86df41 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4d86df41 Branch: refs/heads/GROOVY_2_6_X Commit: 4d86df4199e9e597a8bb5b66aee701937e0b2ad4 Parents: ca05e9f Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 16:34:00 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 16:34:24 2017 +0800 -- src/bin/startGroovy.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/4d86df41/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index afc6c95..2c7aee7 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -266,7 +266,7 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%" -for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( +for /f "tokens=3" %%g in ('%JAVA_EXE% -version 2^>^&1 ^| findstr /i "version"') do ( SET JAVA_VERSION=%%g ) for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a
groovy git commit: Fix NoClassDefFoundError when using Java9 further
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X ef7173c2a -> ca05e9ff8 Fix NoClassDefFoundError when using Java9 further (cherry picked from commit 72b1d60) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ca05e9ff Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ca05e9ff Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ca05e9ff Branch: refs/heads/GROOVY_2_6_X Commit: ca05e9ff8f217d5ac16a87fff7023a481b9c1b3f Parents: ef7173c Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 16:22:34 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 16:23:22 2017 +0800 -- src/bin/startGroovy | 7 +-- src/bin/startGroovy.bat | 7 ++- 2 files changed, 11 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/ca05e9ff/src/bin/startGroovy -- diff --git a/src/bin/startGroovy b/src/bin/startGroovy index d727595..30a6f06 100644 --- a/src/bin/startGroovy +++ b/src/bin/startGroovy @@ -220,8 +220,6 @@ if $darwin; then JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GROOVY_APP_NAME -Xdock:icon=$GROOVY_HOME/lib/groovy.icns" fi -JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" - # For Cygwin, switch paths to Windows format before running java if $cygwin ; then GROOVY_HOME=`cygpath --mixed "$GROOVY_HOME"` @@ -279,6 +277,11 @@ if $cygwin ; then fi startGroovy ( ) { +JAVA_VERSION=`"$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d "_" -f1` +if [[ "$JAVA_VERSION" > "1.8.0" ]]; then +JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" +fi + CLASS=$1 shift # Start the Profiler or the JVM http://git-wip-us.apache.org/repos/asf/groovy/blob/ca05e9ff/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index f21a763..afc6c95 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -266,7 +266,12 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%" -set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM +for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( + SET JAVA_VERSION=%%g +) +for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a +set JAVA_VERSION=%JAVA_VERSION:~0,5% +if "%JAVA_VERSION%" gtr "1.8.0" set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
groovy git commit: Fix NoClassDefFoundError when using Java9 further
Repository: groovy Updated Branches: refs/heads/master 412ec8e01 -> 72b1d607b Fix NoClassDefFoundError when using Java9 further Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/72b1d607 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/72b1d607 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/72b1d607 Branch: refs/heads/master Commit: 72b1d607b058b22f2f7dea7717f30e02e29b9dd6 Parents: 412ec8e Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 16:22:34 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 16:22:45 2017 +0800 -- src/bin/startGroovy | 7 +-- src/bin/startGroovy.bat | 7 ++- 2 files changed, 11 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/72b1d607/src/bin/startGroovy -- diff --git a/src/bin/startGroovy b/src/bin/startGroovy index d727595..30a6f06 100644 --- a/src/bin/startGroovy +++ b/src/bin/startGroovy @@ -220,8 +220,6 @@ if $darwin; then JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GROOVY_APP_NAME -Xdock:icon=$GROOVY_HOME/lib/groovy.icns" fi -JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" - # For Cygwin, switch paths to Windows format before running java if $cygwin ; then GROOVY_HOME=`cygpath --mixed "$GROOVY_HOME"` @@ -279,6 +277,11 @@ if $cygwin ; then fi startGroovy ( ) { +JAVA_VERSION=`"$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d "_" -f1` +if [[ "$JAVA_VERSION" > "1.8.0" ]]; then +JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" +fi + CLASS=$1 shift # Start the Profiler or the JVM http://git-wip-us.apache.org/repos/asf/groovy/blob/72b1d607/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index f21a763..afc6c95 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -266,7 +266,12 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%" -set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM +for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do ( + SET JAVA_VERSION=%%g +) +for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a +set JAVA_VERSION=%JAVA_VERSION:~0,5% +if "%JAVA_VERSION%" gtr "1.8.0" set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
groovy git commit: Add option `--add-modules ALL-SYSTEM` only when no `--add-modules` option is set
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 21c4bd997 -> 287a134fe Add option `--add-modules ALL-SYSTEM` only when no `--add-modules` option is set (cherry picked from commit 12f3f81) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/287a134f Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/287a134f Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/287a134f Branch: refs/heads/GROOVY_2_6_X Commit: 287a134fe502201d64f2a56bf8d42f3562a2f62c Parents: 21c4bd9 Author: sunlan <sun...@apache.org> Authored: Sat Sep 23 20:58:47 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 23 21:00:04 2017 +0800 -- src/bin/startGroovy | 3 ++- src/bin/startGroovy.bat | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/287a134f/src/bin/startGroovy -- diff --git a/src/bin/startGroovy b/src/bin/startGroovy index 30a6f06..be8b07a 100644 --- a/src/bin/startGroovy +++ b/src/bin/startGroovy @@ -279,7 +279,8 @@ fi startGroovy ( ) { JAVA_VERSION=`"$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d "_" -f1` if [[ "$JAVA_VERSION" > "1.8.0" ]]; then -JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" + ADD_MODULES_OPT="--add-modules" + test "${JAVA_OPTS#*$ADD_MODULES_OPT}" == "$JAVA_OPTS" && JAVA_OPTS="$JAVA_OPTS $ADD_MODULES_OPT ALL-SYSTEM" fi CLASS=$1 http://git-wip-us.apache.org/repos/asf/groovy/blob/287a134f/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index 2c7aee7..e4f784e 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -271,7 +271,8 @@ for /f "tokens=3" %%g in ('%JAVA_EXE% -version 2^>^&1 ^| findstr /i "version"') ) for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a set JAVA_VERSION=%JAVA_VERSION:~0,5% -if "%JAVA_VERSION%" gtr "1.8.0" set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM +set ADD_MODULES_OPT=--add-modules +if "%JAVA_VERSION%" gtr "1.8.0" echo.%JAVA_OPTS% | findstr /C:"%ADD_MODULES_OPT%" >nul 2>&1 || set JAVA_OPTS=%JAVA_OPTS% %ADD_MODULES_OPT% ALL-SYSTEM if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
groovy git commit: Add option `--add-modules ALL-SYSTEM` only when no `--add-modules` option is set
Repository: groovy Updated Branches: refs/heads/master 3093abd2a -> 12f3f818b Add option `--add-modules ALL-SYSTEM` only when no `--add-modules` option is set Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/12f3f818 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/12f3f818 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/12f3f818 Branch: refs/heads/master Commit: 12f3f818bb366f98ddad6e2f4124e1981dc67947 Parents: 3093abd Author: sunlan <sun...@apache.org> Authored: Sat Sep 23 20:58:47 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 23 20:58:47 2017 +0800 -- src/bin/startGroovy | 3 ++- src/bin/startGroovy.bat | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/12f3f818/src/bin/startGroovy -- diff --git a/src/bin/startGroovy b/src/bin/startGroovy index 30a6f06..be8b07a 100644 --- a/src/bin/startGroovy +++ b/src/bin/startGroovy @@ -279,7 +279,8 @@ fi startGroovy ( ) { JAVA_VERSION=`"$JAVACMD" -version 2>&1 | awk -F '"' '/version/ {print $2}' | cut -d "_" -f1` if [[ "$JAVA_VERSION" > "1.8.0" ]]; then -JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" + ADD_MODULES_OPT="--add-modules" + test "${JAVA_OPTS#*$ADD_MODULES_OPT}" == "$JAVA_OPTS" && JAVA_OPTS="$JAVA_OPTS $ADD_MODULES_OPT ALL-SYSTEM" fi CLASS=$1 http://git-wip-us.apache.org/repos/asf/groovy/blob/12f3f818/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index 2c7aee7..e4f784e 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -271,7 +271,8 @@ for /f "tokens=3" %%g in ('%JAVA_EXE% -version 2^>^&1 ^| findstr /i "version"') ) for /f "useback tokens=*" %%a in ('%JAVA_VERSION%') do set JAVA_VERSION=%%~a set JAVA_VERSION=%JAVA_VERSION:~0,5% -if "%JAVA_VERSION%" gtr "1.8.0" set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM +set ADD_MODULES_OPT=--add-modules +if "%JAVA_VERSION%" gtr "1.8.0" echo.%JAVA_OPTS% | findstr /C:"%ADD_MODULES_OPT%" >nul 2>&1 || set JAVA_OPTS=%JAVA_OPTS% %ADD_MODULES_OPT% ALL-SYSTEM if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat"
groovy git commit: GROOVY-8319: Improve smart type on list expressions (closes #602)
Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 74380b3da -> 63a1e44b2 GROOVY-8319: Improve smart type on list expressions (closes #602) (cherry picked from commit 70ce561) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/63a1e44b Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/63a1e44b Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/63a1e44b Branch: refs/heads/GROOVY_2_5_X Commit: 63a1e44b2aba9e50774c0d6206baad4d3b359857 Parents: 74380b3 Author: alexey.afanasiev <alexey.afanas...@jetbrains.com> Authored: Fri Sep 15 22:16:11 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 16 00:30:34 2017 +0800 -- .../stc/StaticTypeCheckingVisitor.java | 4 ++- .../transform/stc/STCAssignmentTest.groovy | 28 2 files changed, 31 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/63a1e44b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 380a952..3c6f24e 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -875,6 +875,8 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { if (!isAssignableTo(elemType, tupleType)) { addStaticTypeError("Cannot assign value of type " + elemType.toString(false) + " to variable of type " + tupleType.toString(false), rightExpression); return false; // avoids too many errors +} else { +storeType(tupleExpression, elemType); } } @@ -925,7 +927,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { } } else if (rightExpression instanceof ListExpression) { for (Expression element : ((ListExpression) rightExpression).getExpressions()) { -ClassNode rightComponentType = element.getType().redirect(); +ClassNode rightComponentType = this.getType(element); if (!checkCompatibleAssignmentTypes(leftComponentType, rightComponentType) && !(isNullConstant(element) && !isPrimitiveType(leftComponentType))) { addStaticTypeError("Cannot assign value of type " + rightComponentType.toString(false) + " into array of type " + lhsType.toString(false), rightExpression); http://git-wip-us.apache.org/repos/asf/groovy/blob/63a1e44b/src/test/groovy/transform/stc/STCAssignmentTest.groovy -- diff --git a/src/test/groovy/transform/stc/STCAssignmentTest.groovy b/src/test/groovy/transform/stc/STCAssignmentTest.groovy index 7b40304..3c00185 100644 --- a/src/test/groovy/transform/stc/STCAssignmentTest.groovy +++ b/src/test/groovy/transform/stc/STCAssignmentTest.groovy @@ -844,5 +844,33 @@ class STCAssignmentTest extends StaticTypeCheckingTestCase { assert fooParameterAssignment(null) == 42 ''' } + +void testIntegerArraySmartType() { +assertScript ''' +def m() { +def a = 1 +Integer[] b = [a] +} +''' +} + +void testIntegerSecondDimArraySmartType() { +assertScript ''' +def m() { +def a = new int[5] +int[][] b = [a] +} +''' +} + +void testMultiAssign() { +assertScript ''' +def m() { +def row = ["", "", ""] +def (left, right) = [row[0], row[1]] +left.toUpperCase() +} +''' +} }
groovy git commit: GROOVY-8319: Improve smart type on list expressions (closes #602)
Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X 423d47d35 -> f5b022274 GROOVY-8319: Improve smart type on list expressions (closes #602) (cherry picked from commit 70ce561) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f5b02227 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f5b02227 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f5b02227 Branch: refs/heads/GROOVY_2_4_X Commit: f5b02227426a4b9c135fd7b1b1d98b1532dc97bf Parents: 423d47d Author: alexey.afanasiev <alexey.afanas...@jetbrains.com> Authored: Fri Sep 15 22:16:11 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 16 00:31:38 2017 +0800 -- .../stc/StaticTypeCheckingVisitor.java | 4 ++- .../transform/stc/STCAssignmentTest.groovy | 28 2 files changed, 31 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/f5b02227/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java index 06ac1eb..86dcec3 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java @@ -875,6 +875,8 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { if (!isAssignableTo(elemType, tupleType)) { addStaticTypeError("Cannot assign value of type " + elemType.toString(false) + " to variable of type " + tupleType.toString(false), rightExpression); return false; // avoids too many errors +} else { +storeType(tupleExpression, elemType); } } @@ -925,7 +927,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport { } } else if (rightExpression instanceof ListExpression) { for (Expression element : ((ListExpression) rightExpression).getExpressions()) { -ClassNode rightComponentType = element.getType().redirect(); +ClassNode rightComponentType = this.getType(element); if (!checkCompatibleAssignmentTypes(leftComponentType, rightComponentType) && !(isNullConstant(element) && !isPrimitiveType(leftComponentType))) { addStaticTypeError("Cannot assign value of type " + rightComponentType.toString(false) + " into array of type " + lhsType.toString(false), rightExpression); http://git-wip-us.apache.org/repos/asf/groovy/blob/f5b02227/src/test/groovy/transform/stc/STCAssignmentTest.groovy -- diff --git a/src/test/groovy/transform/stc/STCAssignmentTest.groovy b/src/test/groovy/transform/stc/STCAssignmentTest.groovy index 7b40304..3c00185 100644 --- a/src/test/groovy/transform/stc/STCAssignmentTest.groovy +++ b/src/test/groovy/transform/stc/STCAssignmentTest.groovy @@ -844,5 +844,33 @@ class STCAssignmentTest extends StaticTypeCheckingTestCase { assert fooParameterAssignment(null) == 42 ''' } + +void testIntegerArraySmartType() { +assertScript ''' +def m() { +def a = 1 +Integer[] b = [a] +} +''' +} + +void testIntegerSecondDimArraySmartType() { +assertScript ''' +def m() { +def a = new int[5] +int[][] b = [a] +} +''' +} + +void testMultiAssign() { +assertScript ''' +def m() { +def row = ["", "", ""] +def (left, right) = [row[0], row[1]] +left.toUpperCase() +} +''' +} }
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 46f0416f6 -> 799b853dd Minor refactoring (cherry picked from commit e6db31177e1d34a3f472d4922bd1ee582e00ac1a) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/799b853d Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/799b853d Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/799b853d Branch: refs/heads/GROOVY_2_5_X Commit: 799b853dd80d341d85ff11eb8da155613957447e Parents: 46f0416 Author: sunlan <sun...@apache.org> Authored: Sun Sep 17 04:51:45 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 17 04:51:45 2017 +0800 -- .../org/codehaus/groovy/control/SourceUnit.java | 21 ++-- 1 file changed, 2 insertions(+), 19 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/799b853d/src/main/org/codehaus/groovy/control/SourceUnit.java -- diff --git a/src/main/org/codehaus/groovy/control/SourceUnit.java b/src/main/org/codehaus/groovy/control/SourceUnit.java index b2c8a32..9a1727d 100644 --- a/src/main/org/codehaus/groovy/control/SourceUnit.java +++ b/src/main/org/codehaus/groovy/control/SourceUnit.java @@ -223,31 +223,14 @@ public class SourceUnit extends ProcessingUnit { // // Create a reader on the source and run the parser. -Reader reader = null; -try { -reader = source.getReader(); - +try (Reader reader = source.getReader()) { // let's recreate the parser each time as it tends to keep around state parserPlugin = getConfiguration().getPluginFactory().createParserPlugin(); cst = parserPlugin.parseCST(this, reader); - -reader.close(); - -} -catch (IOException e) { +} catch (IOException e) { getErrorCollector().addFatalError(new SimpleMessage(e.getMessage(), this)); } -finally { -if (reader != null) { -try { -reader.close(); -} -catch (IOException e) { -// Ignore -} -} -} } /**
groovy git commit: Simplify the `replace` method
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 96b59cd61 -> c92b9a751 Simplify the `replace` method (cherry picked from commit fe7a039) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c92b9a75 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c92b9a75 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c92b9a75 Branch: refs/heads/GROOVY_2_6_X Commit: c92b9a7516a181f45e0c47404a6fb0e26c9d893b Parents: 96b59cd Author: sunlan <sun...@apache.org> Authored: Thu Sep 14 12:28:30 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 12:29:33 2017 +0800 -- .../groovy/parser/antlr4/util/StringUtils.java | 94 ++-- 1 file changed, 6 insertions(+), 88 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/c92b9a75/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index 86c91e6..4fe198b 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -156,9 +156,8 @@ public class StringUtils { return length == quotationLength << 1 ? "" : text.substring(quotationLength, length - quotationLength); } - /** -* Copied from Apache commons-lang3-3.6 +* The modified implementation is based on StringUtils#replace(String text, String searchString, String replacement, int max), Apache commons-lang3-3.6 * * Replaces all occurrences of a String within another String. * @@ -175,110 +174,29 @@ public class StringUtils { * StringUtils.replace("aba", "a", "z") = "zbz" * * -* @see #replace(String text, String searchString, String replacement, int max) -* @param text text to search and replace in, may be null -* @param searchString the String to search for, may be null -* @param replacement the String to replace it with, may be null -* @return the text with any replacements processed, -* {@code null} if null String input -*/ - public static String replace(final String text, final String searchString, final String replacement) { - return replace(text, searchString, replacement, -1); - } - - /** -* Copied from Apache commons-lang3-3.6 -* -* Replaces a String with another String inside a larger String, -* for the first {@code max} values of the search String. -* -* A {@code null} reference passed to this method is a no-op. -* -* -* StringUtils.replace(null, *, *, *) = null -* StringUtils.replace("", *, *, *) = "" -* StringUtils.replace("any", null, *, *) = "any" -* StringUtils.replace("any", *, null, *) = "any" -* StringUtils.replace("any", "", *, *) = "any" -* StringUtils.replace("any", *, *, 0)= "any" -* StringUtils.replace("abaa", "a", null, -1) = "abaa" -* StringUtils.replace("abaa", "a", "", -1) = "b" -* StringUtils.replace("abaa", "a", "z", 0) = "abaa" -* StringUtils.replace("abaa", "a", "z", 1) = "zbaa" -* StringUtils.replace("abaa", "a", "z", 2) = "zbza" -* StringUtils.replace("abaa", "a", "z", -1) = "zbzz" -* -* * @param text text to search and replace in, may be null * @param searchString the String to search for, may be null * @param replacement the String to replace it with, may be null -* @param max maximum number of values to replace, or {@code -1} if no maximum * @return the text with any replacements processed, * {@code null} if null String input */ - public static String replace(final String text, final String searchString, final String replacement, final int max) { - return replace(text, searchString, replacement, max, false); - } - - /** -
[1/2] groovy git commit: Groovyc did not correctly release resources hold by GroovyClassLoader.
Repository: groovy Updated Branches: refs/heads/master 8ad6e770a -> abfde7ef5 Groovyc did not correctly release resources hold by GroovyClassLoader. Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4e3ee3cb Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4e3ee3cb Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4e3ee3cb Branch: refs/heads/master Commit: 4e3ee3cb0ebdc11b5bbfef5be9040b28593463f9 Parents: 8ad6e77 Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Wed Aug 23 11:07:24 2017 +0200 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:13:13 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 27 +++- 1 file changed, 21 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/4e3ee3cb/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 3a15cd3..4d4ffb2 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -1195,7 +1195,13 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(), filenames, forceLookupUnnamedFiles); + GroovyClassLoader loader = buildClassLoaderFor(); + try { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); + } finally { +if (loader != null) + loader.close(); + } } } catch (Exception re) { @@ -1259,7 +1265,7 @@ public class Groovyc extends MatchingTask { } } -protected CompilationUnit makeCompileUnit() { +protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { if (keepStubs) { @@ -1276,9 +1282,9 @@ public class Groovyc extends MatchingTask { throw new BuildException(ioe); } } -return new JavaAwareCompilationUnit(configuration, buildClassLoaderFor()); +return new JavaAwareCompilationUnit(configuration, loader); } else { -return new CompilationUnit(configuration, null, buildClassLoaderFor()); +return new CompilationUnit(configuration, null, loader); } } @@ -1347,10 +1353,19 @@ public class Groovyc extends MatchingTask { Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject()); final String[] pe = classpath.list(); final GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader()); -for (String file : pe) { +try { + for (String file : pe) { loader.addClasspath(file); + } + scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); +} finally { + try { +loader.close(); + } + catch ( IOException e ) { +throw new RuntimeException( e ); + } } - scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); } } }
[2/2] groovy git commit: Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595)
Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595) Old Methode makeCompileUnit is added for API compatibility and marked as deprecated. Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/abfde7ef Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/abfde7ef Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/abfde7ef Branch: refs/heads/master Commit: abfde7ef53d5d2185a53e5d43c16214691f0266e Parents: 4e3ee3c Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Fri Aug 25 08:17:49 2017 +0200 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:13:44 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 59 ++-- 1 file changed, 28 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/abfde7ef/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 4d4ffb2..d69dcb4 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -291,7 +291,7 @@ public class Groovyc extends MatchingTask { * @param version the bytecode compatibility mode */ public void setTargetBytecode(String version) { - + for (String allowedJdk : CompilerConfiguration.ALLOWED_JDKS) { if (allowedJdk.equals(version)) { this.targetBytecode = version; @@ -304,8 +304,8 @@ public class Groovyc extends MatchingTask { * Retrieves the compiler bytecode compatibility mode. * * @return bytecode compatibility mode. Can be one of the values - * 1.8, 1.7, 1.6, 1.5 or - * 1.4. + * 1.8, 1.7, 1.6, 1.5 or + * 1.4. */ public String getTargetBytecode() { return this.targetBytecode; @@ -666,7 +666,7 @@ public class Groovyc extends MatchingTask { * Get the result of the groovyc task (success or failure). * * @return true if compilation succeeded, or - * was not necessary, false if the compilation failed. + * was not necessary, false if the compilation failed. */ public boolean getTaskSuccess() { return taskSuccess; @@ -786,7 +786,7 @@ public class Groovyc extends MatchingTask { /** * Set the forceLookupUnnamedFiles flag. Defaults to false. - * + * * The Groovyc Ant task is frequently used in the context of a build system * that knows the complete list of source files to be compiled. In such a * context, it is wasteful for the Groovy compiler to go searching the @@ -1195,13 +1195,9 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { - GroovyClassLoader loader = buildClassLoaderFor(); - try { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); - } finally { -if (loader != null) - loader.close(); - } +try (GroovyClassLoader loader = buildClassLoaderFor()) { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); +} } } catch (Exception re) { @@ -1265,6 +1261,14 @@ public class Groovyc extends MatchingTask { } } +/** + * @deprecated This method is not in use anymore. Use {@link Groovyc#makeCompileUnit(GroovyClassLoader)} instead. + */ +@Deprecated +protected CompilationUnit makeCompileUnit() { +return makeCompileUnit(buildClassLoaderFor()); +} + protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { @@ -1319,12 +1323,11 @@ public class Groovyc extends MatchingTask { * may not exist in the classpath yet */ if (!found && new File(cpEntry).exists()) { - try { - antLoader.addPathElement(cpEntry); - } - catch(BuildException e) { - log.warn("The classpath entry " + cpEntry + " is not a valid Java resource"); - } +try { +antLoader.addPathElement(cpEntry);
[2/2] groovy git commit: Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595)
Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595) Old Methode makeCompileUnit is added for API compatibility and marked as deprecated. (cherry picked from commit abfde7e) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/20723395 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/20723395 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/20723395 Branch: refs/heads/GROOVY_2_6_X Commit: 2072339556a44dbf042f9c826b0aca565172c80e Parents: 58f35e7 Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Fri Aug 25 14:17:49 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:25:14 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 59 ++-- 1 file changed, 28 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/20723395/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 4d4ffb2..d69dcb4 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -291,7 +291,7 @@ public class Groovyc extends MatchingTask { * @param version the bytecode compatibility mode */ public void setTargetBytecode(String version) { - + for (String allowedJdk : CompilerConfiguration.ALLOWED_JDKS) { if (allowedJdk.equals(version)) { this.targetBytecode = version; @@ -304,8 +304,8 @@ public class Groovyc extends MatchingTask { * Retrieves the compiler bytecode compatibility mode. * * @return bytecode compatibility mode. Can be one of the values - * 1.8, 1.7, 1.6, 1.5 or - * 1.4. + * 1.8, 1.7, 1.6, 1.5 or + * 1.4. */ public String getTargetBytecode() { return this.targetBytecode; @@ -666,7 +666,7 @@ public class Groovyc extends MatchingTask { * Get the result of the groovyc task (success or failure). * * @return true if compilation succeeded, or - * was not necessary, false if the compilation failed. + * was not necessary, false if the compilation failed. */ public boolean getTaskSuccess() { return taskSuccess; @@ -786,7 +786,7 @@ public class Groovyc extends MatchingTask { /** * Set the forceLookupUnnamedFiles flag. Defaults to false. - * + * * The Groovyc Ant task is frequently used in the context of a build system * that knows the complete list of source files to be compiled. In such a * context, it is wasteful for the Groovy compiler to go searching the @@ -1195,13 +1195,9 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { - GroovyClassLoader loader = buildClassLoaderFor(); - try { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); - } finally { -if (loader != null) - loader.close(); - } +try (GroovyClassLoader loader = buildClassLoaderFor()) { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); +} } } catch (Exception re) { @@ -1265,6 +1261,14 @@ public class Groovyc extends MatchingTask { } } +/** + * @deprecated This method is not in use anymore. Use {@link Groovyc#makeCompileUnit(GroovyClassLoader)} instead. + */ +@Deprecated +protected CompilationUnit makeCompileUnit() { +return makeCompileUnit(buildClassLoaderFor()); +} + protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { @@ -1319,12 +1323,11 @@ public class Groovyc extends MatchingTask { * may not exist in the classpath yet */ if (!found && new File(cpEntry).exists()) { - try { - antLoader.addPathElement(cpEntry); - } - catch(BuildException e) { - log.warn("The classpath entry " + cpEntry + " is not a valid Java resource"); - } +try { +
[1/2] groovy git commit: Groovyc did not correctly release resources hold by GroovyClassLoader.
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X ddebbeca2 -> 207233955 Groovyc did not correctly release resources hold by GroovyClassLoader. (cherry picked from commit 4e3ee3c) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/58f35e7d Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/58f35e7d Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/58f35e7d Branch: refs/heads/GROOVY_2_6_X Commit: 58f35e7d7f2b73f31cde84cf49e4cf79c2a44bd3 Parents: ddebbec Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Wed Aug 23 17:07:24 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:21:11 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 27 +++- 1 file changed, 21 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/58f35e7d/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 3a15cd3..4d4ffb2 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -1195,7 +1195,13 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(), filenames, forceLookupUnnamedFiles); + GroovyClassLoader loader = buildClassLoaderFor(); + try { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); + } finally { +if (loader != null) + loader.close(); + } } } catch (Exception re) { @@ -1259,7 +1265,7 @@ public class Groovyc extends MatchingTask { } } -protected CompilationUnit makeCompileUnit() { +protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { if (keepStubs) { @@ -1276,9 +1282,9 @@ public class Groovyc extends MatchingTask { throw new BuildException(ioe); } } -return new JavaAwareCompilationUnit(configuration, buildClassLoaderFor()); +return new JavaAwareCompilationUnit(configuration, loader); } else { -return new CompilationUnit(configuration, null, buildClassLoaderFor()); +return new CompilationUnit(configuration, null, loader); } } @@ -1347,10 +1353,19 @@ public class Groovyc extends MatchingTask { Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject()); final String[] pe = classpath.list(); final GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader()); -for (String file : pe) { +try { + for (String file : pe) { loader.addClasspath(file); + } + scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); +} finally { + try { +loader.close(); + } + catch ( IOException e ) { +throw new RuntimeException( e ); + } } - scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); } } }
groovy git commit: Revert "Groovyc did not correctly release resources hold by GroovyClassLoader."(`close` method was added since JDK 1.7)
Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X 8ff366f25 -> db4ae2850 Revert "Groovyc did not correctly release resources hold by GroovyClassLoader."(`close` method was added since JDK 1.7) This reverts commit 8ff366f Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/db4ae285 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/db4ae285 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/db4ae285 Branch: refs/heads/GROOVY_2_4_X Commit: db4ae2850d9af1460c43625f6f9240022ce7e026 Parents: 8ff366f Author: sunlan <sun...@apache.org> Authored: Thu Sep 14 08:44:44 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:44:44 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 27 +--- 1 file changed, 6 insertions(+), 21 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/db4ae285/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index c17b4ff..594dd40 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -1162,13 +1162,7 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { - GroovyClassLoader loader = buildClassLoaderFor(); - try { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); - } finally { -if (loader != null) - loader.close(); - } +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(), filenames, forceLookupUnnamedFiles); } } catch (Exception re) { @@ -1232,7 +1226,7 @@ public class Groovyc extends MatchingTask { } } -protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { +protected CompilationUnit makeCompileUnit() { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { if (keepStubs) { @@ -1249,9 +1243,9 @@ public class Groovyc extends MatchingTask { throw new BuildException(ioe); } } -return new JavaAwareCompilationUnit(configuration, loader); +return new JavaAwareCompilationUnit(configuration, buildClassLoaderFor()); } else { -return new CompilationUnit(configuration, null, loader); +return new CompilationUnit(configuration, null, buildClassLoaderFor()); } } @@ -1320,19 +1314,10 @@ public class Groovyc extends MatchingTask { Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject()); final String[] pe = classpath.list(); final GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader()); -try { - for (String file : pe) { +for (String file : pe) { loader.addClasspath(file); - } - scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); -} finally { - try { -loader.close(); - } - catch ( IOException e ) { -throw new RuntimeException( e ); - } } + scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); } } }
[1/2] groovy git commit: Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595)
Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 849a275bc -> da1d02ce6 Closing the GroovyClassLoader is now realized by try-with-resources. (closes #595) Old Methode makeCompileUnit is added for API compatibility and marked as deprecated. (cherry picked from commit abfde7e) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/da1d02ce Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/da1d02ce Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/da1d02ce Branch: refs/heads/GROOVY_2_5_X Commit: da1d02ce668ebcbdb0cb3e4576736a42d79ab789 Parents: 77e6d13 Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Fri Aug 25 14:17:49 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:28:10 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 59 ++-- 1 file changed, 28 insertions(+), 31 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/da1d02ce/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 4d4ffb2..d69dcb4 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -291,7 +291,7 @@ public class Groovyc extends MatchingTask { * @param version the bytecode compatibility mode */ public void setTargetBytecode(String version) { - + for (String allowedJdk : CompilerConfiguration.ALLOWED_JDKS) { if (allowedJdk.equals(version)) { this.targetBytecode = version; @@ -304,8 +304,8 @@ public class Groovyc extends MatchingTask { * Retrieves the compiler bytecode compatibility mode. * * @return bytecode compatibility mode. Can be one of the values - * 1.8, 1.7, 1.6, 1.5 or - * 1.4. + * 1.8, 1.7, 1.6, 1.5 or + * 1.4. */ public String getTargetBytecode() { return this.targetBytecode; @@ -666,7 +666,7 @@ public class Groovyc extends MatchingTask { * Get the result of the groovyc task (success or failure). * * @return true if compilation succeeded, or - * was not necessary, false if the compilation failed. + * was not necessary, false if the compilation failed. */ public boolean getTaskSuccess() { return taskSuccess; @@ -786,7 +786,7 @@ public class Groovyc extends MatchingTask { /** * Set the forceLookupUnnamedFiles flag. Defaults to false. - * + * * The Groovyc Ant task is frequently used in the context of a build system * that knows the complete list of source files to be compiled. In such a * context, it is wasteful for the Groovy compiler to go searching the @@ -1195,13 +1195,9 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { - GroovyClassLoader loader = buildClassLoaderFor(); - try { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); - } finally { -if (loader != null) - loader.close(); - } +try (GroovyClassLoader loader = buildClassLoaderFor()) { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); +} } } catch (Exception re) { @@ -1265,6 +1261,14 @@ public class Groovyc extends MatchingTask { } } +/** + * @deprecated This method is not in use anymore. Use {@link Groovyc#makeCompileUnit(GroovyClassLoader)} instead. + */ +@Deprecated +protected CompilationUnit makeCompileUnit() { +return makeCompileUnit(buildClassLoaderFor()); +} + protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { @@ -1319,12 +1323,11 @@ public class Groovyc extends MatchingTask { * may not exist in the classpath yet */ if (!found && new File(cpEntry).exists()) { - try { - antLoader.addPathElement(cpEntry); - } - catch(BuildException e) { - log.warn("The classpath entry " + cp
groovy git commit: Groovyc did not correctly release resources hold by GroovyClassLoader.
Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X 1c395602e -> 8ff366f25 Groovyc did not correctly release resources hold by GroovyClassLoader. (cherry picked from commit 4e3ee3c) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8ff366f2 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8ff366f2 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8ff366f2 Branch: refs/heads/GROOVY_2_4_X Commit: 8ff366f25dc30c5e3ef926b5bde1cb71ec24ab27 Parents: 1c395602 Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Wed Aug 23 17:07:24 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:29:33 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 27 +++- 1 file changed, 21 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/8ff366f2/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 594dd40..c17b4ff 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -1162,7 +1162,13 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(), filenames, forceLookupUnnamedFiles); + GroovyClassLoader loader = buildClassLoaderFor(); + try { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); + } finally { +if (loader != null) + loader.close(); + } } } catch (Exception re) { @@ -1226,7 +1232,7 @@ public class Groovyc extends MatchingTask { } } -protected CompilationUnit makeCompileUnit() { +protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { if (keepStubs) { @@ -1243,9 +1249,9 @@ public class Groovyc extends MatchingTask { throw new BuildException(ioe); } } -return new JavaAwareCompilationUnit(configuration, buildClassLoaderFor()); +return new JavaAwareCompilationUnit(configuration, loader); } else { -return new CompilationUnit(configuration, null, buildClassLoaderFor()); +return new CompilationUnit(configuration, null, loader); } } @@ -1314,10 +1320,19 @@ public class Groovyc extends MatchingTask { Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject()); final String[] pe = classpath.list(); final GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader()); -for (String file : pe) { +try { + for (String file : pe) { loader.addClasspath(file); + } + scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); +} finally { + try { +loader.close(); + } + catch ( IOException e ) { +throw new RuntimeException( e ); + } } - scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); } } }
[2/2] groovy git commit: Groovyc did not correctly release resources hold by GroovyClassLoader.
Groovyc did not correctly release resources hold by GroovyClassLoader. (cherry picked from commit 4e3ee3c) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/77e6d138 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/77e6d138 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/77e6d138 Branch: refs/heads/GROOVY_2_5_X Commit: 77e6d138adfaf9cc6dba5a95b99a824611e8189d Parents: 849a275 Author: Marcus Berndt <marcus.ber...@data-experts.de> Authored: Wed Aug 23 17:07:24 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 14 08:28:10 2017 +0800 -- .../java/org/codehaus/groovy/ant/Groovyc.java | 27 +++- 1 file changed, 21 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/77e6d138/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java -- diff --git a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java index 3a15cd3..4d4ffb2 100644 --- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java +++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java @@ -1195,7 +1195,13 @@ public class Groovyc extends MatchingTask { } if (!fileNameErrors) { -FileSystemCompiler.doCompilation(configuration, makeCompileUnit(), filenames, forceLookupUnnamedFiles); + GroovyClassLoader loader = buildClassLoaderFor(); + try { +FileSystemCompiler.doCompilation(configuration, makeCompileUnit(loader), filenames, forceLookupUnnamedFiles); + } finally { +if (loader != null) + loader.close(); + } } } catch (Exception re) { @@ -1259,7 +1265,7 @@ public class Groovyc extends MatchingTask { } } -protected CompilationUnit makeCompileUnit() { +protected CompilationUnit makeCompileUnit(GroovyClassLoader loader) { Map<String, Object> options = configuration.getJointCompilationOptions(); if (options != null) { if (keepStubs) { @@ -1276,9 +1282,9 @@ public class Groovyc extends MatchingTask { throw new BuildException(ioe); } } -return new JavaAwareCompilationUnit(configuration, buildClassLoaderFor()); +return new JavaAwareCompilationUnit(configuration, loader); } else { -return new CompilationUnit(configuration, null, buildClassLoaderFor()); +return new CompilationUnit(configuration, null, loader); } } @@ -1347,10 +1353,19 @@ public class Groovyc extends MatchingTask { Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject()); final String[] pe = classpath.list(); final GroovyClassLoader loader = new GroovyClassLoader(getClass().getClassLoader()); -for (String file : pe) { +try { + for (String file : pe) { loader.addClasspath(file); + } + scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); +} finally { + try { +loader.close(); + } + catch ( IOException e ) { +throw new RuntimeException( e ); + } } - scriptExtensions.addAll(SourceExtensionHandler.getRegisteredExtensions(loader)); } } }
groovy git commit: Fix NoClassDefFoundError when using Java9
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 43cf16c5d -> e6b62dfa1 Fix NoClassDefFoundError when using Java9 (cherry picked from commit e747742) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e6b62dfa Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e6b62dfa Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e6b62dfa Branch: refs/heads/GROOVY_2_6_X Commit: e6b62dfa1fc5b6471304dfe5244e84f7f6987392 Parents: 43cf16c Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 12:59:58 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 13:00:40 2017 +0800 -- src/bin/startGroovy | 2 ++ src/bin/startGroovy.bat | 2 ++ 2 files changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e6b62dfa/src/bin/startGroovy -- diff --git a/src/bin/startGroovy b/src/bin/startGroovy index 36d6edd..d727595 100644 --- a/src/bin/startGroovy +++ b/src/bin/startGroovy @@ -220,6 +220,8 @@ if $darwin; then JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GROOVY_APP_NAME -Xdock:icon=$GROOVY_HOME/lib/groovy.icns" fi +JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" + # For Cygwin, switch paths to Windows format before running java if $cygwin ; then GROOVY_HOME=`cygpath --mixed "$GROOVY_HOME"` http://git-wip-us.apache.org/repos/asf/groovy/blob/e6b62dfa/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index b1e8a3e..f21a763 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -266,6 +266,8 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%" +set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM + if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat" @rem Execute Groovy
groovy git commit: Fix NoClassDefFoundError when using Java9
Repository: groovy Updated Branches: refs/heads/master edea990dc -> e74774255 Fix NoClassDefFoundError when using Java9 Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e7477425 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e7477425 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e7477425 Branch: refs/heads/master Commit: e747742552e1e32d02f84546bd168e77b4cd991b Parents: edea990 Author: sunlan <sun...@apache.org> Authored: Fri Sep 22 12:59:58 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 22 12:59:58 2017 +0800 -- src/bin/startGroovy | 2 ++ src/bin/startGroovy.bat | 2 ++ 2 files changed, 4 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e7477425/src/bin/startGroovy -- diff --git a/src/bin/startGroovy b/src/bin/startGroovy index 36d6edd..d727595 100644 --- a/src/bin/startGroovy +++ b/src/bin/startGroovy @@ -220,6 +220,8 @@ if $darwin; then JAVA_OPTS="$JAVA_OPTS -Xdock:name=$GROOVY_APP_NAME -Xdock:icon=$GROOVY_HOME/lib/groovy.icns" fi +JAVA_OPTS="$JAVA_OPTS --add-modules ALL-SYSTEM" + # For Cygwin, switch paths to Windows format before running java if $cygwin ; then GROOVY_HOME=`cygpath --mixed "$GROOVY_HOME"` http://git-wip-us.apache.org/repos/asf/groovy/blob/e7477425/src/bin/startGroovy.bat -- diff --git a/src/bin/startGroovy.bat b/src/bin/startGroovy.bat index b1e8a3e..f21a763 100644 --- a/src/bin/startGroovy.bat +++ b/src/bin/startGroovy.bat @@ -266,6 +266,8 @@ if not "%TOOLS_JAR%" == "" set GROOVY_OPTS=%GROOVY_OPTS% -Dtools.jar="%TOOLS_JAR set GROOVY_OPTS=%GROOVY_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" set GROOVY_OPTS=%GROOVY_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%" +set JAVA_OPTS=%JAVA_OPTS% --add-modules ALL-SYSTEM + if exist "%USERPROFILE%/.groovy/postinit.bat" call "%USERPROFILE%/.groovy/postinit.bat" @rem Execute Groovy
groovy git commit: Refine error messages
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 9587277b0 -> 79c9cde94 Refine error messages Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/79c9cde9 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/79c9cde9 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/79c9cde9 Branch: refs/heads/GROOVY_2_6_X Commit: 79c9cde940ba7b28b05b77dec65cf92190a3 Parents: 9587277 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 14:17:19 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 14:17:19 2017 +0800 -- src/test/gls/generics/GenericsTest.groovy | 1 + 1 file changed, 1 insertion(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/79c9cde9/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 0f8df3b..92109a9 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -569,3 +569,4 @@ import java.util.concurrent.atomic.AtomicInteger ''' } } +
groovy git commit: Refine error messages
Repository: groovy Updated Branches: refs/heads/master a4306dcb7 -> 18de060f6 Refine error messages (cherry picked from commit a4306dc) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/18de060f Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/18de060f Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/18de060f Branch: refs/heads/master Commit: 18de060f66dc10298fee39fab9c653add463e0c7 Parents: a4306dc Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 13:59:04 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 13:59:04 2017 +0800 -- src/test/gls/generics/GenericsTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/18de060f/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 2a57ec5..0f8df3b 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -427,11 +427,11 @@ import java.util.concurrent.atomic.AtomicInteger shouldFailCompilationWithMessage """ def List<List history = new ArrayList<List>() -""", "Unexpected input: 'def List<List history'" +""", "Unexpected input: '<'" shouldFailCompilationWithMessage """ def List<List> history = new ArrayList<List() -""", "Unexpected input: 'new ArrayList<List('" +""", "Unexpected input:" } }
groovy git commit: Refine error messages
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 0b9db15f7 -> 9587277b0 Refine error messages Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/9587277b Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/9587277b Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/9587277b Branch: refs/heads/GROOVY_2_6_X Commit: 9587277b0c0f1a9f85fdb4891a8ec23f2c032d8e Parents: 0b9db15 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 13:59:04 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 13:59:51 2017 +0800 -- src/test/gls/generics/GenericsTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/9587277b/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 2a57ec5..0f8df3b 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -427,11 +427,11 @@ import java.util.concurrent.atomic.AtomicInteger shouldFailCompilationWithMessage """ def List<List history = new ArrayList<List>() -""", "Unexpected input: 'def List<List history'" +""", "Unexpected input: '<'" shouldFailCompilationWithMessage """ def List<List> history = new ArrayList<List() -""", "Unexpected input: 'new ArrayList<List('" +""", "Unexpected input:" } }
groovy git commit: Revert "Treat conditional statement as expression" related commits
Repository: groovy Updated Branches: refs/heads/master 18de060f6 -> 6db885207 Revert "Treat conditional statement as expression" related commits Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6db88520 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6db88520 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6db88520 Branch: refs/heads/master Commit: 6db8852079a600c2af28f5a1efb15e46316023a7 Parents: 18de060 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 14:33:40 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 14:33:40 2017 +0800 -- src/antlr/GroovyParser.g4 | 1 - src/test/gls/generics/GenericsTest.groovy | 6 +- src/test/groovy/bugs/Groovy5318Bug.groovy | 2 +- .../apache/groovy/parser/antlr4/AstBuilder.java | 18 .../parser/antlr4/GroovyParserTest.groovy | 4 - .../ConditionalStatementAsExpression_01x.groovy | 91 6 files changed, 4 insertions(+), 118 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index dd0bcfb..23e7e7a 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -784,7 +784,6 @@ expressionListElement[boolean canSpread] enhancedStatementExpression : statementExpression | standardLambdaExpression -| conditionalStatement// treat conditional statement as expression ; /** http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 0f8df3b..3fe0e69 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -398,7 +398,7 @@ import java.util.concurrent.atomic.AtomicInteger } else { shouldFailCompilationWithMessage """ def list1 = new ArrayList<Integer() -""", "Unexpected input:" +""", "Unexpected input: 'new ArrayList<Integer('" shouldFailCompilationWithMessage """ List() @@ -427,11 +427,11 @@ import java.util.concurrent.atomic.AtomicInteger shouldFailCompilationWithMessage """ def List<List history = new ArrayList<List>() -""", "Unexpected input: '<'" +""", "Unexpected input: 'def List<List history'" shouldFailCompilationWithMessage """ def List<List> history = new ArrayList<List() -""", "Unexpected input:" +""", "Unexpected input: 'new ArrayList<List('" } } http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/src/test/groovy/bugs/Groovy5318Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy5318Bug.groovy b/src/test/groovy/bugs/Groovy5318Bug.groovy index 8feaf6d..bf2610a 100644 --- a/src/test/groovy/bugs/Groovy5318Bug.groovy +++ b/src/test/groovy/bugs/Groovy5318Bug.groovy @@ -31,7 +31,7 @@ class Groovy5318Bug extends CompilableTestSupport { if (ParserVersion.V_2 == CompilerConfiguration.DEFAULT.parserVersion) { assert message.contains('Unexpected type arguments found prior to: ArrayList') } else { -assert message.contains('Unexpected input:') +assert message.contains('Unexpected input: \'new java.util.\'') } } } http://git-wip-us.apache.org/repos/asf/groovy/blob/6db88520/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index c69cf3c..157a5be 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -1979,24 +1979,6 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov expression = ((ExpressionStatement) this.visit(ctx.statementExpressi
groovy git commit: Treat conditional statement as expression
Repository: groovy Updated Branches: refs/heads/master 1783be3ae -> 35ae8e484 Treat conditional statement as expression Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/35ae8e48 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/35ae8e48 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/35ae8e48 Branch: refs/heads/master Commit: 35ae8e484020f2d11b2dd9c7efa3740ee527fa70 Parents: 1783be3 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 12:47:10 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 12:47:10 2017 +0800 -- src/antlr/GroovyParser.g4 | 1 + .../apache/groovy/parser/antlr4/AstBuilder.java | 18 .../parser/antlr4/GroovyParserTest.groovy | 4 + .../ConditionalStatementAsExpression_01x.groovy | 91 4 files changed, 114 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/35ae8e48/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 23e7e7a..dd0bcfb 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -784,6 +784,7 @@ expressionListElement[boolean canSpread] enhancedStatementExpression : statementExpression | standardLambdaExpression +| conditionalStatement// treat conditional statement as expression ; /** http://git-wip-us.apache.org/repos/asf/groovy/blob/35ae8e48/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 157a5be..c69cf3c 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -1979,6 +1979,24 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov expression = ((ExpressionStatement) this.visit(ctx.statementExpression())).getExpression(); } else if (asBoolean(ctx.standardLambdaExpression())) { expression = this.visitStandardLambdaExpression(ctx.standardLambdaExpression()); +} else if (asBoolean(ctx.conditionalStatement())) { +expression = +configureAST( +createCallMethodCallExpression( +configureAST( +new ClosureExpression( +Parameter.EMPTY_ARRAY, +configureAST( + this.createBlockStatement(this.visitConditionalStatement(ctx.conditionalStatement())), +ctx +) +), +ctx +), +new ArgumentListExpression() +), +ctx +); } else { throw createParsingFailedException("Unsupported enhanced statement expression: " + ctx.getText(), ctx); } http://git-wip-us.apache.org/repos/asf/groovy/blob/35ae8e48/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy -- diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy index fd65344..abadf5f 100644 --- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy +++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy @@ -373,6 +373,10 @@ class GroovyParserTest extends GroovyTestCase { doRunAndTest('core/SafeChainOperator.groovy'); } +void "test groovy core - ConditionalStatementAsExpression"() { +doRunAndTest('core/ConditionalStatementAsExpression_01x.groovy'); +} + void "test groovy core - BUG"() { doRunAndTest('bugs/BUG-GROOVY-4757.groovy'); doRunAndTest('bugs/BUG-GROOVY-5652.groovy'); http://git-wip-us.apache.org/repos/asf/groovy/blob/35ae8e48/subprojects/parser-antlr4/src/test/resources/cor
groovy git commit: Refine error messages
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X e9294f56f -> 0b9db15f7 Refine error messages (cherry picked from commit a4306dc) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0b9db15f Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0b9db15f Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0b9db15f Branch: refs/heads/GROOVY_2_6_X Commit: 0b9db15f7073659b998b8ae12b21fd0c228fe5a5 Parents: e9294f5 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 13:28:25 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 13:29:06 2017 +0800 -- src/test/gls/generics/GenericsTest.groovy | 2 +- src/test/groovy/bugs/Groovy5318Bug.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/0b9db15f/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 3fe0e69..2a57ec5 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -398,7 +398,7 @@ import java.util.concurrent.atomic.AtomicInteger } else { shouldFailCompilationWithMessage """ def list1 = new ArrayList<Integer() -""", "Unexpected input: 'new ArrayList<Integer('" +""", "Unexpected input:" shouldFailCompilationWithMessage """ List() http://git-wip-us.apache.org/repos/asf/groovy/blob/0b9db15f/src/test/groovy/bugs/Groovy5318Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy5318Bug.groovy b/src/test/groovy/bugs/Groovy5318Bug.groovy index bf2610a..8feaf6d 100644 --- a/src/test/groovy/bugs/Groovy5318Bug.groovy +++ b/src/test/groovy/bugs/Groovy5318Bug.groovy @@ -31,7 +31,7 @@ class Groovy5318Bug extends CompilableTestSupport { if (ParserVersion.V_2 == CompilerConfiguration.DEFAULT.parserVersion) { assert message.contains('Unexpected type arguments found prior to: ArrayList') } else { -assert message.contains('Unexpected input: \'new java.util.\'') +assert message.contains('Unexpected input:') } } }
groovy git commit: Treat conditional statement as expression
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X d91eb131d -> e9294f56f Treat conditional statement as expression (cherry picked from commit 35ae8e4) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e9294f56 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e9294f56 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e9294f56 Branch: refs/heads/GROOVY_2_6_X Commit: e9294f56f62b2db6c275e923928aeba7e8ff1695 Parents: d91eb13 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 12:47:10 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 12:49:40 2017 +0800 -- src/antlr/GroovyParser.g4 | 1 + .../apache/groovy/parser/antlr4/AstBuilder.java | 18 .../parser/antlr4/GroovyParserTest.groovy | 4 + .../ConditionalStatementAsExpression_01x.groovy | 91 4 files changed, 114 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e9294f56/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 700344b..85580e1 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -817,6 +817,7 @@ expressionListElement[boolean canSpread] enhancedStatementExpression : statementExpression | standardLambdaExpression +| conditionalStatement// treat conditional statement as expression ; /** http://git-wip-us.apache.org/repos/asf/groovy/blob/e9294f56/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 7dfef2a..4ec1589 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -2001,6 +2001,24 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov expression = ((ExpressionStatement) this.visit(ctx.statementExpression())).getExpression(); } else if (asBoolean(ctx.standardLambdaExpression())) { expression = this.visitStandardLambdaExpression(ctx.standardLambdaExpression()); +} else if (asBoolean(ctx.conditionalStatement())) { +expression = +configureAST( +createCallMethodCallExpression( +configureAST( +new ClosureExpression( +Parameter.EMPTY_ARRAY, +configureAST( + this.createBlockStatement(this.visitConditionalStatement(ctx.conditionalStatement())), +ctx +) +), +ctx +), +new ArgumentListExpression() +), +ctx +); } else { throw createParsingFailedException("Unsupported enhanced statement expression: " + ctx.getText(), ctx); } http://git-wip-us.apache.org/repos/asf/groovy/blob/e9294f56/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy -- diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy index 1e3e0e2..7fcc6a0 100644 --- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy +++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy @@ -381,6 +381,10 @@ class GroovyParserTest extends GroovyTestCase { doRunAndTest('core/SafeChainOperator.groovy'); } +void "test groovy core - ConditionalStatementAsExpression"() { +doRunAndTest('core/ConditionalStatementAsExpression_01x.groovy'); +} + void "test groovy core - BUG"() { doRunAndTest('bugs/BUG-GROOVY-4757.groovy'); doRunAndTest('bugs/BUG-GROOVY-5652.groovy'); http://git-wip-us.apache.org/repos/asf/groovy/blob/e9294f56/subprojects/parser-antlr4/src/test/resources/cor
groovy git commit: Refine error messages
Repository: groovy Updated Branches: refs/heads/master 35ae8e484 -> a4306dcb7 Refine error messages Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a4306dcb Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a4306dcb Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a4306dcb Branch: refs/heads/master Commit: a4306dcb76579907f4d054e2ea630d16c148de05 Parents: 35ae8e4 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 13:28:25 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 13:28:25 2017 +0800 -- src/test/gls/generics/GenericsTest.groovy | 2 +- src/test/groovy/bugs/Groovy5318Bug.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/a4306dcb/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 3fe0e69..2a57ec5 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -398,7 +398,7 @@ import java.util.concurrent.atomic.AtomicInteger } else { shouldFailCompilationWithMessage """ def list1 = new ArrayList<Integer() -""", "Unexpected input: 'new ArrayList<Integer('" +""", "Unexpected input:" shouldFailCompilationWithMessage """ List() http://git-wip-us.apache.org/repos/asf/groovy/blob/a4306dcb/src/test/groovy/bugs/Groovy5318Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy5318Bug.groovy b/src/test/groovy/bugs/Groovy5318Bug.groovy index bf2610a..8feaf6d 100644 --- a/src/test/groovy/bugs/Groovy5318Bug.groovy +++ b/src/test/groovy/bugs/Groovy5318Bug.groovy @@ -31,7 +31,7 @@ class Groovy5318Bug extends CompilableTestSupport { if (ParserVersion.V_2 == CompilerConfiguration.DEFAULT.parserVersion) { assert message.contains('Unexpected type arguments found prior to: ArrayList') } else { -assert message.contains('Unexpected input: \'new java.util.\'') +assert message.contains('Unexpected input:') } } }
groovy git commit: Revert "Treat conditional statement as expression" related commits
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 79c9cde94 -> 444abbf58 Revert "Treat conditional statement as expression" related commits (cherry picked from commit 6db8852) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/444abbf5 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/444abbf5 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/444abbf5 Branch: refs/heads/GROOVY_2_6_X Commit: 444abbf58fc3405bbf685adf9689f3ad618f8978 Parents: 79c9cde Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 14:33:40 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 14:34:18 2017 +0800 -- src/antlr/GroovyParser.g4 | 1 - src/test/gls/generics/GenericsTest.groovy | 6 +- src/test/groovy/bugs/Groovy5318Bug.groovy | 2 +- .../apache/groovy/parser/antlr4/AstBuilder.java | 18 .../parser/antlr4/GroovyParserTest.groovy | 4 - .../ConditionalStatementAsExpression_01x.groovy | 91 6 files changed, 4 insertions(+), 118 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/444abbf5/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 85580e1..700344b 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -817,7 +817,6 @@ expressionListElement[boolean canSpread] enhancedStatementExpression : statementExpression | standardLambdaExpression -| conditionalStatement// treat conditional statement as expression ; /** http://git-wip-us.apache.org/repos/asf/groovy/blob/444abbf5/src/test/gls/generics/GenericsTest.groovy -- diff --git a/src/test/gls/generics/GenericsTest.groovy b/src/test/gls/generics/GenericsTest.groovy index 92109a9..7ae33e4 100644 --- a/src/test/gls/generics/GenericsTest.groovy +++ b/src/test/gls/generics/GenericsTest.groovy @@ -398,7 +398,7 @@ import java.util.concurrent.atomic.AtomicInteger } else { shouldFailCompilationWithMessage """ def list1 = new ArrayList<Integer() -""", "Unexpected input:" +""", "Unexpected input: 'new ArrayList<Integer('" shouldFailCompilationWithMessage """ List() @@ -427,11 +427,11 @@ import java.util.concurrent.atomic.AtomicInteger shouldFailCompilationWithMessage """ def List<List history = new ArrayList<List>() -""", "Unexpected input: '<'" +""", "Unexpected input: 'def List<List history'" shouldFailCompilationWithMessage """ def List<List> history = new ArrayList<List() -""", "Unexpected input:" +""", "Unexpected input: 'new ArrayList<List('" } } http://git-wip-us.apache.org/repos/asf/groovy/blob/444abbf5/src/test/groovy/bugs/Groovy5318Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy5318Bug.groovy b/src/test/groovy/bugs/Groovy5318Bug.groovy index 8feaf6d..bf2610a 100644 --- a/src/test/groovy/bugs/Groovy5318Bug.groovy +++ b/src/test/groovy/bugs/Groovy5318Bug.groovy @@ -31,7 +31,7 @@ class Groovy5318Bug extends CompilableTestSupport { if (ParserVersion.V_2 == CompilerConfiguration.DEFAULT.parserVersion) { assert message.contains('Unexpected type arguments found prior to: ArrayList') } else { -assert message.contains('Unexpected input:') +assert message.contains('Unexpected input: \'new java.util.\'') } } } http://git-wip-us.apache.org/repos/asf/groovy/blob/444abbf5/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 4ec1589..7dfef2a 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -2001,24 +2001,6 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov expression = ((ExpressionStatement) th
groovy git commit: Minor refactoring: compilationUnit
Repository: groovy Updated Branches: refs/heads/master 6db885207 -> 196d93272 Minor refactoring: compilationUnit Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/196d9327 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/196d9327 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/196d9327 Branch: refs/heads/master Commit: 196d9327284cdac1a5dc162181e417afd8454da1 Parents: 6db8852 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 16:11:48 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 16:11:48 2017 +0800 -- src/antlr/GroovyParser.g4| 6 +- .../org/apache/groovy/parser/antlr4/AstBuilder.java | 15 --- 2 files changed, 17 insertions(+), 4 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/196d9327/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 23e7e7a..3f92ce4 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -98,7 +98,11 @@ options { // starting point for parsing a groovy file compilationUnit : nls -(packageDeclaration (sep | EOF))? (statement (sep | EOF))* EOF +packageDeclaration? sep? statements? EOF +; + +statements +: statement (sep statement)* sep? ; packageDeclaration http://git-wip-us.apache.org/repos/asf/groovy/blob/196d9327/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 157a5be..6172c68 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -246,9 +246,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov public ModuleNode visitCompilationUnit(CompilationUnitContext ctx) { this.visit(ctx.packageDeclaration()); -ctx.statement().stream() -.map(this::visit) -//.filter(e -> e instanceof Statement) +this.visitStatements(ctx.statements()) .forEach(e -> { if (e instanceof DeclarationListStatement) { // local variable declaration ((DeclarationListStatement) e).getDeclarationStatements().forEach(moduleNode::addStatement); @@ -280,6 +278,17 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } @Override +public List visitStatements(StatementsContext ctx) { +if (!asBoolean(ctx)) { +return Collections.emptyList(); +} + +return ctx.statement().stream() +.map(e -> (ASTNode) visit(e)) +.collect(Collectors.toList()); +} + +@Override public PackageNode visitPackageDeclaration(PackageDeclarationContext ctx) { String packageName = this.visitQualifiedName(ctx.qualifiedName()); moduleNode.setPackageName(packageName + DOT_STR);
groovy git commit: Minor improvement
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X b6c999d06 -> 3e273a898 Minor improvement Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3e273a89 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3e273a89 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3e273a89 Branch: refs/heads/GROOVY_2_6_X Commit: 3e273a898b7944996e9f43963639efea832b6777 Parents: b6c999d Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 17:15:27 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 17:15:27 2017 +0800 -- .../src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/3e273a89/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 97eafa0..dd68126 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -281,7 +281,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov return Collections.emptyList(); } -List nodeList = new ArrayList<>(); +List nodeList = new ArrayList<>(ctx.statement().size()); for (StatementContext statementContext : ctx.statement()) { nodeList.add((ASTNode) this.visit(statementContext));
groovy git commit: Minor refactoring: compilationUnit
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 444abbf58 -> b6c999d06 Minor refactoring: compilationUnit Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b6c999d0 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b6c999d0 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b6c999d0 Branch: refs/heads/GROOVY_2_6_X Commit: b6c999d06529109e0c4a382fb3f1b249201d6431 Parents: 444abbf Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 16:30:37 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 16:30:37 2017 +0800 -- src/antlr/GroovyParser.g4 | 6 +- .../apache/groovy/parser/antlr4/AstBuilder.java | 18 -- 2 files changed, 21 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/b6c999d0/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 700344b..39f3315 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -131,7 +131,11 @@ options { // starting point for parsing a groovy file compilationUnit : nls -(packageDeclaration (sep | EOF))? (statement (sep | EOF))* EOF +packageDeclaration? sep? statements? EOF +; + +statements +: statement (sep statement)* sep? ; packageDeclaration http://git-wip-us.apache.org/repos/asf/groovy/blob/b6c999d0/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 7dfef2a..97eafa0 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -243,8 +243,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov public ModuleNode visitCompilationUnit(CompilationUnitContext ctx) { this.visit(ctx.packageDeclaration()); -for (StatementContext s : ctx.statement()) { -Object e = this.visit(s); +for (ASTNode e : this.visitStatements(ctx.statements())) { if (e instanceof DeclarationListStatement) { // local variable declaration for (Statement ds : ((DeclarationListStatement) e).getDeclarationStatements()) { moduleNode.addStatement(ds); @@ -277,6 +276,21 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } @Override +public List visitStatements(StatementsContext ctx) { +if (!asBoolean(ctx)) { +return Collections.emptyList(); +} + +List nodeList = new ArrayList<>(); + +for (StatementContext statementContext : ctx.statement()) { +nodeList.add((ASTNode) this.visit(statementContext)); +} + +return nodeList; +} + +@Override public PackageNode visitPackageDeclaration(PackageDeclarationContext ctx) { String packageName = this.visitQualifiedName(ctx.qualifiedName()); moduleNode.setPackageName(packageName + DOT_STR);
groovy git commit: Minor improvement for lexer
Repository: groovy Updated Branches: refs/heads/master c3315afca -> 3e3b0f49b Minor improvement for lexer Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3e3b0f49 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3e3b0f49 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3e3b0f49 Branch: refs/heads/master Commit: 3e3b0f49b06ac3a78f47f3b950e0893255cf6f94 Parents: c3315af Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 21:48:33 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 21:48:33 2017 +0800 -- src/antlr/GroovyLexer.g4 | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/3e3b0f49/src/antlr/GroovyLexer.g4 -- diff --git a/src/antlr/GroovyLexer.g4 b/src/antlr/GroovyLexer.g4 index bcf6f24..402d364 100644 --- a/src/antlr/GroovyLexer.g4 +++ b/src/antlr/GroovyLexer.g4 @@ -202,29 +202,29 @@ options { // §3.10.5 String Literals StringLiteral -: GStringQuotationMarkDqStringCharacter*? GStringQuotationMark -| SqStringQuotationMark SqStringCharacter*? SqStringQuotationMark +: GStringQuotationMarkDqStringCharacter* GStringQuotationMark +| SqStringQuotationMark SqStringCharacter* SqStringQuotationMark | Slash { this.isRegexAllowed() && _input.LA(1) != '*' }? - SlashyStringCharacter+? Slash + SlashyStringCharacter+ Slash -| TdqStringQuotationMark TdqStringCharacter*?TdqStringQuotationMark -| TsqStringQuotationMark TsqStringCharacter*?TsqStringQuotationMark -| DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter+? DollarSlashyGStringQuotationMarkEnd +| TdqStringQuotationMark TdqStringCharacter*TdqStringQuotationMark +| TsqStringQuotationMark TsqStringCharacter*TsqStringQuotationMark +| DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter+ DollarSlashyGStringQuotationMarkEnd ; // Groovy gstring GStringBegin -: GStringQuotationMark DqStringCharacter*? Dollar -> pushMode(DQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: GStringQuotationMark DqStringCharacter* Dollar -> pushMode(DQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; TdqGStringBegin -: TdqStringQuotationMark TdqStringCharacter*? Dollar -> type(GStringBegin), pushMode(TDQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: TdqStringQuotationMark TdqStringCharacter* Dollar -> type(GStringBegin), pushMode(TDQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; SlashyGStringBegin -: Slash { this.isRegexAllowed() && _input.LA(1) != '*' }? SlashyStringCharacter*? Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: Slash { this.isRegexAllowed() && _input.LA(1) != '*' }? SlashyStringCharacter* Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; DollarSlashyGStringBegin -: DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter*? Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(DOLLAR_SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter* Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(DOLLAR_SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; mode DQ_GSTRING_MODE;
groovy git commit: Minor improvement for lexer
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 31cc93bf2 -> 40f94267c Minor improvement for lexer (cherry picked from commit 3e3b0f4) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/40f94267 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/40f94267 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/40f94267 Branch: refs/heads/GROOVY_2_6_X Commit: 40f94267c5817feca15b070f0ba11a312cc822d1 Parents: 31cc93b Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 21:48:33 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 21:49:34 2017 +0800 -- src/antlr/GroovyLexer.g4 | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/40f94267/src/antlr/GroovyLexer.g4 -- diff --git a/src/antlr/GroovyLexer.g4 b/src/antlr/GroovyLexer.g4 index bcf6f24..402d364 100644 --- a/src/antlr/GroovyLexer.g4 +++ b/src/antlr/GroovyLexer.g4 @@ -202,29 +202,29 @@ options { // §3.10.5 String Literals StringLiteral -: GStringQuotationMarkDqStringCharacter*? GStringQuotationMark -| SqStringQuotationMark SqStringCharacter*? SqStringQuotationMark +: GStringQuotationMarkDqStringCharacter* GStringQuotationMark +| SqStringQuotationMark SqStringCharacter* SqStringQuotationMark | Slash { this.isRegexAllowed() && _input.LA(1) != '*' }? - SlashyStringCharacter+? Slash + SlashyStringCharacter+ Slash -| TdqStringQuotationMark TdqStringCharacter*?TdqStringQuotationMark -| TsqStringQuotationMark TsqStringCharacter*?TsqStringQuotationMark -| DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter+? DollarSlashyGStringQuotationMarkEnd +| TdqStringQuotationMark TdqStringCharacter*TdqStringQuotationMark +| TsqStringQuotationMark TsqStringCharacter*TsqStringQuotationMark +| DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter+ DollarSlashyGStringQuotationMarkEnd ; // Groovy gstring GStringBegin -: GStringQuotationMark DqStringCharacter*? Dollar -> pushMode(DQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: GStringQuotationMark DqStringCharacter* Dollar -> pushMode(DQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; TdqGStringBegin -: TdqStringQuotationMark TdqStringCharacter*? Dollar -> type(GStringBegin), pushMode(TDQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: TdqStringQuotationMark TdqStringCharacter* Dollar -> type(GStringBegin), pushMode(TDQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; SlashyGStringBegin -: Slash { this.isRegexAllowed() && _input.LA(1) != '*' }? SlashyStringCharacter*? Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: Slash { this.isRegexAllowed() && _input.LA(1) != '*' }? SlashyStringCharacter* Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; DollarSlashyGStringBegin -: DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter*? Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(DOLLAR_SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) +: DollarSlashyGStringQuotationMarkBegin DollarSlashyStringCharacter* Dollar { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(DOLLAR_SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE) ; mode DQ_GSTRING_MODE;
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master 196d93272 -> c3315afca Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c3315afc Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c3315afc Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c3315afc Branch: refs/heads/master Commit: c3315afcaa8f707e0b9246e00e78b61c86d512f8 Parents: 196d932 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 19:48:28 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 19:48:28 2017 +0800 -- src/antlr/GroovyParser.g4 | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/c3315afc/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 3f92ce4..3da2dab 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -435,12 +435,16 @@ qualifiedNameElement | TRAIT ; +qualifiedNameElements +: (qualifiedNameElement DOT)* +; + qualifiedClassName -: (qualifiedNameElement DOT)* identifier +: qualifiedNameElements identifier ; qualifiedStandardClassName -: (qualifiedNameElement DOT)* (className DOT)* className +: qualifiedNameElements className (DOT className)* ; literal
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 3e273a898 -> 31cc93bf2 Minor refactoring (cherry picked from commit c3315af) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/31cc93bf Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/31cc93bf Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/31cc93bf Branch: refs/heads/GROOVY_2_6_X Commit: 31cc93bf2fa1c762a0557b6de74f3e6d8b214d0b Parents: 3e273a8 Author: sunlan <sun...@apache.org> Authored: Thu Oct 5 19:48:28 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Oct 5 19:49:15 2017 +0800 -- src/antlr/GroovyParser.g4 | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/31cc93bf/src/antlr/GroovyParser.g4 -- diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4 index 39f3315..756efb6 100644 --- a/src/antlr/GroovyParser.g4 +++ b/src/antlr/GroovyParser.g4 @@ -468,12 +468,16 @@ qualifiedNameElement | TRAIT ; +qualifiedNameElements +: (qualifiedNameElement DOT)* +; + qualifiedClassName -: (qualifiedNameElement DOT)* identifier +: qualifiedNameElements identifier ; qualifiedStandardClassName -: (qualifiedNameElement DOT)* (className DOT)* className +: qualifiedNameElements className (DOT className)* ; literal
groovy git commit: Refine error messages
Repository: groovy Updated Branches: refs/heads/master 8a1b3789a -> 881219cc6 Refine error messages Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/881219cc Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/881219cc Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/881219cc Branch: refs/heads/master Commit: 881219cc6ee9e8ee6d6a3c865141750c865ba224 Parents: 8a1b378 Author: sunlan <sun...@apache.org> Authored: Fri Sep 8 21:59:59 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 8 21:59:59 2017 +0800 -- src/main/antlr/GroovyLexer.g4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/881219cc/src/main/antlr/GroovyLexer.g4 -- diff --git a/src/main/antlr/GroovyLexer.g4 b/src/main/antlr/GroovyLexer.g4 index 6c8fd33..9e44ae3 100644 --- a/src/main/antlr/GroovyLexer.g4 +++ b/src/main/antlr/GroovyLexer.g4 @@ -445,7 +445,7 @@ IntegerLiteral | HexIntegerLiteral | OctalIntegerLiteral | BinaryIntegerLiteral -) (Underscore { require(false, "Invalid number", -1, true); })? +) (Underscore { require(false, "Number ending with underscores is invalid", -1, true); })? // !!! Error Alternative !!! | Zero ([0-9] { invalidDigitCount++; })+ { require(false, "Invalid octal number", -(invalidDigitCount + 1), true); } IntegerTypeSuffix? @@ -587,7 +587,7 @@ BinaryDigitOrUnderscore FloatingPointLiteral : ( DecimalFloatingPointLiteral | HexadecimalFloatingPointLiteral -) (Underscore { require(false, "Invalid number", -1, true); })? +) (Underscore { require(false, "Number ending with underscores is invalid", -1, true); })? ; fragment @@ -935,7 +935,7 @@ SL_COMMENT // Script-header comments. // The very first characters of the file may be "#!". If so, ignore the first line. SH_COMMENT -: '#!' { 0 == this.tokenIndex }?
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 6fd3f95e4 -> e7676ec75 Minor refactoring (cherry picked from commit 0d7b0bc) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e7676ec7 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e7676ec7 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e7676ec7 Branch: refs/heads/GROOVY_2_6_X Commit: e7676ec754d92b709613bac2baee7fb1f1665f4b Parents: 6fd3f95 Author: sunlan <sun...@apache.org> Authored: Thu Sep 7 20:25:33 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 7 20:56:08 2017 +0800 -- .../org/codehaus/groovy/ast/expr/Expression.java | 2 +- .../apache/groovy/parser/antlr4/AstBuilder.java| 17 +++-- 2 files changed, 8 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e7676ec7/src/main/org/codehaus/groovy/ast/expr/Expression.java -- diff --git a/src/main/org/codehaus/groovy/ast/expr/Expression.java b/src/main/org/codehaus/groovy/ast/expr/Expression.java index 1109528..6ffa3f2 100644 --- a/src/main/org/codehaus/groovy/ast/expr/Expression.java +++ b/src/main/org/codehaus/groovy/ast/expr/Expression.java @@ -32,7 +32,7 @@ import org.codehaus.groovy.GroovyBugError; * @author mailto:ja...@coredevelopers.net;>James Strachan */ public abstract class Expression extends AnnotatedNode { - +public static final Expression[] EMPTY_ARRAY = new Expression[0]; private ClassNode type=ClassHelper.DYNAMIC_TYPE; /** http://git-wip-us.apache.org/repos/asf/groovy/blob/e7676ec7/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 9cd91c8..b2d0c47 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -446,7 +446,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov if (asBoolean(ctx.localVariableDeclaration())) { DeclarationListStatement declarationListStatement = this.visitLocalVariableDeclaration(ctx.localVariableDeclaration()); -List declarationExpressionList = declarationListStatement.getDeclarationExpressions(); +List declarationExpressionList = declarationListStatement.getDeclarationExpressions(); if (declarationExpressionList.size() == 1) { return this.configureAST((Expression) declarationExpressionList.get(0), ctx); @@ -2238,7 +2238,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public ClassNode[] visitTypeList(TypeListContext ctx) { if (!asBoolean(ctx)) { -return new ClassNode[0]; +return ClassNode.EMPTY_ARRAY; } List list = new ArrayList<>(); @@ -2878,7 +2878,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov empties[i] = ConstantExpression.EMPTY_EXPRESSION; } } else { -empties = new Expression[0]; +empties = Expression.EMPTY_ARRAY; } List sizes = new LinkedList<>(); @@ -3645,7 +3645,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } if (asBoolean(ctx.LT())) { // e.g. <> -return new GenericsType[0]; +return GenericsType.EMPTY_ARRAY; } throw createParsingFailedException("Unsupported type arguments or diamond: " + ctx.getText(), ctx); @@ -4209,11 +4209,8 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov private boolean isInsideParentheses(NodeMetaDataHandler nodeMetaDataHandler) { Integer insideParenLevel = nodeMetaDataHandler.getNodeMetaData(INSIDE_PARENTHESES_LEVEL); -if (null != insideParenLevel) { -return insideParenLevel > 0; -} +return null != insideParenLevel && insideParenLevel > 0; -return false; } private void addEmptyReturnStatement() { @@ -4318,9 +4315,9 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } if (0 == newLineCnt) { -return new Pair<Integer, Integer>(token.getLine(), token.getCharPositionInLine() + 1 + token
groovy git commit: GROOVY-8311: [Parrot]Failed to check duplicated parameters properly
Repository: groovy Updated Branches: refs/heads/master 881219cc6 -> 0e0e650c2 GROOVY-8311: [Parrot]Failed to check duplicated parameters properly Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0e0e650c Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0e0e650c Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0e0e650c Branch: refs/heads/master Commit: 0e0e650c27637f00c6e926342a745a0d8be4303a Parents: 881219c Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 00:43:05 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 00:43:05 2017 +0800 -- .../apache/groovy/parser/antlr4/AstBuilder.java | 9 +++- .../parser/antlr4/GroovyParserTest.groovy | 2 ++ .../test/resources/bugs/BUG-GROOVY-8311.groovy | 23 3 files changed, 33 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/0e0e650c/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 7b63bee..ff7b5e9 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -2290,9 +2290,16 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov return; } +if (isInsideParentheses(keyExpression)) { +return; +} + String parameterName = keyExpression.getText(); -boolean isDuplicatedNamedParameter = mapEntryExpressionList.stream().anyMatch(m -> m.getKeyExpression().getText().equals(parameterName)); +boolean isDuplicatedNamedParameter = +mapEntryExpressionList.stream() +.anyMatch(m -> m.getKeyExpression().getText().equals(parameterName)); + if (!isDuplicatedNamedParameter) { return; } http://git-wip-us.apache.org/repos/asf/groovy/blob/0e0e650c/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy -- diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy index 3410dd7..1241112 100644 --- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy +++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy @@ -376,5 +376,7 @@ class GroovyParserTest extends GroovyTestCase { doRunAndTest('bugs/GROOVY-3898.groovy'); doRunAndTest('bugs/GROOVY-8228.groovy'); + +doRunAndTest('bugs/BUG-GROOVY-8311.groovy'); } } http://git-wip-us.apache.org/repos/asf/groovy/blob/0e0e650c/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy -- diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy new file mode 100644 index 000..dafa651 --- /dev/null +++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8311.groovy @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +def greet(args) { +[args.name, args.age] +} +def name = 'age' +assert greet(name: 'Doe', (name): 8) == ['Doe', 8]
groovy git commit: GROOVY-8312: Deprecate useless features of unicode sequences
Repository: groovy Updated Branches: refs/heads/master 0e0e650c2 -> 7a2cdd26b GROOVY-8312: Deprecate useless features of unicode sequences Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7a2cdd26 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7a2cdd26 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7a2cdd26 Branch: refs/heads/master Commit: 7a2cdd26b7e960d580732dad4470dc2e5fcba9e1 Parents: 0e0e650 Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 02:56:50 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 02:56:50 2017 +0800 -- src/main/antlr/GroovyLexer.g4 | 8 +--- src/tck/test/gls/ch03/s01/Unicode2.groovy | 2 ++ src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy| 2 ++ src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy| 4 .../org/apache/groovy/parser/antlr4/AstBuilder.java | 16 ++-- .../groovy/parser/antlr4/util/StringUtils.java | 2 +- .../groovy/parser/antlr4/GroovyParserTest.groovy| 2 ++ 7 files changed, 14 insertions(+), 22 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/7a2cdd26/src/main/antlr/GroovyLexer.g4 -- diff --git a/src/main/antlr/GroovyLexer.g4 b/src/main/antlr/GroovyLexer.g4 index 9e44ae3..05fb767 100644 --- a/src/main/antlr/GroovyLexer.g4 +++ b/src/main/antlr/GroovyLexer.g4 @@ -677,7 +677,7 @@ OctalEscape // Groovy allows 1 or more u's after the backslash fragment UnicodeEscape -: Backslash 'u'+ HexDigit HexDigit HexDigit HexDigit +: Backslash 'u' HexDigit HexDigit HexDigit HexDigit ; fragment @@ -842,16 +842,10 @@ ELVIS_ASSIGN: '?='; // §3.8 Identifiers (must appear after all keywords in the grammar) CapitalizedIdentifier : [A-Z] JavaLetterOrDigit* - -// FIXME REMOVE THE FOLLOWING ALTERNATIVE. Groovy's identifier can be unicode escape(e.g. def \u4e00\u9fa5 = '123'), which will impact the performance and is pointless to support IMO -| [A-Z] (JavaLetterOrDigit | UnicodeEscape)* ; Identifier : JavaLetter JavaLetterOrDigit* - -// FIXME REMOVE THE FOLLOWING ALTERNATIVE. Groovy's identifier can be unicode escape(e.g. def \u4e00\u9fa5 = '123'), which will impact the performance and is pointless to support IMO -| (JavaLetter | UnicodeEscape) (JavaLetterOrDigit | UnicodeEscape)* ; fragment http://git-wip-us.apache.org/repos/asf/groovy/blob/7a2cdd26/src/tck/test/gls/ch03/s01/Unicode2.groovy -- diff --git a/src/tck/test/gls/ch03/s01/Unicode2.groovy b/src/tck/test/gls/ch03/s01/Unicode2.groovy index 35fbf72..b845366 100644 --- a/src/tck/test/gls/ch03/s01/Unicode2.groovy +++ b/src/tck/test/gls/ch03/s01/Unicode2.groovy @@ -30,9 +30,11 @@ class Unicode2 extends GroovyTestCase { assert 1 == s.codePointCount(0, s.length()) // number of Unicode code points } +/* void testIdentifiers() { def foo\u0044 = 12 assert 20 == foo\u0044 + 8 } +*/ } http://git-wip-us.apache.org/repos/asf/groovy/blob/7a2cdd26/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy -- diff --git a/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy b/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy index 6411c34..3f23dfd 100644 --- a/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy +++ b/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy @@ -39,11 +39,13 @@ class UnicodeEscapes1 extends GroovyTestCase { } // There can be 1 or more u's after the backslash +/* void testMultipleUs() { assert "\uu0061" == "a" assert "\uuu0061" == "a" assert "\u0061" == "a" } +*/ void testOtherVariations() { // Capital 'U' not allowed http://git-wip-us.apache.org/repos/asf/groovy/blob/7a2cdd26/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy -- diff --git a/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy b/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy index 58eafbe..e78a3d7 100644 --- a/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy +++ b/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy @@ -29,6 +29,7 @@ class UnicodeEscapes2 extends GroovyTestCase { // GLS: If an even number of backslashes precede the 'u', it is not // an escape +/* void testCountBackslash() { def a = 1 assert \u0061 == 1 // char 61 is 'a' @@ -42,10 +43,12 @@ class UnicodeEscapes2 extends GroovyTestCase { assert "\\\u0061&quo
groovy git commit: GROOVY-8312: Deprecate useless features of unicode sequences
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 302a78e3d -> 7dd30235d GROOVY-8312: Deprecate useless features of unicode sequences (cherry picked from commit 7a2cdd2) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/7dd30235 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/7dd30235 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/7dd30235 Branch: refs/heads/GROOVY_2_6_X Commit: 7dd30235db428b94c74b4d8e3a71e5dff85208e6 Parents: 302a78e Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 02:56:50 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 02:59:29 2017 +0800 -- src/main/antlr/GroovyLexer.g4 | 8 +--- src/tck/test/gls/ch03/s01/Unicode2.groovy | 2 ++ src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy| 2 ++ src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy| 4 .../org/apache/groovy/parser/antlr4/AstBuilder.java | 16 ++-- .../groovy/parser/antlr4/util/StringUtils.java | 2 +- .../groovy/parser/antlr4/GroovyParserTest.groovy| 2 ++ 7 files changed, 14 insertions(+), 22 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/main/antlr/GroovyLexer.g4 -- diff --git a/src/main/antlr/GroovyLexer.g4 b/src/main/antlr/GroovyLexer.g4 index 9e44ae3..05fb767 100644 --- a/src/main/antlr/GroovyLexer.g4 +++ b/src/main/antlr/GroovyLexer.g4 @@ -677,7 +677,7 @@ OctalEscape // Groovy allows 1 or more u's after the backslash fragment UnicodeEscape -: Backslash 'u'+ HexDigit HexDigit HexDigit HexDigit +: Backslash 'u' HexDigit HexDigit HexDigit HexDigit ; fragment @@ -842,16 +842,10 @@ ELVIS_ASSIGN: '?='; // §3.8 Identifiers (must appear after all keywords in the grammar) CapitalizedIdentifier : [A-Z] JavaLetterOrDigit* - -// FIXME REMOVE THE FOLLOWING ALTERNATIVE. Groovy's identifier can be unicode escape(e.g. def \u4e00\u9fa5 = '123'), which will impact the performance and is pointless to support IMO -| [A-Z] (JavaLetterOrDigit | UnicodeEscape)* ; Identifier : JavaLetter JavaLetterOrDigit* - -// FIXME REMOVE THE FOLLOWING ALTERNATIVE. Groovy's identifier can be unicode escape(e.g. def \u4e00\u9fa5 = '123'), which will impact the performance and is pointless to support IMO -| (JavaLetter | UnicodeEscape) (JavaLetterOrDigit | UnicodeEscape)* ; fragment http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/tck/test/gls/ch03/s01/Unicode2.groovy -- diff --git a/src/tck/test/gls/ch03/s01/Unicode2.groovy b/src/tck/test/gls/ch03/s01/Unicode2.groovy index 35fbf72..b845366 100644 --- a/src/tck/test/gls/ch03/s01/Unicode2.groovy +++ b/src/tck/test/gls/ch03/s01/Unicode2.groovy @@ -30,9 +30,11 @@ class Unicode2 extends GroovyTestCase { assert 1 == s.codePointCount(0, s.length()) // number of Unicode code points } +/* void testIdentifiers() { def foo\u0044 = 12 assert 20 == foo\u0044 + 8 } +*/ } http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy -- diff --git a/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy b/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy index 6411c34..3f23dfd 100644 --- a/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy +++ b/src/tck/test/gls/ch03/s03/UnicodeEscapes1.groovy @@ -39,11 +39,13 @@ class UnicodeEscapes1 extends GroovyTestCase { } // There can be 1 or more u's after the backslash +/* void testMultipleUs() { assert "\uu0061" == "a" assert "\uuu0061" == "a" assert "\u0061" == "a" } +*/ void testOtherVariations() { // Capital 'U' not allowed http://git-wip-us.apache.org/repos/asf/groovy/blob/7dd30235/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy -- diff --git a/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy b/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy index 58eafbe..e78a3d7 100644 --- a/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy +++ b/src/tck/test/gls/ch03/s03/UnicodeEscapes2.groovy @@ -29,6 +29,7 @@ class UnicodeEscapes2 extends GroovyTestCase { // GLS: If an even number of backslashes precede the 'u', it is not // an escape +/* void testCountBackslash() { def a = 1 assert \u0061 == 1 // char 61 is 'a' @@ -42,10 +43,12 @@ class Unicod
[2/2] groovy git commit: Improve the performance of replacing strings
Improve the performance of replacing strings (cherry picked from commit 099fbbc) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e9fb7840 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e9fb7840 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e9fb7840 Branch: refs/heads/GROOVY_2_6_X Commit: e9fb784062ab7b4e8f20519312ac855b184d8e25 Parents: cff0df4 Author: sunlan <sun...@apache.org> Authored: Wed Aug 30 02:05:18 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Aug 30 02:15:06 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 4 +- .../groovy/parser/antlr4/util/StringUtils.java | 42 2 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e9fb7840/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index 861160b..d806baa 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -1283,7 +1283,7 @@ keywords rparen : RPAREN | -// !!!Error Alternative +// !!!Error Alternative, impact the performance of parsing ~LPAREN { require(false, "Missing ')'", -1); } ; @@ -1291,7 +1291,7 @@ rparen rbrack : RBRACK | -// !!!Error Alternative +// !!!Error Alternative, impact the performance of parsing ~LBRACK { require(false, "Missing ']'", -1); } ; http://git-wip-us.apache.org/repos/asf/groovy/blob/e9fb7840/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index 5aad139..4c58256 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -80,7 +80,7 @@ public class StringUtils { } }); - return result.replace("", "\\"); + return replace(result, Maps.of("", "\\")); } public static final int NONE_SLASHY = 0; @@ -92,15 +92,17 @@ public class StringUtils { text = StringUtils.replaceHexEscapes(text); text = StringUtils.replaceLineEscape(text); + StringBuilder sb = new StringBuilder(text); if (slashyType == SLASHY) { - text = text.replace("\\/", "/"); + replace(sb, Maps.of("\\/", "/")); } if (slashyType == DOLLAR_SLASHY) { - text = text.replace("$$", "$"); - text = text.replace("$/", "/"); + replace(sb, Maps.of("$$", "$")); + replace(sb, Maps.of("$/", "/")); } + text = sb.toString(); } else if (slashyType == NONE_SLASHY) { text = StringUtils.replaceEscapes(text); } else { @@ -111,8 +113,7 @@ public class StringUtils { } private static String replaceEscapes(String text) { - text = text.replace("\\$", "$"); - + text = replace(text, Maps.of("\\$", "$")); text = StringUtils.replaceLineEscape(text); return StringUtils.replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text))); @@ -138,7 +139,7 @@ public class StringUtils { } public static String removeCR(String text) { -return text.replace("\r\n", "\n"); + return replace(text, Maps.of("\r\n", "\n")); } public static long countChar(String text, char c) { @@ -150,9 +151,34 @@ public class StringUtils { return count; // return text.chars().filter(e -> c == e).count(); } + public static String replace(String str, Map<String, String> replacements) { + return replace(new StringBuil
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master 099fbbcea -> 3bd0d8012 Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3bd0d801 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3bd0d801 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3bd0d801 Branch: refs/heads/master Commit: 3bd0d8012462cff00686778df0725010f1d97fa7 Parents: 099fbbc Author: sunlan <sun...@apache.org> Authored: Wed Aug 30 02:12:53 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Aug 30 02:12:53 2017 +0800 -- .../apache/groovy/parser/antlr4/util/StringUtils.java | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/3bd0d801/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index ef75471..67ec3a7 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -151,20 +151,17 @@ public class StringUtils { } public static StringBuilder replace(StringBuilder sb, Map<String, String> replacements) { - - for (Map.Entry<String, String> entry : replacements.entrySet()) { - String key = entry.getKey(); + for (Map.Entry<String, String> replacementEntry : replacements.entrySet()) { + String key = replacementEntry.getKey(); int keyLength = key.length(); - String value = entry.getValue(); + String value = replacementEntry.getValue(); int valueLength = value.length(); int start = sb.indexOf(key, 0); while (start > -1) { - int end = start + keyLength; - int nextSearchStart = start + valueLength; - sb.replace(start, end, value); - start = sb.indexOf(key, nextSearchStart); + sb.replace(start, start + keyLength, value); + start = sb.indexOf(key, start + valueLength); } }
groovy git commit: Improve the performance of replacing strings
Repository: groovy Updated Branches: refs/heads/master 4bd92e664 -> 099fbbcea Improve the performance of replacing strings Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/099fbbce Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/099fbbce Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/099fbbce Branch: refs/heads/master Commit: 099fbbcea6a6ae3958f1abeadf5d8cfc6799880a Parents: 4bd92e6 Author: sunlan <sun...@apache.org> Authored: Wed Aug 30 02:05:18 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Aug 30 02:05:18 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 4 +- .../groovy/parser/antlr4/util/StringUtils.java | 42 2 files changed, 36 insertions(+), 10 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/099fbbce/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index 4456a60..b5e4c84 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -1250,7 +1250,7 @@ keywords rparen : RPAREN | -// !!!Error Alternative +// !!!Error Alternative, impact the performance of parsing ~LPAREN { require(false, "Missing ')'", -1); } ; @@ -1258,7 +1258,7 @@ rparen rbrack : RBRACK | -// !!!Error Alternative +// !!!Error Alternative, impact the performance of parsing ~LBRACK { require(false, "Missing ']'", -1); } ; http://git-wip-us.apache.org/repos/asf/groovy/blob/099fbbce/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index e200742..ef75471 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -80,7 +80,7 @@ public class StringUtils { } }); - return result.replace("", "\\"); + return replace(result, Maps.of("", "\\")); } public static final int NONE_SLASHY = 0; @@ -92,15 +92,17 @@ public class StringUtils { text = StringUtils.replaceHexEscapes(text); text = StringUtils.replaceLineEscape(text); + StringBuilder sb = new StringBuilder(text); if (slashyType == SLASHY) { - text = text.replace("\\/", "/"); + replace(sb, Maps.of("\\/", "/")); } if (slashyType == DOLLAR_SLASHY) { - text = text.replace("$$", "$"); - text = text.replace("$/", "/"); + replace(sb, Maps.of("$$", "$")); + replace(sb, Maps.of("$/", "/")); } + text = sb.toString(); } else if (slashyType == NONE_SLASHY) { text = StringUtils.replaceEscapes(text); } else { @@ -111,8 +113,7 @@ public class StringUtils { } private static String replaceEscapes(String text) { - text = text.replace("\\$", "$"); - + text = replace(text, Maps.of("\\$", "$")); text = StringUtils.replaceLineEscape(text); return StringUtils.replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text))); @@ -138,16 +139,41 @@ public class StringUtils { } public static String removeCR(String text) { -return text.replace("\r\n", "\n"); + return replace(text, Maps.of("\r\n", "\n")); } public static long countChar(String text, char c) { return text.chars().filter(e -> c == e).count(); } + public static String replace(String str, Map<String, String> replacements) { + return replace(new StringBuilder(str), replacements).toString(); + } + +
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 559359e5b -> c1444a905 Minor refactoring (cherry picked from commit d721a39) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c1444a90 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c1444a90 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c1444a90 Branch: refs/heads/GROOVY_2_6_X Commit: c1444a9053791bdc2fda123841390a100b541d42 Parents: 559359e Author: sunlan <sun...@apache.org> Authored: Wed Aug 30 03:37:13 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Aug 30 03:38:16 2017 +0800 -- .../java/org/apache/groovy/parser/antlr4/util/StringUtils.java| 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/c1444a90/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index 8458cfa..088fe6f 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -98,8 +98,7 @@ public class StringUtils { } if (slashyType == DOLLAR_SLASHY) { - replace(sb, Maps.of("$$", "$")); - replace(sb, Maps.of("$/", "/")); + replace(sb, Maps.of("$$", "$", "$/", "/")); } text = sb.toString();
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master 3bd0d8012 -> d721a39ae Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d721a39a Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d721a39a Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d721a39a Branch: refs/heads/master Commit: d721a39ae9ef6676b4d4a793480fb49a498c72f8 Parents: 3bd0d80 Author: sunlan <sun...@apache.org> Authored: Wed Aug 30 03:37:13 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Aug 30 03:37:13 2017 +0800 -- .../java/org/apache/groovy/parser/antlr4/util/StringUtils.java| 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/d721a39a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index 67ec3a7..40313cd 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -98,8 +98,7 @@ public class StringUtils { } if (slashyType == DOLLAR_SLASHY) { - replace(sb, Maps.of("$$", "$")); - replace(sb, Maps.of("$/", "/")); + replace(sb, Maps.of("$$", "$", "$/", "/")); } text = sb.toString();
groovy git commit: Clean the build script
Repository: groovy Updated Branches: refs/heads/master 548ac7e56 -> f628fcb36 Clean the build script Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f628fcb3 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f628fcb3 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f628fcb3 Branch: refs/heads/master Commit: f628fcb36935982f4f376bd5259d3b52f0dd7f96 Parents: 548ac7e Author: sunlan <sun...@apache.org> Authored: Wed Aug 30 12:49:04 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Aug 30 12:49:04 2017 +0800 -- build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/f628fcb3/build.gradle -- diff --git a/build.gradle b/build.gradle index bc9f157..35a333f 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ allprojects { group = 'org.codehaus.groovy' version = groovyVersion repositories { -if (!InetAddress.getByName('www.google.com').isReachable(3000)) { +if (!InetAddress.getByName('twitter.com').isReachable(3000)) { // Try to use Aliyun maven repository when building in China maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } } @@ -255,8 +255,6 @@ dependencies { exclude(module: 'geronimo-j2ee-connector_1.5_spec') } -// TODO use antlr plugin -//antlr "antlr:antlr:$antlrVersion" antlr2 "org.apache.ant:ant-antlr:$antVersion" testCompile project(':groovy-ant')
[3/3] groovy git commit: Fix the position issue
Fix the position issue (cherry picked from commit 58bc7a8) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/699627e1 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/699627e1 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/699627e1 Branch: refs/heads/GROOVY_2_6_X Commit: 699627e17946603bb13f8101d31c40f9af75c101 Parents: 6007654 Author: sunlan <sun...@apache.org> Authored: Mon Sep 11 22:25:22 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Sep 11 22:29:00 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/699627e1/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index a3d8869..a03da00 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -697,7 +697,7 @@ locals[boolean resourcesExists = false] nls finallyBlock | // catch and finally clauses required unless it's a try-with-resources block -{ require($resourcesExists, "either a catch or finally clause or both is required for a try-catch-finally statement", -5); } +{ require($resourcesExists, "either a catch or finally clause or both is required for a try-catch-finally statement"); } ) ;
[1/3] groovy git commit: Tweak how grammar detects non try-with-resource case with no catch/finally
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 00768041b -> 699627e17 Tweak how grammar detects non try-with-resource case with no catch/finally (cherry picked from commit da24038) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/bd8e7e72 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/bd8e7e72 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/bd8e7e72 Branch: refs/heads/GROOVY_2_6_X Commit: bd8e7e72cab112eea56e15aec8fe48a86f907ba5 Parents: 0076804 Author: paulk <pa...@asert.com.au> Authored: Mon Sep 11 21:42:02 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Sep 11 22:28:43 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/bd8e7e72/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index 59ac4f9..a3d8869 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -696,8 +696,8 @@ locals[boolean resourcesExists = false] | nls finallyBlock | -// try-with-resources can have no catche and finally clauses -{ $resourcesExists }?
groovy git commit: Fix the position issue
Repository: groovy Updated Branches: refs/heads/master a2fb76d73 -> 58bc7a88b Fix the position issue Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/58bc7a88 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/58bc7a88 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/58bc7a88 Branch: refs/heads/master Commit: 58bc7a88b13344b3dcd76509fce16f0c68e1898a Parents: a2fb76d Author: sunlan <sun...@apache.org> Authored: Mon Sep 11 22:25:22 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Sep 11 22:25:22 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/58bc7a88/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index 49877d7..009f415 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -664,7 +664,7 @@ locals[boolean resourcesExists = false] nls finallyBlock | // catch and finally clauses required unless it's a try-with-resources block -{ require($resourcesExists, "either a catch or finally clause or both is required for a try-catch-finally statement", -5); } +{ require($resourcesExists, "either a catch or finally clause or both is required for a try-catch-finally statement"); } ) ;
groovy git commit: Refine groovydoc support
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 4959cd215 -> 711620419 Refine groovydoc support Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/71162041 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/71162041 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/71162041 Branch: refs/heads/GROOVY_2_6_X Commit: 7116204190d92bc74a06f2b5f5b36872a63c701e Parents: 4959cd2 Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 12:25:50 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 12:25:50 2017 +0800 -- src/main/org/codehaus/groovy/ast/ClassNode.java | 10 ++- src/main/org/codehaus/groovy/ast/FieldNode.java | 13 +++- .../org/codehaus/groovy/ast/MethodNode.java | 9 ++- .../groovy/ast/groovydoc/Groovydoc.java | 68 ++ .../groovy/ast/groovydoc/GroovydocHolder.java | 31 .../groovy/ast/groovydoc/GroovydocTag.java | 74 .../groovy/parser/antlr4/GroovydocManager.java | 9 ++- .../parser/antlr4/GroovyParserTest.groovy | 56 +++ .../antlr4/util/ASTComparatorCategory.groovy| 2 +- 9 files changed, 236 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/71162041/src/main/org/codehaus/groovy/ast/ClassNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java index 283e86f..7e24de2 100644 --- a/src/main/org/codehaus/groovy/ast/ClassNode.java +++ b/src/main/org/codehaus/groovy/ast/ClassNode.java @@ -23,6 +23,8 @@ import org.codehaus.groovy.ast.expr.BinaryExpression; import org.codehaus.groovy.ast.expr.Expression; import org.codehaus.groovy.ast.expr.FieldExpression; import org.codehaus.groovy.ast.expr.TupleExpression; +import org.codehaus.groovy.ast.groovydoc.Groovydoc; +import org.codehaus.groovy.ast.groovydoc.GroovydocHolder; import org.codehaus.groovy.ast.stmt.BlockStatement; import org.codehaus.groovy.ast.stmt.ExpressionStatement; import org.codehaus.groovy.ast.stmt.Statement; @@ -103,7 +105,8 @@ import java.util.Set; * * @see org.codehaus.groovy.ast.ClassHelper */ -public class ClassNode extends AnnotatedNode implements Opcodes { +public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder { + private static class MapOfLists { private Map<Object, List> map; public List get(Object key) { @@ -1493,4 +1496,9 @@ public class ClassNode extends AnnotatedNode implements Opcodes { public String getText() { return getName(); } + +@Override +public Groovydoc getGroovydoc() { +return this.getNodeMetaData(DOC_COMMENT); +} } http://git-wip-us.apache.org/repos/asf/groovy/blob/71162041/src/main/org/codehaus/groovy/ast/FieldNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/FieldNode.java b/src/main/org/codehaus/groovy/ast/FieldNode.java index c791346..987349b 100644 --- a/src/main/org/codehaus/groovy/ast/FieldNode.java +++ b/src/main/org/codehaus/groovy/ast/FieldNode.java @@ -18,17 +18,19 @@ */ package org.codehaus.groovy.ast; -import java.lang.reflect.Field; - import org.codehaus.groovy.ast.expr.Expression; +import org.codehaus.groovy.ast.groovydoc.Groovydoc; +import org.codehaus.groovy.ast.groovydoc.GroovydocHolder; import org.objectweb.asm.Opcodes; +import java.lang.reflect.Field; + /** * Represents a field (member variable) * * @author mailto:ja...@coredevelopers.net;>James Strachan */ -public class FieldNode extends AnnotatedNode implements Opcodes, Variable { +public class FieldNode extends AnnotatedNode implements Opcodes, Variable, GroovydocHolder { private String name; private int modifiers; @@ -190,4 +192,9 @@ public class FieldNode extends AnnotatedNode implements Opcodes, Variable { declaringClass.renameField(this.name, name); this.name = name; } + +@Override +public Groovydoc getGroovydoc() { +return this.getNodeMetaData(DOC_COMMENT); +} } http://git-wip-us.apache.org/repos/asf/groovy/blob/71162041/src/main/org/codehaus/groovy/ast/MethodNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/MethodNode.java b/src/main/org/codehaus/groovy/ast/MethodNode.java index 7239a86..ea0db81 100644 --- a/src/main/org/codehaus/groovy/ast/MethodNode.java +++ b/src/main/org/codehaus/groovy/ast/MethodNode.java @@ -19,6 +19,8 @@ package org.codehaus.groovy.ast; import org.apache.groovy.ast.tools.MethodNodeUtils; +import org.codehaus.groovy.ast.groo
groovy git commit: Add `getGroovydoc` DGMs
Repository: groovy Updated Branches: refs/heads/master b364be085 -> ec49133c5 Add `getGroovydoc` DGMs Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ec49133c Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ec49133c Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ec49133c Branch: refs/heads/master Commit: ec49133c5ebdcd3236fccd59718c919f5d840f7f Parents: b364be0 Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 14:02:06 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 14:02:06 2017 +0800 -- .../groovy/runtime/DefaultGroovyMethods.java| 138 ++- .../test/resources/core/Groovydoc_01x.groovy| 12 +- 2 files changed, 139 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/ec49133c/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java -- diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java index dd0ae2c..9f99021 100644 --- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java +++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java @@ -20,7 +20,31 @@ package org.codehaus.groovy.runtime; import groovy.io.FileType; import groovy.io.GroovyPrintWriter; -import groovy.lang.*; +import groovy.lang.Closure; +import groovy.lang.DelegatesTo; +import groovy.lang.DelegatingMetaClass; +import groovy.lang.EmptyRange; +import groovy.lang.ExpandoMetaClass; +import groovy.lang.GString; +import groovy.lang.GroovyObject; +import groovy.lang.GroovyRuntimeException; +import groovy.lang.GroovySystem; +import groovy.lang.Groovydoc; +import groovy.lang.IntRange; +import groovy.lang.ListWithDefault; +import groovy.lang.MapWithDefault; +import groovy.lang.MetaClass; +import groovy.lang.MetaClassImpl; +import groovy.lang.MetaClassRegistry; +import groovy.lang.MetaMethod; +import groovy.lang.MetaProperty; +import groovy.lang.MissingPropertyException; +import groovy.lang.ObjectRange; +import groovy.lang.PropertyValue; +import groovy.lang.Range; +import groovy.lang.SpreadMap; +import groovy.lang.Tuple2; +import groovy.lang.Writable; import groovy.transform.stc.ClosureParams; import groovy.transform.stc.FirstParam; import groovy.transform.stc.FromString; @@ -44,7 +68,24 @@ import org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv; import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus; import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply; import org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus; -import org.codehaus.groovy.runtime.dgmimpl.arrays.*; +import org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod; import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; import org.codehaus.groovy.runtime.metaclass.MissingPropertyExceptionNoStack; import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation; @@ -53,11 +94,31 @@ import org.codehaus.groovy.runtime.typehandling.NumberMath; import org.codehaus.groovy.tools.RootLoader; import org.codehaus.groovy.transform.trait.Traits; import org.codehaus.groovy.util.ArrayIterator; -import org.codehaus.groovy.util.ListBufferedIterator; import org.codehaus.groovy.util.IteratorBufferedIterator; +import org.codehaus.groovy.util.ListBufferedIterator; -import java.io.*; +import java.io.Buff
groovy git commit: Refine "block" rule
Repository: groovy Updated Branches: refs/heads/master 546ccd875 -> 3853aca6e Refine "block" rule Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/3853aca6 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/3853aca6 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/3853aca6 Branch: refs/heads/master Commit: 3853aca6ea57d7b2ae85e3fd4146e7ebb51f0cbe Parents: 546ccd8 Author: sunlan <sun...@apache.org> Authored: Wed Sep 6 20:10:02 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 6 20:10:02 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/3853aca6/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index 4fe61e3..d72b907 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -562,7 +562,7 @@ elementValueArrayInitializer // STATEMENTS / BLOCKS block -: LBRACE (nls | sep+) blockStatementsOpt RBRACE +: LBRACE (nls | sep*) blockStatementsOpt RBRACE ; blockStatement
groovy git commit: Refine "block" rule
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 17c1bdbe2 -> 1a2aff345 Refine "block" rule (cherry picked from commit 3853aca) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1a2aff34 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1a2aff34 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1a2aff34 Branch: refs/heads/GROOVY_2_6_X Commit: 1a2aff3459587240db671e65a02fd324f05394a8 Parents: 17c1bdb Author: sunlan <sun...@apache.org> Authored: Wed Sep 6 20:10:02 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 6 20:11:21 2017 +0800 -- src/main/antlr/GroovyParser.g4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/1a2aff34/src/main/antlr/GroovyParser.g4 -- diff --git a/src/main/antlr/GroovyParser.g4 b/src/main/antlr/GroovyParser.g4 index fa1716e..59ac4f9 100644 --- a/src/main/antlr/GroovyParser.g4 +++ b/src/main/antlr/GroovyParser.g4 @@ -595,7 +595,7 @@ elementValueArrayInitializer // STATEMENTS / BLOCKS block -: LBRACE (nls | sep+) blockStatementsOpt RBRACE +: LBRACE (nls | sep*) blockStatementsOpt RBRACE ; blockStatement
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X e7676ec75 -> 0aa9ec3fd Minor refactoring (cherry picked from commit 4b09236) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0aa9ec3f Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0aa9ec3f Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0aa9ec3f Branch: refs/heads/GROOVY_2_6_X Commit: 0aa9ec3fd30355094c794558d801707929cc7fdc Parents: e7676ec Author: sunlan <sun...@apache.org> Authored: Thu Sep 7 21:16:18 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 7 21:23:13 2017 +0800 -- src/main/org/codehaus/groovy/ast/Parameter.java | 3 +-- .../org/apache/groovy/parser/antlr4/AstBuilder.java | 12 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/0aa9ec3f/src/main/org/codehaus/groovy/ast/Parameter.java -- diff --git a/src/main/org/codehaus/groovy/ast/Parameter.java b/src/main/org/codehaus/groovy/ast/Parameter.java index a49b34a..c3df7c3 100644 --- a/src/main/org/codehaus/groovy/ast/Parameter.java +++ b/src/main/org/codehaus/groovy/ast/Parameter.java @@ -29,8 +29,7 @@ import org.codehaus.groovy.ast.expr.*; */ public class Parameter extends AnnotatedNode implements Variable { -public static final Parameter[] EMPTY_ARRAY = { -}; +public static final Parameter[] EMPTY_ARRAY = {}; private ClassNode type; private final String name; http://git-wip-us.apache.org/repos/asf/groovy/blob/0aa9ec3f/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index b2d0c47..9a9fe95 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -262,7 +262,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov this.addPackageInfoClassNode(); } else { // if groovy source file only contains blank(including EOF), add "return null" to the AST -if (this.isBlankScript(ctx)) { +if (this.isBlankScript()) { this.addEmptyReturnStatement(); } } @@ -3396,7 +3396,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public Parameter[] visitFormalParameters(FormalParametersContext ctx) { if (!asBoolean(ctx)) { -return new Parameter[0]; +return Parameter.EMPTY_ARRAY; } return this.visitFormalParameterList(ctx.formalParameterList()); @@ -3405,7 +3405,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public Parameter[] visitFormalParameterList(FormalParameterListContext ctx) { if (!asBoolean(ctx)) { -return new Parameter[0]; +return Parameter.EMPTY_ARRAY; } List parameterList = new LinkedList<>(); @@ -3428,7 +3428,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov validateParameterList(parameterList); -return parameterList.toArray(new Parameter[0]); +return parameterList.toArray(Parameter.EMPTY_ARRAY); } private void validateVarArgParameter(List formalParameterList) { @@ -3912,7 +3912,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public ClassNode[] visitQualifiedClassNameList(QualifiedClassNameListContext ctx) { if (!asBoolean(ctx)) { -return new ClassNode[0]; +return ClassNode.EMPTY_ARRAY; } List list = new ArrayList<>(); @@ -4202,7 +4202,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } -private boolean isBlankScript(CompilationUnitContext ctx) { +private boolean isBlankScript() { return moduleNode.getStatementBlock().isEmpty() && moduleNode.getMethods().isEmpty() && moduleNode.getClasses().isEmpty(); }
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master 0d7b0bcc5 -> 4b09236fd Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4b09236f Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4b09236f Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4b09236f Branch: refs/heads/master Commit: 4b09236fdd15c3d73fbf58b0fac8565e7b843a88 Parents: 0d7b0bc Author: sunlan <sun...@apache.org> Authored: Thu Sep 7 21:16:18 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 7 21:16:18 2017 +0800 -- src/main/org/codehaus/groovy/ast/Parameter.java | 3 +-- .../org/apache/groovy/parser/antlr4/AstBuilder.java | 12 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/4b09236f/src/main/org/codehaus/groovy/ast/Parameter.java -- diff --git a/src/main/org/codehaus/groovy/ast/Parameter.java b/src/main/org/codehaus/groovy/ast/Parameter.java index a49b34a..c3df7c3 100644 --- a/src/main/org/codehaus/groovy/ast/Parameter.java +++ b/src/main/org/codehaus/groovy/ast/Parameter.java @@ -29,8 +29,7 @@ import org.codehaus.groovy.ast.expr.*; */ public class Parameter extends AnnotatedNode implements Variable { -public static final Parameter[] EMPTY_ARRAY = { -}; +public static final Parameter[] EMPTY_ARRAY = {}; private ClassNode type; private final String name; http://git-wip-us.apache.org/repos/asf/groovy/blob/4b09236f/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index a833973..7b63bee 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -264,7 +264,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov this.addPackageInfoClassNode(); } else { // if groovy source file only contains blank(including EOF), add "return null" to the AST -if (this.isBlankScript(ctx)) { +if (this.isBlankScript()) { this.addEmptyReturnStatement(); } } @@ -3347,7 +3347,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public Parameter[] visitFormalParameters(FormalParametersContext ctx) { if (!asBoolean(ctx)) { -return new Parameter[0]; +return Parameter.EMPTY_ARRAY; } return this.visitFormalParameterList(ctx.formalParameterList()); @@ -3356,7 +3356,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public Parameter[] visitFormalParameterList(FormalParameterListContext ctx) { if (!asBoolean(ctx)) { -return new Parameter[0]; +return Parameter.EMPTY_ARRAY; } List parameterList = new LinkedList<>(); @@ -3377,7 +3377,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov validateParameterList(parameterList); -return parameterList.toArray(new Parameter[0]); +return parameterList.toArray(Parameter.EMPTY_ARRAY); } private void validateVarArgParameter(List formalParameterList) { @@ -3828,7 +3828,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov @Override public ClassNode[] visitQualifiedClassNameList(QualifiedClassNameListContext ctx) { if (!asBoolean(ctx)) { -return new ClassNode[0]; +return ClassNode.EMPTY_ARRAY; } return ctx.annotatedQualifiedClassName().stream() @@ -4122,7 +4122,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } -private boolean isBlankScript(CompilationUnitContext ctx) { +private boolean isBlankScript() { return moduleNode.getStatementBlock().isEmpty() && moduleNode.getMethods().isEmpty() && moduleNode.getClasses().isEmpty(); }
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 1a2aff345 -> 6fd3f95e4 Minor refactoring (cherry picked from commit 1f2ca64) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6fd3f95e Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6fd3f95e Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6fd3f95e Branch: refs/heads/GROOVY_2_6_X Commit: 6fd3f95e4eec58c5732f04038c55fd075fb60698 Parents: 1a2aff3 Author: sunlan <sun...@apache.org> Authored: Thu Sep 7 02:01:44 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 7 07:57:42 2017 +0800 -- .../apache/groovy/parser/antlr4/AstBuilder.java | 35 1 file changed, 21 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/6fd3f95e/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 2766c02..9cd91c8 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -147,7 +147,6 @@ import static org.codehaus.groovy.runtime.DefaultGroovyMethods.last; * Created on 2016/08/14 */ public class AstBuilder extends GroovyParserBaseVisitor implements GroovyParserVisitor { - public AstBuilder(SourceUnit sourceUnit, ClassLoader classLoader) { this.sourceUnit = sourceUnit; this.moduleNode = new ModuleNode(sourceUnit); @@ -2352,17 +2351,17 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov int slashyType = getSlashyType(text); boolean startsWithSlash = false; -if (text.startsWith("'''") || text.startsWith("\"\"\"")) { +if (text.startsWith(TSQ_STR) || text.startsWith(TDQ_STR)) { text = StringUtils.removeCR(text); // remove CR in the multiline string text = StringUtils.trimQuotations(text, 3); -} else if (text.startsWith("'") || text.startsWith("\"") || (startsWithSlash = text.startsWith("/"))) { +} else if (text.startsWith(SQ_STR) || text.startsWith(DQ_STR) || (startsWithSlash = text.startsWith(SLASH_STR))) { if (startsWithSlash) { // the slashy string can span rows, so we have to remove CR for it text = StringUtils.removeCR(text); // remove CR in the multiline string } text = StringUtils.trimQuotations(text, 1); -} else if (text.startsWith("$/")) { +} else if (text.startsWith(DOLLAR_SLASH_STR)) { text = StringUtils.removeCR(text); text = StringUtils.trimQuotations(text, 2); @@ -2378,8 +2377,8 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } private int getSlashyType(String text) { -return text.startsWith("/") ? StringUtils.SLASHY : -text.startsWith("$/") ? StringUtils.DOLLAR_SLASHY : StringUtils.NONE_SLASHY; +return text.startsWith(SLASH_STR) ? StringUtils.SLASHY : +text.startsWith(DOLLAR_SLASH_STR) ? StringUtils.DOLLAR_SLASHY : StringUtils.NONE_SLASHY; } @Override @@ -3198,13 +3197,13 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov { String it = begin; -if (it.startsWith("\"\"\"")) { +if (it.startsWith(TDQ_STR)) { it = StringUtils.removeCR(it); it = it.substring(2); // translate leading """ to " -} else if (it.startsWith("$/")) { +} else if (it.startsWith(DOLLAR_SLASH_STR)) { it = StringUtils.removeCR(it); -it = "\"" + it.substring(2); // translate leading $/ to " -} else if (it.startsWith("/")) { +it = DQ_STR + it.substring(2); // translate leading $/ to " +} else if (it.startsWith(SLASH_STR)) { it = StringUtils.removeCR(it); } @@ -3230,13 +3229,13 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov { String it = ctx.GStringEnd().getText(); -if (it.endsWith("\"\"\"")) { +if (it.endsWith(TDQ_STR)) { it = Stri
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master 3853aca6e -> 1f2ca648a Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1f2ca648 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1f2ca648 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1f2ca648 Branch: refs/heads/master Commit: 1f2ca648a9971cd6bb17a112524d6c0259428b01 Parents: 3853aca Author: sunlan <sun...@apache.org> Authored: Thu Sep 7 02:01:44 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Thu Sep 7 02:01:44 2017 +0800 -- .../apache/groovy/parser/antlr4/AstBuilder.java | 35 1 file changed, 21 insertions(+), 14 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/1f2ca648/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 7f0e391..8d15e54 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -149,7 +149,6 @@ import static org.codehaus.groovy.runtime.DefaultGroovyMethods.last; * Created on 2016/08/14 */ public class AstBuilder extends GroovyParserBaseVisitor implements GroovyParserVisitor { - public AstBuilder(SourceUnit sourceUnit, ClassLoader classLoader) { this.sourceUnit = sourceUnit; this.moduleNode = new ModuleNode(sourceUnit); @@ -2325,17 +2324,17 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov int slashyType = getSlashyType(text); boolean startsWithSlash = false; -if (text.startsWith("'''") || text.startsWith("\"\"\"")) { +if (text.startsWith(TSQ_STR) || text.startsWith(TDQ_STR)) { text = StringUtils.removeCR(text); // remove CR in the multiline string text = StringUtils.trimQuotations(text, 3); -} else if (text.startsWith("'") || text.startsWith("\"") || (startsWithSlash = text.startsWith("/"))) { +} else if (text.startsWith(SQ_STR) || text.startsWith(DQ_STR) || (startsWithSlash = text.startsWith(SLASH_STR))) { if (startsWithSlash) { // the slashy string can span rows, so we have to remove CR for it text = StringUtils.removeCR(text); // remove CR in the multiline string } text = StringUtils.trimQuotations(text, 1); -} else if (text.startsWith("$/")) { +} else if (text.startsWith(DOLLAR_SLASH_STR)) { text = StringUtils.removeCR(text); text = StringUtils.trimQuotations(text, 2); @@ -2351,8 +2350,8 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } private int getSlashyType(String text) { -return text.startsWith("/") ? StringUtils.SLASHY : -text.startsWith("$/") ? StringUtils.DOLLAR_SLASHY : StringUtils.NONE_SLASHY; +return text.startsWith(SLASH_STR) ? StringUtils.SLASHY : +text.startsWith(DOLLAR_SLASH_STR) ? StringUtils.DOLLAR_SLASHY : StringUtils.NONE_SLASHY; } @Override @@ -3157,13 +3156,13 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov { String it = begin; -if (it.startsWith("\"\"\"")) { +if (it.startsWith(TDQ_STR)) { it = StringUtils.removeCR(it); it = it.substring(2); // translate leading """ to " -} else if (it.startsWith("$/")) { +} else if (it.startsWith(DOLLAR_SLASH_STR)) { it = StringUtils.removeCR(it); -it = "\"" + it.substring(2); // translate leading $/ to " -} else if (it.startsWith("/")) { +it = DQ_STR + it.substring(2); // translate leading $/ to " +} else if (it.startsWith(SLASH_STR)) { it = StringUtils.removeCR(it); } @@ -3190,13 +3189,13 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov { String it = ctx.GStringEnd().getText(); -if (it.endsWith("\"\"\"")) { +if (it.endsWith(TDQ_STR)) { it = StringUtils.removeCR(it); it = Str
groovy git commit: Change the default encoding of source file to UTF-8
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X e9960604a -> d12cf899c Change the default encoding of source file to UTF-8 (cherry picked from commit e490280) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d12cf899 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d12cf899 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d12cf899 Branch: refs/heads/GROOVY_2_6_X Commit: d12cf899cca922c0ec7627dc51459c0e2e48f02a Parents: e996060 Author: sunlan <sun...@apache.org> Authored: Fri Sep 8 11:44:10 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 8 11:45:10 2017 +0800 -- src/main/org/codehaus/groovy/control/CompilerConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/d12cf899/src/main/org/codehaus/groovy/control/CompilerConfiguration.java -- diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java index fbc3d0d..4003990 100644 --- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java +++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java @@ -222,7 +222,7 @@ public class CompilerConfiguration { setDefaultScriptExtension(safeGetSystemProperty("groovy.default.scriptExtension", ".groovy")); // Source file encoding -String encoding = safeGetSystemProperty("file.encoding", "US-ASCII"); +String encoding = safeGetSystemProperty("file.encoding", "UTF-8"); encoding = safeGetSystemProperty("groovy.source.encoding", encoding); setSourceEncoding(encoding);
groovy git commit: Change the default encoding of source file to UTF-8
Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 0eddf67ad -> 9cdbdd08a Change the default encoding of source file to UTF-8 (cherry picked from commit e490280) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/9cdbdd08 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/9cdbdd08 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/9cdbdd08 Branch: refs/heads/GROOVY_2_5_X Commit: 9cdbdd08a7c246ff5722576643898b9fc280f524 Parents: 0eddf67 Author: sunlan <sun...@apache.org> Authored: Fri Sep 8 11:44:10 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 8 11:45:42 2017 +0800 -- src/main/org/codehaus/groovy/control/CompilerConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/9cdbdd08/src/main/org/codehaus/groovy/control/CompilerConfiguration.java -- diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java index 39a195e..c3ddb42 100644 --- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java +++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java @@ -203,7 +203,7 @@ public class CompilerConfiguration { setDefaultScriptExtension(safeGetSystemProperty("groovy.default.scriptExtension", ".groovy")); // Source file encoding -String encoding = safeGetSystemProperty("file.encoding", "US-ASCII"); +String encoding = safeGetSystemProperty("file.encoding", "UTF-8"); encoding = safeGetSystemProperty("groovy.source.encoding", encoding); setSourceEncoding(encoding);
groovy git commit: Change the default encoding of source file to UTF-8
Repository: groovy Updated Branches: refs/heads/master be385debc -> e49028082 Change the default encoding of source file to UTF-8 Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e4902808 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e4902808 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e4902808 Branch: refs/heads/master Commit: e49028082882a01c4830625171cc05bc30e53e7d Parents: be385de Author: sunlan <sun...@apache.org> Authored: Fri Sep 8 11:44:10 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 8 11:44:23 2017 +0800 -- src/main/org/codehaus/groovy/control/CompilerConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e4902808/src/main/org/codehaus/groovy/control/CompilerConfiguration.java -- diff --git a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java index 267f55d..0a001ff 100644 --- a/src/main/org/codehaus/groovy/control/CompilerConfiguration.java +++ b/src/main/org/codehaus/groovy/control/CompilerConfiguration.java @@ -227,7 +227,7 @@ public class CompilerConfiguration { setDefaultScriptExtension(safeGetSystemProperty("groovy.default.scriptExtension", ".groovy")); // Source file encoding -String encoding = safeGetSystemProperty("file.encoding", "US-ASCII"); +String encoding = safeGetSystemProperty("file.encoding", "UTF-8"); encoding = safeGetSystemProperty("groovy.source.encoding", encoding); setSourceEncoding(encoding);
[2/2] groovy git commit: GROOVY-8300: @AutoFinal (asciidoc doco)
GROOVY-8300: @AutoFinal (asciidoc doco) (cherry picked from commit 9ea35d6) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/5db12571 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/5db12571 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/5db12571 Branch: refs/heads/GROOVY_2_6_X Commit: 5db12571492b064fe4fdde679ee0ff1fc8469616 Parents: c7774a3 Author: paulk <pa...@asert.com.au> Authored: Wed Sep 13 20:35:27 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 20:50:23 2017 +0800 -- src/spec/doc/core-metaprogramming.adoc | 37 .../CompilerDirectivesASTTransformsTest.groovy | 46 2 files changed, 83 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/5db12571/src/spec/doc/core-metaprogramming.adoc -- diff --git a/src/spec/doc/core-metaprogramming.adoc b/src/spec/doc/core-metaprogramming.adoc index f2ffdc4..e18784a 100644 --- a/src/spec/doc/core-metaprogramming.adoc +++ b/src/spec/doc/core-metaprogramming.adoc @@ -2357,6 +2357,43 @@ The `@PackageScope` annotation is seldom used as part of normal Groovy conventio for factory methods that should be visible internally within a package or for methods or constructors provided for testing purposes, or when integrating with third-party libraries which require such visibility conventions. +[[xform-AutoFinal]] += `@groovy.transform.AutoFinal` + +The `@AutoFinal` annotation instructs the compiler to automatically insert the final modifier +in numerous places within the annotated node. If applied on a method (or constructor), the parameters +for that method (or constructor) will be marked as final. If applied on a class definition, the same +treatment will occur for all declared methods and constructors within that class. + +It is often considered bad practice to reassign parameters of a method or constructor with its body. +By adding the final modifier to all parameter declarations you can avoid this practice entirely. +Some programmers feel that adding final everywhere increases the amount of boilerplate code and makes the +method signatures somewhat noisy. An alternative might instead be to use a code review process or apply +a http://codenarc.org[codenarc] http://codenarc.sourceforge.net/codenarc-rules-convention.html#ParameterReassignment[rule] +to give warnings if that practice is observed but these alternatives might lead to delayed feedback during +quality checking rather than within the IDE or during compilation. The `@AutoFinal` annotation aims to +maximise compiler/IDE feedback while retaining succinct code with minimum boilerplate noise. + +The following example illustrates applying the annotation at the class level: + +[source,groovy] + +include::{projectdir}/src/spec/test/CompilerDirectivesASTTransformsTest.groovy[tags=autofinal_class,indent=0] + + +In this example, the two parameters for the constructor and the single parameter for +both the `fullname` and `greeting` methods will be final. Attempts to modify those parameters within the +constructor or method bodies will be flagged by the compiler. + +The following example illustrates applying the annotation at the method level: + +[source,groovy] + +include::{projectdir}/src/spec/test/CompilerDirectivesASTTransformsTest.groovy[tags=autofinal_method,indent=0] + + +Here, the `add` method will have final parameters but the `mult` method will remain unchanged. + [[xform-AnnotationCollector]] = `@groovy.transform.AnnotationCollector` http://git-wip-us.apache.org/repos/asf/groovy/blob/5db12571/src/spec/test/CompilerDirectivesASTTransformsTest.groovy -- diff --git a/src/spec/test/CompilerDirectivesASTTransformsTest.groovy b/src/spec/test/CompilerDirectivesASTTransformsTest.groovy index 29ccd9f..8e72851 100644 --- a/src/spec/test/CompilerDirectivesASTTransformsTest.groovy +++ b/src/spec/test/CompilerDirectivesASTTransformsTest.groovy @@ -96,6 +96,52 @@ new MyScript().run() ''' } +void testAutoFinalClass() { +assertScript ''' +// tag::autofinal_class[] +import groovy.transform.AutoFinal + +@AutoFinal +class Person { +private String first, last + +Person(String first, String last) { +this.first = first +this.last = last +} + +String fullName(String separator) { +"$first$separator$last" +} + +String greeting(String salutation) { +"$salutation, $first" +} +} +// end::autofinal_class[] +def john = new Person('John', 'Smith') +assert john.fullName(' ') == 'John Smith' +assert john.g
groovy git commit: Use "replace" method from commons-lang3 to improve performance
Repository: groovy Updated Branches: refs/heads/master 9ea35d6aa -> a4f779335 Use "replace" method from commons-lang3 to improve performance Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a4f77933 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a4f77933 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a4f77933 Branch: refs/heads/master Commit: a4f779335c97d0aa0fe2f42351b13eedf48e6119 Parents: 9ea35d6 Author: sunlan <sun...@apache.org> Authored: Wed Sep 13 21:52:58 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 21:52:58 2017 +0800 -- .../groovy/parser/antlr4/util/StringUtils.java | 172 ++- 1 file changed, 166 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/a4f77933/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index 928f8ab..02b09d4 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -80,7 +80,7 @@ public class StringUtils { } }); - return result.replace("", "\\"); + return replace(result,"", "\\"); } public static final int NONE_SLASHY = 0; @@ -93,12 +93,12 @@ public class StringUtils { text = StringUtils.replaceLineEscape(text); if (slashyType == SLASHY) { - text = text.replace("\\/", "/"); + text = replace(text,"\\/", "/"); } if (slashyType == DOLLAR_SLASHY) { - text = text.replace("$$", "$"); - text = text.replace("$/", "/"); + text = replace(text,"$$", "$"); + text = replace(text,"$/", "/"); } } else if (slashyType == NONE_SLASHY) { @@ -111,7 +111,7 @@ public class StringUtils { } private static String replaceEscapes(String text) { - text = text.replace("\\$", "$"); + text = replace(text,"\\$", "$"); text = StringUtils.replaceLineEscape(text); @@ -138,7 +138,7 @@ public class StringUtils { } public static String removeCR(String text) { - return text.replace("\r\n", "\n"); + return replace(text,"\r\n", "\n"); } public static long countChar(String text, char c) { @@ -150,4 +150,164 @@ public class StringUtils { return length == quotationLength << 1 ? "" : text.substring(quotationLength, length - quotationLength); } + + + /** +* Copied from Apache commons-lang3-3.6 +* +* Replaces all occurrences of a String within another String. +* +* A {@code null} reference passed to this method is a no-op. +* +* +* StringUtils.replace(null, *, *)= null +* StringUtils.replace("", *, *) = "" +* StringUtils.replace("any", null, *)= "any" +* StringUtils.replace("any", *, null)= "any" +* StringUtils.replace("any", "", *) = "any" +* StringUtils.replace("aba", "a", null) = "aba" +* StringUtils.replace("aba", "a", "")= "b" +* StringUtils.replace("aba", "a", "z") = "zbz" +* +* +* @see #replace(String text, String searchString, String replacement, int max) +* @param text text to search and replace in, may be null +* @param searchString the String to search for, may be null +* @param replacement the String to replace it with, may be null +* @return the text with any replacements processed, +* {@code null} if null String input +*/ +
groovy git commit: GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)
Repository: groovy Updated Branches: refs/heads/master 26fc4e0f2 -> 34df6cf46 GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/34df6cf4 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/34df6cf4 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/34df6cf4 Branch: refs/heads/master Commit: 34df6cf461a5ecce66f2c2c0f14489cf96feaf34 Parents: 26fc4e0 Author: sunlan <sun...@apache.org> Authored: Wed Sep 13 20:20:11 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 20:20:11 2017 +0800 -- .../stc/StaticTypeCheckingSupport.java | 11 ++- src/test/groovy/bugs/Groovy7721Bug.groovy | 80 2 files changed, 89 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/34df6cf4/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index 98fb157..eb208fe 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -1149,13 +1149,20 @@ public abstract class StaticTypeCheckingSupport { private static void removeMethodWithSuperReturnType(List toBeRemoved, MethodNode one, MethodNode two) { ClassNode oneRT = one.getReturnType(); ClassNode twoRT = two.getReturnType(); -if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) { +if (isCovariant(oneRT, twoRT)) { toBeRemoved.add(two); -} else if (twoRT.isDerivedFrom(oneRT) || twoRT.implementsInterface(oneRT)) { +} else if (isCovariant(twoRT, oneRT)) { toBeRemoved.add(one); } } +private static boolean isCovariant(ClassNode left, ClassNode right) { +if (left.isArray() && right.isArray()) { +return isCovariant(left.getComponentType(), right.getComponentType()); +} +return left.isDerivedFrom(right) || left.implementsInterface(right); +} + private static boolean areOverloadMethodsInSameClass(MethodNode one, MethodNode two) { return one.getName().equals(two.getName()) && one.getDeclaringClass() == two.getDeclaringClass(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/34df6cf4/src/test/groovy/bugs/Groovy7721Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy b/src/test/groovy/bugs/Groovy7721Bug.groovy new file mode 100644 index 000..f316a2a --- /dev/null +++ b/src/test/groovy/bugs/Groovy7721Bug.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package groovy.bugs + +import org.codehaus.groovy.control.CompilerConfiguration +import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit + +class Groovy7721Bug extends GroovyTestCase { +void testCovariantArrayAtOverriding() { +def config = new CompilerConfiguration() +config.with { +targetDirectory = createTempDir() +jointCompilationOptions = [stubDir: createTempDir()] +} + +File parentDir = createTempDir() +try { +def a = new File(parentDir, 'A.java') +a.write ''' +package pack; +interface A { +Object[] bar(); +} + +''' +def b = new File(parentDir, 'B.java') +b.write ''' +package pack; +interface B extends A { +@Override +String[] bar(); +
groovy git commit: Use "replace" method from commons-lang3 to improve performance
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 5db125714 -> 6e47e6df4 Use "replace" method from commons-lang3 to improve performance (cherry picked from commit a4f779335c97d0aa0fe2f42351b13eedf48e6119) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6e47e6df Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6e47e6df Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6e47e6df Branch: refs/heads/GROOVY_2_6_X Commit: 6e47e6df435ad590863e5e9ee1a8996143a841a1 Parents: 5db1257 Author: sunlan <sun...@apache.org> Authored: Wed Sep 13 22:12:26 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 22:12:26 2017 +0800 -- .../groovy/parser/antlr4/util/StringUtils.java | 172 ++- 1 file changed, 166 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/6e47e6df/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index 49b3f3c..86c91e6 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -80,7 +80,7 @@ public class StringUtils { } }); - return result.replace("", "\\"); + return replace(result,"", "\\"); } public static final int NONE_SLASHY = 0; @@ -93,12 +93,12 @@ public class StringUtils { text = StringUtils.replaceLineEscape(text); if (slashyType == SLASHY) { - text = text.replace("\\/", "/"); + text = replace(text,"\\/", "/"); } if (slashyType == DOLLAR_SLASHY) { - text = text.replace("$$", "$"); - text = text.replace("$/", "/"); + text = replace(text,"$$", "$"); + text = replace(text,"$/", "/"); } } else if (slashyType == NONE_SLASHY) { @@ -111,7 +111,7 @@ public class StringUtils { } private static String replaceEscapes(String text) { - text = text.replace("\\$", "$"); + text = replace(text,"\\$", "$"); text = StringUtils.replaceLineEscape(text); @@ -138,7 +138,7 @@ public class StringUtils { } public static String removeCR(String text) { - return text.replace("\r\n", "\n"); + return replace(text,"\r\n", "\n"); } public static long countChar(String text, char c) { @@ -155,4 +155,164 @@ public class StringUtils { return length == quotationLength << 1 ? "" : text.substring(quotationLength, length - quotationLength); } + + + /** +* Copied from Apache commons-lang3-3.6 +* +* Replaces all occurrences of a String within another String. +* +* A {@code null} reference passed to this method is a no-op. +* +* +* StringUtils.replace(null, *, *)= null +* StringUtils.replace("", *, *) = "" +* StringUtils.replace("any", null, *)= "any" +* StringUtils.replace("any", *, null)= "any" +* StringUtils.replace("any", "", *) = "any" +* StringUtils.replace("aba", "a", null) = "aba" +* StringUtils.replace("aba", "a", "")= "b" +* StringUtils.replace("aba", "a", "z") = "zbz" +* +* +* @see #replace(String text, String searchString, String replacement, int max) +* @param text text to search and replace in, may be null +* @param searchString the String to search for, may be null +* @param replacement the String to replace it with, may be null +* @return the text with any replacements processed, +* {@c
groovy git commit: Revert "GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)"
Repository: groovy Updated Branches: refs/heads/master a4f779335 -> 695b7afb7 Revert "GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)" This reverts commit 34df6cf461a5ecce66f2c2c0f14489cf96feaf34. Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/695b7afb Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/695b7afb Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/695b7afb Branch: refs/heads/master Commit: 695b7afb7b2652b0e2043189b8c0b3c97f97c2c4 Parents: a4f7793 Author: sunlan <sun...@apache.org> Authored: Wed Sep 13 22:35:50 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 22:35:50 2017 +0800 -- .../stc/StaticTypeCheckingSupport.java | 11 +-- src/test/groovy/bugs/Groovy7721Bug.groovy | 80 2 files changed, 2 insertions(+), 89 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/695b7afb/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index eb208fe..98fb157 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -1149,20 +1149,13 @@ public abstract class StaticTypeCheckingSupport { private static void removeMethodWithSuperReturnType(List toBeRemoved, MethodNode one, MethodNode two) { ClassNode oneRT = one.getReturnType(); ClassNode twoRT = two.getReturnType(); -if (isCovariant(oneRT, twoRT)) { +if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) { toBeRemoved.add(two); -} else if (isCovariant(twoRT, oneRT)) { +} else if (twoRT.isDerivedFrom(oneRT) || twoRT.implementsInterface(oneRT)) { toBeRemoved.add(one); } } -private static boolean isCovariant(ClassNode left, ClassNode right) { -if (left.isArray() && right.isArray()) { -return isCovariant(left.getComponentType(), right.getComponentType()); -} -return left.isDerivedFrom(right) || left.implementsInterface(right); -} - private static boolean areOverloadMethodsInSameClass(MethodNode one, MethodNode two) { return one.getName().equals(two.getName()) && one.getDeclaringClass() == two.getDeclaringClass(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/695b7afb/src/test/groovy/bugs/Groovy7721Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy b/src/test/groovy/bugs/Groovy7721Bug.groovy deleted file mode 100644 index f316a2a..000 --- a/src/test/groovy/bugs/Groovy7721Bug.groovy +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - *http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package groovy.bugs - -import org.codehaus.groovy.control.CompilerConfiguration -import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit - -class Groovy7721Bug extends GroovyTestCase { -void testCovariantArrayAtOverriding() { -def config = new CompilerConfiguration() -config.with { -targetDirectory = createTempDir() -jointCompilationOptions = [stubDir: createTempDir()] -} - -File parentDir = createTempDir() -try { -def a = new File(parentDir, 'A.java') -a.write ''' -package pack; -interface A { -Object[] bar(); -} - -''' -def b = new File(parentDir, 'B.java') -b.write ''' -package pack; -interface B extends A { -
groovy git commit: GROOVY-7721: Static type checking fails when compiling against a Java8 interface with inherited methods
Repository: groovy Updated Branches: refs/heads/master 695b7afb7 -> 8ad6e770a GROOVY-7721: Static type checking fails when compiling against a Java8 interface with inherited methods Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8ad6e770 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8ad6e770 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8ad6e770 Branch: refs/heads/master Commit: 8ad6e770ab2a6c6968ae02ddc5d49d7d6e6f79f3 Parents: 695b7af Author: alexey.afanasiev <alexey.afanas...@jetbrains.com> Authored: Wed Sep 13 13:14:58 2017 +0300 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 22:42:01 2017 +0800 -- .../stc/StaticTypeCheckingSupport.java | 11 ++- src/test/groovy/bugs/Groovy7721Bug.groovy | 80 2 files changed, 89 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/8ad6e770/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index 98fb157..eb208fe 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -1149,13 +1149,20 @@ public abstract class StaticTypeCheckingSupport { private static void removeMethodWithSuperReturnType(List toBeRemoved, MethodNode one, MethodNode two) { ClassNode oneRT = one.getReturnType(); ClassNode twoRT = two.getReturnType(); -if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) { +if (isCovariant(oneRT, twoRT)) { toBeRemoved.add(two); -} else if (twoRT.isDerivedFrom(oneRT) || twoRT.implementsInterface(oneRT)) { +} else if (isCovariant(twoRT, oneRT)) { toBeRemoved.add(one); } } +private static boolean isCovariant(ClassNode left, ClassNode right) { +if (left.isArray() && right.isArray()) { +return isCovariant(left.getComponentType(), right.getComponentType()); +} +return left.isDerivedFrom(right) || left.implementsInterface(right); +} + private static boolean areOverloadMethodsInSameClass(MethodNode one, MethodNode two) { return one.getName().equals(two.getName()) && one.getDeclaringClass() == two.getDeclaringClass(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/8ad6e770/src/test/groovy/bugs/Groovy7721Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy b/src/test/groovy/bugs/Groovy7721Bug.groovy new file mode 100644 index 000..f316a2a --- /dev/null +++ b/src/test/groovy/bugs/Groovy7721Bug.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package groovy.bugs + +import org.codehaus.groovy.control.CompilerConfiguration +import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit + +class Groovy7721Bug extends GroovyTestCase { +void testCovariantArrayAtOverriding() { +def config = new CompilerConfiguration() +config.with { +targetDirectory = createTempDir() +jointCompilationOptions = [stubDir: createTempDir()] +} + +File parentDir = createTempDir() +try { +def a = new File(parentDir, 'A.java') +a.write ''' +package pack; +interface A { +Object[] bar(); +} + +''' +def b = new File(parentDir, 'B.java') +b.write ''' +package pack; +interface B extends A { +
[1/2] groovy git commit: Revert "GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)"
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 6e47e6df4 -> ddebbeca2 Revert "GROOVY-7721: Static type checking fails when compiling against a Java interface call (closes #599)" This reverts commit 34df6cf461a5ecce66f2c2c0f14489cf96feaf34. (cherry picked from commit 695b7af) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/22635dac Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/22635dac Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/22635dac Branch: refs/heads/GROOVY_2_6_X Commit: 22635dac48a84152fecc887e5a919efdd52009be Parents: 6e47e6d Author: sunlan <sun...@apache.org> Authored: Wed Sep 13 22:35:50 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 22:47:48 2017 +0800 -- .../stc/StaticTypeCheckingSupport.java | 11 +-- src/test/groovy/bugs/Groovy7721Bug.groovy | 80 2 files changed, 2 insertions(+), 89 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/22635dac/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index eb208fe..98fb157 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -1149,20 +1149,13 @@ public abstract class StaticTypeCheckingSupport { private static void removeMethodWithSuperReturnType(List toBeRemoved, MethodNode one, MethodNode two) { ClassNode oneRT = one.getReturnType(); ClassNode twoRT = two.getReturnType(); -if (isCovariant(oneRT, twoRT)) { +if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) { toBeRemoved.add(two); -} else if (isCovariant(twoRT, oneRT)) { +} else if (twoRT.isDerivedFrom(oneRT) || twoRT.implementsInterface(oneRT)) { toBeRemoved.add(one); } } -private static boolean isCovariant(ClassNode left, ClassNode right) { -if (left.isArray() && right.isArray()) { -return isCovariant(left.getComponentType(), right.getComponentType()); -} -return left.isDerivedFrom(right) || left.implementsInterface(right); -} - private static boolean areOverloadMethodsInSameClass(MethodNode one, MethodNode two) { return one.getName().equals(two.getName()) && one.getDeclaringClass() == two.getDeclaringClass(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/22635dac/src/test/groovy/bugs/Groovy7721Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy b/src/test/groovy/bugs/Groovy7721Bug.groovy deleted file mode 100644 index f316a2a..000 --- a/src/test/groovy/bugs/Groovy7721Bug.groovy +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - *http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -package groovy.bugs - -import org.codehaus.groovy.control.CompilerConfiguration -import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit - -class Groovy7721Bug extends GroovyTestCase { -void testCovariantArrayAtOverriding() { -def config = new CompilerConfiguration() -config.with { -targetDirectory = createTempDir() -jointCompilationOptions = [stubDir: createTempDir()] -} - -File parentDir = createTempDir() -try { -def a = new File(parentDir, 'A.java') -a.write ''' -package pack; -interface A { -Object[] bar(); -} - -''' -def b = new File(parentDir, 'B.java') -b.write ''' -
[2/2] groovy git commit: GROOVY-7721: Static type checking fails when compiling against a Java8 interface with inherited methods
GROOVY-7721: Static type checking fails when compiling against a Java8 interface with inherited methods (cherry picked from commit 8ad6e77) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ddebbeca Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ddebbeca Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ddebbeca Branch: refs/heads/GROOVY_2_6_X Commit: ddebbeca2a3441895046bc4dfe4a1ea128515dcc Parents: 22635da Author: alexey.afanasiev <alexey.afanas...@jetbrains.com> Authored: Wed Sep 13 18:14:58 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Wed Sep 13 22:48:00 2017 +0800 -- .../stc/StaticTypeCheckingSupport.java | 11 ++- src/test/groovy/bugs/Groovy7721Bug.groovy | 80 2 files changed, 89 insertions(+), 2 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/ddebbeca/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java -- diff --git a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java index 98fb157..eb208fe 100644 --- a/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java +++ b/src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingSupport.java @@ -1149,13 +1149,20 @@ public abstract class StaticTypeCheckingSupport { private static void removeMethodWithSuperReturnType(List toBeRemoved, MethodNode one, MethodNode two) { ClassNode oneRT = one.getReturnType(); ClassNode twoRT = two.getReturnType(); -if (oneRT.isDerivedFrom(twoRT) || oneRT.implementsInterface(twoRT)) { +if (isCovariant(oneRT, twoRT)) { toBeRemoved.add(two); -} else if (twoRT.isDerivedFrom(oneRT) || twoRT.implementsInterface(oneRT)) { +} else if (isCovariant(twoRT, oneRT)) { toBeRemoved.add(one); } } +private static boolean isCovariant(ClassNode left, ClassNode right) { +if (left.isArray() && right.isArray()) { +return isCovariant(left.getComponentType(), right.getComponentType()); +} +return left.isDerivedFrom(right) || left.implementsInterface(right); +} + private static boolean areOverloadMethodsInSameClass(MethodNode one, MethodNode two) { return one.getName().equals(two.getName()) && one.getDeclaringClass() == two.getDeclaringClass(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/ddebbeca/src/test/groovy/bugs/Groovy7721Bug.groovy -- diff --git a/src/test/groovy/bugs/Groovy7721Bug.groovy b/src/test/groovy/bugs/Groovy7721Bug.groovy new file mode 100644 index 000..f316a2a --- /dev/null +++ b/src/test/groovy/bugs/Groovy7721Bug.groovy @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +package groovy.bugs + +import org.codehaus.groovy.control.CompilerConfiguration +import org.codehaus.groovy.tools.javac.JavaAwareCompilationUnit + +class Groovy7721Bug extends GroovyTestCase { +void testCovariantArrayAtOverriding() { +def config = new CompilerConfiguration() +config.with { +targetDirectory = createTempDir() +jointCompilationOptions = [stubDir: createTempDir()] +} + +File parentDir = createTempDir() +try { +def a = new File(parentDir, 'A.java') +a.write ''' +package pack; +interface A { +Object[] bar(); +} + +''' +def b = new File(parentDir, 'B.java') +b.write ''' +package pack; +interface B extends A { +@Override +String[] bar(); +} +
groovy git commit: Refine groovydoc support
Repository: groovy Updated Branches: refs/heads/master c7f5931a0 -> b364be085 Refine groovydoc support Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b364be08 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b364be08 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b364be08 Branch: refs/heads/master Commit: b364be0850833f14012bfdd1bd31f29a82c8e0cd Parents: c7f5931 Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 11:37:28 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 11:37:28 2017 +0800 -- src/main/org/codehaus/groovy/ast/ClassNode.java | 10 ++- src/main/org/codehaus/groovy/ast/FieldNode.java | 13 +++- .../org/codehaus/groovy/ast/MethodNode.java | 9 ++- .../groovy/ast/groovydoc/Groovydoc.java | 68 ++ .../groovy/ast/groovydoc/GroovydocHolder.java | 31 .../groovy/ast/groovydoc/GroovydocTag.java | 74 .../groovy/parser/antlr4/GroovydocManager.java | 9 ++- .../parser/antlr4/GroovyParserTest.groovy | 56 +++ .../antlr4/util/ASTComparatorCategory.groovy| 2 +- 9 files changed, 236 insertions(+), 36 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/b364be08/src/main/org/codehaus/groovy/ast/ClassNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java index 283e86f..7e24de2 100644 --- a/src/main/org/codehaus/groovy/ast/ClassNode.java +++ b/src/main/org/codehaus/groovy/ast/ClassNode.java @@ -23,6 +23,8 @@ import org.codehaus.groovy.ast.expr.BinaryExpression; import org.codehaus.groovy.ast.expr.Expression; import org.codehaus.groovy.ast.expr.FieldExpression; import org.codehaus.groovy.ast.expr.TupleExpression; +import org.codehaus.groovy.ast.groovydoc.Groovydoc; +import org.codehaus.groovy.ast.groovydoc.GroovydocHolder; import org.codehaus.groovy.ast.stmt.BlockStatement; import org.codehaus.groovy.ast.stmt.ExpressionStatement; import org.codehaus.groovy.ast.stmt.Statement; @@ -103,7 +105,8 @@ import java.util.Set; * * @see org.codehaus.groovy.ast.ClassHelper */ -public class ClassNode extends AnnotatedNode implements Opcodes { +public class ClassNode extends AnnotatedNode implements Opcodes, GroovydocHolder { + private static class MapOfLists { private Map<Object, List> map; public List get(Object key) { @@ -1493,4 +1496,9 @@ public class ClassNode extends AnnotatedNode implements Opcodes { public String getText() { return getName(); } + +@Override +public Groovydoc getGroovydoc() { +return this.getNodeMetaData(DOC_COMMENT); +} } http://git-wip-us.apache.org/repos/asf/groovy/blob/b364be08/src/main/org/codehaus/groovy/ast/FieldNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/FieldNode.java b/src/main/org/codehaus/groovy/ast/FieldNode.java index c791346..987349b 100644 --- a/src/main/org/codehaus/groovy/ast/FieldNode.java +++ b/src/main/org/codehaus/groovy/ast/FieldNode.java @@ -18,17 +18,19 @@ */ package org.codehaus.groovy.ast; -import java.lang.reflect.Field; - import org.codehaus.groovy.ast.expr.Expression; +import org.codehaus.groovy.ast.groovydoc.Groovydoc; +import org.codehaus.groovy.ast.groovydoc.GroovydocHolder; import org.objectweb.asm.Opcodes; +import java.lang.reflect.Field; + /** * Represents a field (member variable) * * @author mailto:ja...@coredevelopers.net;>James Strachan */ -public class FieldNode extends AnnotatedNode implements Opcodes, Variable { +public class FieldNode extends AnnotatedNode implements Opcodes, Variable, GroovydocHolder { private String name; private int modifiers; @@ -190,4 +192,9 @@ public class FieldNode extends AnnotatedNode implements Opcodes, Variable { declaringClass.renameField(this.name, name); this.name = name; } + +@Override +public Groovydoc getGroovydoc() { +return this.getNodeMetaData(DOC_COMMENT); +} } http://git-wip-us.apache.org/repos/asf/groovy/blob/b364be08/src/main/org/codehaus/groovy/ast/MethodNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/MethodNode.java b/src/main/org/codehaus/groovy/ast/MethodNode.java index 7239a86..ea0db81 100644 --- a/src/main/org/codehaus/groovy/ast/MethodNode.java +++ b/src/main/org/codehaus/groovy/ast/MethodNode.java @@ -19,6 +19,8 @@ package org.codehaus.groovy.ast; import org.apache.groovy.ast.tools.MethodNodeUtils; +import org.codehaus.groovy.ast.groo
groovy git commit: Add `getGroovydoc` DGMs
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 711620419 -> b1d964dba Add `getGroovydoc` DGMs (cherry picked from commit ec49133) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b1d964db Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b1d964db Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b1d964db Branch: refs/heads/GROOVY_2_6_X Commit: b1d964dbad396901f79e7a1901175562e95ecaeb Parents: 7116204 Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 14:02:06 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 14:04:02 2017 +0800 -- .../groovy/runtime/DefaultGroovyMethods.java| 138 ++- .../test/resources/core/Groovydoc_01x.groovy| 12 +- 2 files changed, 139 insertions(+), 11 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/b1d964db/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java -- diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java index dd0ae2c..9f99021 100644 --- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java +++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java @@ -20,7 +20,31 @@ package org.codehaus.groovy.runtime; import groovy.io.FileType; import groovy.io.GroovyPrintWriter; -import groovy.lang.*; +import groovy.lang.Closure; +import groovy.lang.DelegatesTo; +import groovy.lang.DelegatingMetaClass; +import groovy.lang.EmptyRange; +import groovy.lang.ExpandoMetaClass; +import groovy.lang.GString; +import groovy.lang.GroovyObject; +import groovy.lang.GroovyRuntimeException; +import groovy.lang.GroovySystem; +import groovy.lang.Groovydoc; +import groovy.lang.IntRange; +import groovy.lang.ListWithDefault; +import groovy.lang.MapWithDefault; +import groovy.lang.MetaClass; +import groovy.lang.MetaClassImpl; +import groovy.lang.MetaClassRegistry; +import groovy.lang.MetaMethod; +import groovy.lang.MetaProperty; +import groovy.lang.MissingPropertyException; +import groovy.lang.ObjectRange; +import groovy.lang.PropertyValue; +import groovy.lang.Range; +import groovy.lang.SpreadMap; +import groovy.lang.Tuple2; +import groovy.lang.Writable; import groovy.transform.stc.ClosureParams; import groovy.transform.stc.FirstParam; import groovy.transform.stc.FromString; @@ -44,7 +68,24 @@ import org.codehaus.groovy.runtime.dgmimpl.NumberNumberDiv; import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMinus; import org.codehaus.groovy.runtime.dgmimpl.NumberNumberMultiply; import org.codehaus.groovy.runtime.dgmimpl.NumberNumberPlus; -import org.codehaus.groovy.runtime.dgmimpl.arrays.*; +import org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.BooleanArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ByteArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.CharacterArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.DoubleArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.FloatArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.IntegerArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.LongArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayPutAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayGetAtMetaMethod; +import org.codehaus.groovy.runtime.dgmimpl.arrays.ShortArrayPutAtMetaMethod; import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl; import org.codehaus.groovy.runtime.metaclass.MissingPropertyExceptionNoStack; import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation; @@ -53,11 +94,31 @@ import org.codehaus.groovy.runtime.typehandling.NumberMath; import org.codehaus.groovy.tools.RootLoader; import org.codehaus.groovy.transform.trait.Traits; import org.codehaus.groovy.util.ArrayIterator; -import org.codehaus.groovy.util.ListBufferedIterator; import org.codehaus.groovy.util.IteratorBufferedIterator; +import org.codehaus.groovy.util.ListBufferedIter
groovy git commit: Refine groovydoc support further
Repository: groovy Updated Branches: refs/heads/master 86eb9dd7d -> 43067475c Refine groovydoc support further Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/43067475 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/43067475 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/43067475 Branch: refs/heads/master Commit: 43067475c75fe175ebb345ce9fb4f75e8cbae419 Parents: 86eb9dd Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 21:16:40 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 22:02:14 2017 +0800 -- src/main/groovy/lang/groovydoc/Groovydoc.java | 96 .../groovy/lang/groovydoc/GroovydocHolder.java | 33 +++ .../groovy/lang/groovydoc/GroovydocTag.java | 68 ++ src/main/org/codehaus/groovy/ast/ClassNode.java | 9 +- src/main/org/codehaus/groovy/ast/FieldNode.java | 9 +- .../org/codehaus/groovy/ast/MethodNode.java | 9 +- .../groovy/ast/groovydoc/Groovydoc.java | 68 -- .../groovy/ast/groovydoc/GroovydocHolder.java | 31 --- .../groovy/ast/groovydoc/GroovydocTag.java | 74 --- .../groovy/runtime/DefaultGroovyMethods.java| 4 +- .../groovy/parser/antlr4/GroovydocManager.java | 4 +- .../test/resources/core/Groovydoc_01x.groovy| 12 +-- 12 files changed, 228 insertions(+), 189 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/43067475/src/main/groovy/lang/groovydoc/Groovydoc.java -- diff --git a/src/main/groovy/lang/groovydoc/Groovydoc.java b/src/main/groovy/lang/groovydoc/Groovydoc.java new file mode 100644 index 000..7b281ff --- /dev/null +++ b/src/main/groovy/lang/groovydoc/Groovydoc.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.lang.groovydoc; + +import java.lang.reflect.AnnotatedElement; +import java.util.List; +import java.util.Objects; + +/** + * Represents groovydoc + */ +public class Groovydoc { +private final String content; +private List tagList; +private final GroovydocHolder groovydocHolder; + +public Groovydoc(String content, GroovydocHolder groovydocHolder) { +this.content = content; +this.groovydocHolder = groovydocHolder; +} + +public Groovydoc(final String content, final AnnotatedElement annotatedElement) { +this.content = content; +this.groovydocHolder = new GroovydocHolder() { +@Override +public Groovydoc getGroovydoc() { +return Groovydoc.this; +} + +@Override +public Object getInstance() { +return annotatedElement; +} +}; +} + +/** + * Get the content of groovydoc + * @return the text content + */ +public String getContent() { +return content; +} + +/** + * TODO Get list of groovydoc tags + * @return a list of tags + */ +public List getTagList() { +throw new UnsupportedOperationException("[TODO]parsing tags will be a new features of the next releases"); +//return tagList; +} + +/** + * Get the holder of the groovydoc + * @return the groovydoc holder + */ +public GroovydocHolder getGroovydocHolder() { +return groovydocHolder; +} + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +Groovydoc groovydoc = (Groovydoc) o; +return Objects.equals(content, groovydoc.content) && +Objects.equals(groovydocHolder, groovydoc.groovydocHolder); +} + +@Override +public int hashCode() { +return Objects.hash(content, groovydocHolder); +} + +@Override +public String toString() { +return this.content; +} +} http://git-wip-us.apache.or
[2/2] groovy git commit: Refine groovydoc support further
Refine groovydoc support further (cherry picked from commit 4306747) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/f7e2c46a Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f7e2c46a Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f7e2c46a Branch: refs/heads/GROOVY_2_6_X Commit: f7e2c46a0b3e3b91247166114067dd7f990efcfb Parents: ba37b01 Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 21:16:40 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 22:46:59 2017 +0800 -- src/main/groovy/lang/groovydoc/Groovydoc.java | 96 .../groovy/lang/groovydoc/GroovydocHolder.java | 33 +++ .../groovy/lang/groovydoc/GroovydocTag.java | 68 ++ src/main/org/codehaus/groovy/ast/ClassNode.java | 9 +- src/main/org/codehaus/groovy/ast/FieldNode.java | 9 +- .../org/codehaus/groovy/ast/MethodNode.java | 9 +- .../groovy/ast/groovydoc/Groovydoc.java | 68 -- .../groovy/ast/groovydoc/GroovydocHolder.java | 31 --- .../groovy/ast/groovydoc/GroovydocTag.java | 74 --- .../groovy/runtime/DefaultGroovyMethods.java| 4 +- .../groovy/parser/antlr4/GroovydocManager.java | 4 +- .../test/resources/core/Groovydoc_01x.groovy| 12 +-- 12 files changed, 228 insertions(+), 189 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/f7e2c46a/src/main/groovy/lang/groovydoc/Groovydoc.java -- diff --git a/src/main/groovy/lang/groovydoc/Groovydoc.java b/src/main/groovy/lang/groovydoc/Groovydoc.java new file mode 100644 index 000..7b281ff --- /dev/null +++ b/src/main/groovy/lang/groovydoc/Groovydoc.java @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.lang.groovydoc; + +import java.lang.reflect.AnnotatedElement; +import java.util.List; +import java.util.Objects; + +/** + * Represents groovydoc + */ +public class Groovydoc { +private final String content; +private List tagList; +private final GroovydocHolder groovydocHolder; + +public Groovydoc(String content, GroovydocHolder groovydocHolder) { +this.content = content; +this.groovydocHolder = groovydocHolder; +} + +public Groovydoc(final String content, final AnnotatedElement annotatedElement) { +this.content = content; +this.groovydocHolder = new GroovydocHolder() { +@Override +public Groovydoc getGroovydoc() { +return Groovydoc.this; +} + +@Override +public Object getInstance() { +return annotatedElement; +} +}; +} + +/** + * Get the content of groovydoc + * @return the text content + */ +public String getContent() { +return content; +} + +/** + * TODO Get list of groovydoc tags + * @return a list of tags + */ +public List getTagList() { +throw new UnsupportedOperationException("[TODO]parsing tags will be a new features of the next releases"); +//return tagList; +} + +/** + * Get the holder of the groovydoc + * @return the groovydoc holder + */ +public GroovydocHolder getGroovydocHolder() { +return groovydocHolder; +} + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +Groovydoc groovydoc = (Groovydoc) o; +return Objects.equals(content, groovydoc.content) && +Objects.equals(groovydocHolder, groovydoc.groovydocHolder); +} + +@Override +public int hashCode() { +return Objects.hash(content, groovydocHolder); +} + +@Override +public String toString() { +return this.content; +} +} http://git-wip-us.apache.org/repos/asf/groovy/blob/f7e2c46a/s
[1/2] groovy git commit: Refine `getGroovydoc` DGMs
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X b1d964dba -> f7e2c46a0 Refine `getGroovydoc` DGMs (cherry picked from commit 86eb9dd) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ba37b013 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ba37b013 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ba37b013 Branch: refs/heads/GROOVY_2_6_X Commit: ba37b01388772caf15d948f9c1e914b36952bbab Parents: b1d964d Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 20:42:22 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 22:46:47 2017 +0800 -- .../groovy/runtime/DefaultGroovyMethods.java| 35 ++-- 1 file changed, 2 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/ba37b013/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java -- diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java index 9f99021..b4dae13 100644 --- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java +++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java @@ -117,8 +117,8 @@ import java.io.Reader; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Array; -import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -18884,44 +18884,13 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { return self.remove(o); } - -/** - * Get runtime groovydoc - * @param holder the groovydoc hold - * @return runtime groovydoc - * @since 2.6.0 - */ -public static String getGroovydoc(Class holder) { -return holder.getAnnotation(Groovydoc.class).value(); -} - -/** - * Get runtime groovydoc - * @param holder the groovydoc hold - * @return runtime groovydoc - * @since 2.6.0 - */ -public static String getGroovydoc(Method holder) { -return holder.getAnnotation(Groovydoc.class).value(); -} - -/** - * Get runtime groovydoc - * @param holder the groovydoc hold - * @return runtime groovydoc - * @since 2.6.0 - */ -public static String getGroovydoc(Constructor holder) { -return ((Groovydoc) holder.getAnnotation(Groovydoc.class)).value(); -} - /** * Get runtime groovydoc * @param holder the groovydoc hold * @return runtime groovydoc * @since 2.6.0 */ -public static String getGroovydoc(Field holder) { +public static String getGroovydoc(AnnotatedElement holder) { return holder.getAnnotation(Groovydoc.class).value(); } }
groovy git commit: Refine `getGroovydoc` DGMs
Repository: groovy Updated Branches: refs/heads/master ec49133c5 -> 86eb9dd7d Refine `getGroovydoc` DGMs Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/86eb9dd7 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/86eb9dd7 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/86eb9dd7 Branch: refs/heads/master Commit: 86eb9dd7d64188ab0847697ea57dede3d2190246 Parents: ec49133 Author: sunlan <sun...@apache.org> Authored: Sun Sep 10 20:42:22 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sun Sep 10 20:42:22 2017 +0800 -- .../groovy/runtime/DefaultGroovyMethods.java| 35 ++-- 1 file changed, 2 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/86eb9dd7/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java -- diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java index 9f99021..b4dae13 100644 --- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java +++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java @@ -117,8 +117,8 @@ import java.io.Reader; import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; +import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Array; -import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -18884,44 +18884,13 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport { return self.remove(o); } - -/** - * Get runtime groovydoc - * @param holder the groovydoc hold - * @return runtime groovydoc - * @since 2.6.0 - */ -public static String getGroovydoc(Class holder) { -return holder.getAnnotation(Groovydoc.class).value(); -} - -/** - * Get runtime groovydoc - * @param holder the groovydoc hold - * @return runtime groovydoc - * @since 2.6.0 - */ -public static String getGroovydoc(Method holder) { -return holder.getAnnotation(Groovydoc.class).value(); -} - -/** - * Get runtime groovydoc - * @param holder the groovydoc hold - * @return runtime groovydoc - * @since 2.6.0 - */ -public static String getGroovydoc(Constructor holder) { -return ((Groovydoc) holder.getAnnotation(Groovydoc.class)).value(); -} - /** * Get runtime groovydoc * @param holder the groovydoc hold * @return runtime groovydoc * @since 2.6.0 */ -public static String getGroovydoc(Field holder) { +public static String getGroovydoc(AnnotatedElement holder) { return holder.getAnnotation(Groovydoc.class).value(); } }
[2/3] groovy git commit: Minor refactoring
http://git-wip-us.apache.org/repos/asf/groovy/blob/c7f5931a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 26868ed..8b6639f 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -139,6 +139,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import static org.apache.groovy.parser.antlr4.GroovyLangParser.*; +import static org.apache.groovy.parser.antlr4.util.PositionConfigureUtils.configureAST; import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean; import static org.codehaus.groovy.runtime.DefaultGroovyMethods.last; @@ -164,7 +165,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov this.parser.setErrorHandler(new DescriptiveErrorStrategy(charStream)); this.tryWithResourcesASTTransformation = new TryWithResourcesASTTransformation(this); -this.groovydocManager = new GroovydocManager(this); +this.groovydocManager = GroovydocManager.getInstance(); } private CharStream createCharStream(SourceUnit sourceUnit) { @@ -272,7 +273,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov this.configureScriptClassNode(); if (null != this.numberFormatError) { -throw createParsingFailedException(this.numberFormatError.value.getMessage(), this.numberFormatError.key); +throw createParsingFailedException(this.numberFormatError.getValue().getMessage(), this.numberFormatError.getKey()); } return moduleNode; @@ -287,7 +288,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov packageNode.addAnnotations(this.visitAnnotationsOpt(ctx.annotationsOpt())); -return this.configureAST(packageNode, ctx); +return configureAST(packageNode, ctx); } @Override @@ -304,7 +305,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov if (hasStar) { // e.g. import static java.lang.Math.* String qualifiedName = this.visitQualifiedName(ctx.qualifiedName()); ClassNode type = ClassHelper.make(qualifiedName); -this.configureAST(type, ctx); +configureAST(type, ctx); moduleNode.addStaticStarImport(type.getText(), type, annotationNodeList); @@ -322,7 +323,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov String alias = hasAlias ? ctx.alias.getText() : name; -this.configureAST(classNode, ctx); +configureAST(classNode, ctx); moduleNode.addStaticImport(classNode, name, alias, annotationNodeList); @@ -342,7 +343,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov String alias = hasAlias ? ctx.alias.getText() : name; -this.configureAST(classNode, ctx); +configureAST(classNode, ctx); moduleNode.addImport(alias, classNode, annotationNodeList); @@ -350,7 +351,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } } -return this.configureAST(importNode, ctx); +return configureAST(importNode, ctx); } // statement { @@ -367,29 +368,29 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } BooleanExpression booleanExpression = -this.configureAST( +configureAST( new BooleanExpression(conditionExpression), conditionExpression); if (!asBoolean(ctx.me)) { -return this.configureAST( +return configureAST( new AssertStatement(booleanExpression), ctx); } -return this.configureAST(new AssertStatement(booleanExpression, +return configureAST(new AssertStatement(booleanExpression, (Expression) this.visit(ctx.me)), ctx); } @Override public AssertStatement visitAssertStmtAlt(AssertStmtAltContext ctx) { -return this.configureAST(this.visitAssertStatement(ctx.assertStatement()), ctx); +return configureAST(this.visitAssertStatement(ctx.assertStatement()), ctx); } @Override public IfStatement
[3/3] groovy git commit: Minor refactoring
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c7f5931a Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c7f5931a Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c7f5931a Branch: refs/heads/master Commit: c7f5931a0cc5f62b96c0f59fdbf03695de764c8d Parents: a23c809 Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 13:44:41 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 13:44:41 2017 +0800 -- .../apache/groovy/parser/antlr4/AstBuilder.java | 647 --- .../groovy/parser/antlr4/GroovydocManager.java | 9 +- .../org/apache/groovy/parser/antlr4/Pair.java | 68 ++ .../antlr4/util/PositionConfigureUtils.java | 127 4 files changed, 457 insertions(+), 394 deletions(-) --
[1/3] groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master a23c80911 -> c7f5931a0 http://git-wip-us.apache.org/repos/asf/groovy/blob/c7f5931a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java index 2fdef75..a9e5e90 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java @@ -52,7 +52,8 @@ public class GroovydocManager { private static final boolean ATTACHING_RUNTIME_GROOVYDOC_ENABLED; private static final String VALUE = "value"; private static final String RUNTIME_GROOVYDOC_PATTERN = "(?s)/[*][*]\\s+(\\s+[*]\\s*)*@Groovydoc\\b.+?[*]/"; -private AstBuilder astBuilder; + +private static final GroovydocManager INSTANCE = new GroovydocManager(); static { ATTACHING_GROOVYDOC_ENABLED = isFeatureEnabled(ATTACH_GROOVYDOC) || isFeatureEnabled(EXTRACT_DOC_COMMENT); @@ -71,8 +72,10 @@ public class GroovydocManager { return result; } -public GroovydocManager(AstBuilder astBuilder) { -this.astBuilder = astBuilder; +private GroovydocManager() {} + +public static GroovydocManager getInstance() { +return INSTANCE; } /** http://git-wip-us.apache.org/repos/asf/groovy/blob/c7f5931a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java new file mode 100644 index 000..14500be --- /dev/null +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.groovy.parser.antlr4; + +import java.util.Objects; + +/** + * key and value pair + * + * @param key type + * @param value type + */ +public class Pair{ +private K key; +private V value; + +public Pair(K key, V value) { +this.key = key; +this.value = value; +} + +public K getKey() { +return key; +} + +public void setKey(K key) { +this.key = key; +} + +public V getValue() { +return value; +} + +public void setValue(V value) { +this.value = value; +} + + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +Pair pair = (Pair) o; +return Objects.equals(key, pair.key) && +Objects.equals(value, pair.value); +} + +@Override +public int hashCode() { +return Objects.hash(key, value); +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/c7f5931a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java new file mode 100644 index 000..bbe83eb --- /dev/null +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this
[1/3] groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 21971d236 -> 4959cd215 http://git-wip-us.apache.org/repos/asf/groovy/blob/4959cd21/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java index 2fdef75..a9e5e90 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java @@ -52,7 +52,8 @@ public class GroovydocManager { private static final boolean ATTACHING_RUNTIME_GROOVYDOC_ENABLED; private static final String VALUE = "value"; private static final String RUNTIME_GROOVYDOC_PATTERN = "(?s)/[*][*]\\s+(\\s+[*]\\s*)*@Groovydoc\\b.+?[*]/"; -private AstBuilder astBuilder; + +private static final GroovydocManager INSTANCE = new GroovydocManager(); static { ATTACHING_GROOVYDOC_ENABLED = isFeatureEnabled(ATTACH_GROOVYDOC) || isFeatureEnabled(EXTRACT_DOC_COMMENT); @@ -71,8 +72,10 @@ public class GroovydocManager { return result; } -public GroovydocManager(AstBuilder astBuilder) { -this.astBuilder = astBuilder; +private GroovydocManager() {} + +public static GroovydocManager getInstance() { +return INSTANCE; } /** http://git-wip-us.apache.org/repos/asf/groovy/blob/4959cd21/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java new file mode 100644 index 000..14500be --- /dev/null +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/Pair.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.groovy.parser.antlr4; + +import java.util.Objects; + +/** + * key and value pair + * + * @param key type + * @param value type + */ +public class Pair{ +private K key; +private V value; + +public Pair(K key, V value) { +this.key = key; +this.value = value; +} + +public K getKey() { +return key; +} + +public void setKey(K key) { +this.key = key; +} + +public V getValue() { +return value; +} + +public void setValue(V value) { +this.value = value; +} + + +@Override +public boolean equals(Object o) { +if (this == o) return true; +if (o == null || getClass() != o.getClass()) return false; +Pair pair = (Pair) o; +return Objects.equals(key, pair.key) && +Objects.equals(value, pair.value); +} + +@Override +public int hashCode() { +return Objects.hash(key, value); +} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/4959cd21/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java new file mode 100644 index 000..bbe83eb --- /dev/null +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/PositionConfigureUtils.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use
[2/3] groovy git commit: Minor refactoring
http://git-wip-us.apache.org/repos/asf/groovy/blob/4959cd21/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 76671f6..7f0e73c 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -137,6 +137,7 @@ import java.util.Set; import java.util.logging.Logger; import static org.apache.groovy.parser.antlr4.GroovyLangParser.*; +import static org.apache.groovy.parser.antlr4.util.PositionConfigureUtils.configureAST; import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean; import static org.codehaus.groovy.runtime.DefaultGroovyMethods.last; @@ -162,7 +163,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov this.parser.setErrorHandler(new DescriptiveErrorStrategy(charStream)); this.tryWithResourcesASTTransformation = new TryWithResourcesASTTransformation(this); -this.groovydocManager = new GroovydocManager(this); +this.groovydocManager = GroovydocManager.getInstance(); } private CharStream createCharStream(SourceUnit sourceUnit) { @@ -270,7 +271,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov this.configureScriptClassNode(); if (null != this.numberFormatError) { -throw createParsingFailedException(this.numberFormatError.value.getMessage(), this.numberFormatError.key); +throw createParsingFailedException(this.numberFormatError.getValue().getMessage(), this.numberFormatError.getKey()); } return moduleNode; @@ -285,7 +286,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov packageNode.addAnnotations(this.visitAnnotationsOpt(ctx.annotationsOpt())); -return this.configureAST(packageNode, ctx); +return configureAST(packageNode, ctx); } @Override @@ -302,7 +303,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov if (hasStar) { // e.g. import static java.lang.Math.* String qualifiedName = this.visitQualifiedName(ctx.qualifiedName()); ClassNode type = ClassHelper.make(qualifiedName); -this.configureAST(type, ctx); +configureAST(type, ctx); moduleNode.addStaticStarImport(type.getText(), type, annotationNodeList); @@ -327,7 +328,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov String alias = hasAlias ? ctx.alias.getText() : name; -this.configureAST(classNode, ctx); +configureAST(classNode, ctx); moduleNode.addStaticImport(classNode, name, alias, annotationNodeList); @@ -347,7 +348,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov String alias = hasAlias ? ctx.alias.getText() : name; -this.configureAST(classNode, ctx); +configureAST(classNode, ctx); moduleNode.addImport(alias, classNode, annotationNodeList); @@ -355,7 +356,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } } -return this.configureAST(importNode, ctx); +return configureAST(importNode, ctx); } // statement { @@ -372,29 +373,29 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov } BooleanExpression booleanExpression = -this.configureAST( +configureAST( new BooleanExpression(conditionExpression), conditionExpression); if (!asBoolean(ctx.me)) { -return this.configureAST( +return configureAST( new AssertStatement(booleanExpression), ctx); } -return this.configureAST(new AssertStatement(booleanExpression, +return configureAST(new AssertStatement(booleanExpression, (Expression) this.visit(ctx.me)), ctx); } @Override public AssertStatement visitAssertStmtAlt(AssertStmtAltContext ctx) { -return this.configureAST(this.visitAssertStatement(ctx.assertStatement()), ctx); +return configureAST(this.visitAssertStatement(ctx.assertStatement()), ctx); } @Override public IfStatement visitIfElseStmtAlt(IfElseStmtAltContext
[3/3] groovy git commit: Minor refactoring
Minor refactoring (cherry picked from commit c7f5931) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4959cd21 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4959cd21 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4959cd21 Branch: refs/heads/GROOVY_2_6_X Commit: 4959cd2158a27953ad06da3889fb368636040d27 Parents: 21971d2 Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 13:44:41 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 14:03:33 2017 +0800 -- build.gradle| 10 +- .../apache/groovy/parser/antlr4/AstBuilder.java | 660 --- .../groovy/parser/antlr4/GroovydocManager.java | 9 +- .../org/apache/groovy/parser/antlr4/Pair.java | 68 ++ .../antlr4/util/PositionConfigureUtils.java | 127 5 files changed, 473 insertions(+), 401 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/4959cd21/build.gradle -- diff --git a/build.gradle b/build.gradle index 7e53ec8..d43beaa 100644 --- a/build.gradle +++ b/build.gradle @@ -88,7 +88,7 @@ allprojects { group = 'org.codehaus.groovy' version = groovyVersion repositories { -if (!InetAddress.getByName('twitter.com').isReachable(3000)) { +if (isBuildInChina()) { // Try to use Aliyun maven repository when building in China maven { url 'http://maven.aliyun.com/nexus/content/groups/public' } } @@ -523,6 +523,14 @@ licenseReport { ] } +def isBuildInChina() { +try { +return !InetAddress.getByName('www.twitter.com').isReachable(3000) +} catch(e) { +return true +} +} + // UNCOMMENT THE FOLLOWING TASKS IF YOU WANT TO RUN LICENSE CHECKING //task licenseFormatCustom(type:nl.javadude.gradle.plugins.license.License) { //source = fileTree(dir:"src").include ("**/*.java",'**/*.groovy','**/*.html','**/*.css','**/*.xml','**/*.properties','**/*.properties')
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 7dd30235d -> 21971d236 Minor refactoring (cherry picked from commit a23c809) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/21971d23 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/21971d23 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/21971d23 Branch: refs/heads/GROOVY_2_6_X Commit: 21971d236e086be7093a26d301d24757807dfdb8 Parents: 7dd3023 Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 12:43:27 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 12:44:35 2017 +0800 -- .../org/apache/groovy/parser/antlr4/AstBuilder.java | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/21971d23/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 1ba83fc..76671f6 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -4290,9 +4290,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov astNode.setLineNumber(start.getLine()); astNode.setColumnNumber(start.getCharPositionInLine() + 1); -Pair<Integer, Integer> stopTokenEndPosition = endPosition(stop); -astNode.setLastLineNumber(stopTokenEndPosition.getKey()); -astNode.setLastColumnNumber(stopTokenEndPosition.getValue()); +configureEndPosition(astNode, stop); return astNode; } @@ -4345,14 +4343,18 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov astNode.setLastLineNumber(stop.getLastLineNumber()); astNode.setLastColumnNumber(stop.getLastColumnNumber()); } else { -Pair<Integer, Integer> endPosition = endPosition(start); -astNode.setLastLineNumber(endPosition.getKey()); -astNode.setLastColumnNumber(endPosition.getValue()); +configureEndPosition(astNode, start); } return astNode; } +private void configureEndPosition(T astNode, Token token) { +Pair<Integer, Integer> endPosition = endPosition(token); +astNode.setLastLineNumber(endPosition.getKey()); +astNode.setLastColumnNumber(endPosition.getValue()); +} + private T configureAST(T astNode, ASTNode start, ASTNode stop) { astNode.setLineNumber(start.getLineNumber()); astNode.setColumnNumber(start.getColumnNumber());
groovy git commit: Minor refactoring
Repository: groovy Updated Branches: refs/heads/master 7a2cdd26b -> a23c80911 Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/a23c8091 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/a23c8091 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/a23c8091 Branch: refs/heads/master Commit: a23c80911ff8db061048261a65796d28185c35f4 Parents: 7a2cdd2 Author: sunlan <sun...@apache.org> Authored: Sat Sep 9 12:43:27 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Sat Sep 9 12:43:27 2017 +0800 -- .../org/apache/groovy/parser/antlr4/AstBuilder.java | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/a23c8091/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java -- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index 521d7aa..26868ed 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -4213,9 +4213,7 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov astNode.setLineNumber(start.getLine()); astNode.setColumnNumber(start.getCharPositionInLine() + 1); -Pair<Integer, Integer> stopTokenEndPosition = endPosition(stop); -astNode.setLastLineNumber(stopTokenEndPosition.getKey()); -astNode.setLastColumnNumber(stopTokenEndPosition.getValue()); +configureEndPosition(astNode, stop); return astNode; } @@ -4268,14 +4266,18 @@ public class AstBuilder extends GroovyParserBaseVisitor implements Groov astNode.setLastLineNumber(stop.getLastLineNumber()); astNode.setLastColumnNumber(stop.getLastColumnNumber()); } else { -Pair<Integer, Integer> endPosition = endPosition(start); -astNode.setLastLineNumber(endPosition.getKey()); -astNode.setLastColumnNumber(endPosition.getValue()); +configureEndPosition(astNode, start); } return astNode; } +private void configureEndPosition(T astNode, Token token) { +Pair<Integer, Integer> endPosition = endPosition(token); +astNode.setLastLineNumber(endPosition.getKey()); +astNode.setLastColumnNumber(endPosition.getValue()); +} + private T configureAST(T astNode, ASTNode start, ASTNode stop) { astNode.setLineNumber(start.getLineNumber()); astNode.setColumnNumber(start.getColumnNumber());
groovy git commit: Add one more test for method reference
Repository: groovy Updated Branches: refs/heads/master e49028082 -> 8a1b3789a Add one more test for method reference Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8a1b3789 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8a1b3789 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8a1b3789 Branch: refs/heads/master Commit: 8a1b3789a025b7b0083d7de76bc72fd109aba292 Parents: e490280 Author: sunlan <sun...@apache.org> Authored: Fri Sep 8 12:36:40 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 8 12:36:40 2017 +0800 -- .../src/test/resources/core/MethodReference_01x.groovy | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/8a1b3789/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy -- diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy index a31b5b8..4816adf 100644 --- a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy +++ b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy @@ -41,6 +41,8 @@ assert ['J', 'P', 'D'] == [new Person('Jochen'), new Person('Paul'), new Person( // class::instanceMethod assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getName).collect(Collectors.toList()) +// class::instanceMethod +assert 6 == java.util.stream.Stream.of(1, 2, 3).reduce(0, BigDecimal::add) // -- class BasePerson {
groovy git commit: Add one more test for method reference
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X d12cf899c -> 4771c4d98 Add one more test for method reference (cherry picked from commit 8a1b378) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/4771c4d9 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/4771c4d9 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/4771c4d9 Branch: refs/heads/GROOVY_2_6_X Commit: 4771c4d988faad1ffbd9676c89dbefa1913a3fe9 Parents: d12cf89 Author: sunlan <sun...@apache.org> Authored: Fri Sep 8 12:36:40 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Fri Sep 8 12:37:53 2017 +0800 -- .../src/test/resources/core/MethodReference_01x.groovy | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/4771c4d9/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy -- diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy index a31b5b8..4816adf 100644 --- a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy +++ b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy @@ -41,6 +41,8 @@ assert ['J', 'P', 'D'] == [new Person('Jochen'), new Person('Paul'), new Person( // class::instanceMethod assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getName).collect(Collectors.toList()) +// class::instanceMethod +assert 6 == java.util.stream.Stream.of(1, 2, 3).reduce(0, BigDecimal::add) // -- class BasePerson {
groovy git commit: Minor refactoring: Generify GroovydocHolder
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X f7e2c46a0 -> 00768041b Minor refactoring: Generify GroovydocHolder (cherry picked from commit e0b787d) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/00768041 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/00768041 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/00768041 Branch: refs/heads/GROOVY_2_6_X Commit: 00768041b3fe08603a80deb39738c17b2da9deb4 Parents: f7e2c46 Author: sunlan <sun...@apache.org> Authored: Mon Sep 11 07:53:49 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Sep 11 07:54:49 2017 +0800 -- src/main/groovy/lang/groovydoc/Groovydoc.java | 16 src/main/groovy/lang/groovydoc/GroovydocHolder.java | 8 ++-- src/main/org/codehaus/groovy/ast/ClassNode.java | 6 +++--- src/main/org/codehaus/groovy/ast/FieldNode.java | 6 +++--- src/main/org/codehaus/groovy/ast/MethodNode.java| 4 ++-- 5 files changed, 22 insertions(+), 18 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/00768041/src/main/groovy/lang/groovydoc/Groovydoc.java -- diff --git a/src/main/groovy/lang/groovydoc/Groovydoc.java b/src/main/groovy/lang/groovydoc/Groovydoc.java index 7b281ff..d7d4204 100644 --- a/src/main/groovy/lang/groovydoc/Groovydoc.java +++ b/src/main/groovy/lang/groovydoc/Groovydoc.java @@ -28,23 +28,23 @@ import java.util.Objects; public class Groovydoc { private final String content; private List tagList; -private final GroovydocHolder groovydocHolder; +private final GroovydocHolder holder; public Groovydoc(String content, GroovydocHolder groovydocHolder) { this.content = content; -this.groovydocHolder = groovydocHolder; +this.holder = groovydocHolder; } public Groovydoc(final String content, final AnnotatedElement annotatedElement) { this.content = content; -this.groovydocHolder = new GroovydocHolder() { +this.holder = new GroovydocHolder() { @Override public Groovydoc getGroovydoc() { return Groovydoc.this; } @Override -public Object getInstance() { +public AnnotatedElement getInstance() { return annotatedElement; } }; @@ -71,8 +71,8 @@ public class Groovydoc { * Get the holder of the groovydoc * @return the groovydoc holder */ -public GroovydocHolder getGroovydocHolder() { -return groovydocHolder; +public GroovydocHolder getHolder() { +return holder; } @Override @@ -81,12 +81,12 @@ public class Groovydoc { if (o == null || getClass() != o.getClass()) return false; Groovydoc groovydoc = (Groovydoc) o; return Objects.equals(content, groovydoc.content) && -Objects.equals(groovydocHolder, groovydoc.groovydocHolder); +Objects.equals(holder, groovydoc.holder); } @Override public int hashCode() { -return Objects.hash(content, groovydocHolder); +return Objects.hash(content, holder); } @Override http://git-wip-us.apache.org/repos/asf/groovy/blob/00768041/src/main/groovy/lang/groovydoc/GroovydocHolder.java -- diff --git a/src/main/groovy/lang/groovydoc/GroovydocHolder.java b/src/main/groovy/lang/groovydoc/GroovydocHolder.java index 8db3135..eb41df4 100644 --- a/src/main/groovy/lang/groovydoc/GroovydocHolder.java +++ b/src/main/groovy/lang/groovydoc/GroovydocHolder.java @@ -21,7 +21,7 @@ package groovy.lang.groovydoc; /** * Represents Groovydoc Holder */ -public interface GroovydocHolder { +public interface GroovydocHolder { String DOC_COMMENT = "_DOC_COMMENT"; // keys for meta data /** * Get the groovydoc @@ -29,5 +29,9 @@ public interface GroovydocHolder { */ Groovydoc getGroovydoc(); -Object getInstance(); +/** + * Get GroovydocHolder instance + * @return GroovydocHolder instance + */ +T getInstance(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/00768041/src/main/org/codehaus/groovy/ast/ClassNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java index fcf7cd6..f7ad48d 100644 --- a/src/main/org/codehaus/groovy/ast/ClassNode.java +++ b/src/main/org/codehaus/groovy/ast/ClassNode.java @@ -18,13 +18,13 @@ */ package org.codehaus.groovy.ast; +import groovy.lang.groovydoc.Groovydoc; import groovy.lang.g
groovy git commit: Minor refactoring: Generify GroovydocHolder
Repository: groovy Updated Branches: refs/heads/master 43067475c -> e0b787dcf Minor refactoring: Generify GroovydocHolder Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e0b787dc Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e0b787dc Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e0b787dc Branch: refs/heads/master Commit: e0b787dcfc50c1084aac7112ba9d8a2cc6aa0cfa Parents: 4306747 Author: sunlan <sun...@apache.org> Authored: Mon Sep 11 07:53:49 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Sep 11 07:53:49 2017 +0800 -- src/main/groovy/lang/groovydoc/Groovydoc.java | 16 src/main/groovy/lang/groovydoc/GroovydocHolder.java | 8 ++-- src/main/org/codehaus/groovy/ast/ClassNode.java | 6 +++--- src/main/org/codehaus/groovy/ast/FieldNode.java | 6 +++--- src/main/org/codehaus/groovy/ast/MethodNode.java| 4 ++-- 5 files changed, 22 insertions(+), 18 deletions(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/groovy/lang/groovydoc/Groovydoc.java -- diff --git a/src/main/groovy/lang/groovydoc/Groovydoc.java b/src/main/groovy/lang/groovydoc/Groovydoc.java index 7b281ff..d7d4204 100644 --- a/src/main/groovy/lang/groovydoc/Groovydoc.java +++ b/src/main/groovy/lang/groovydoc/Groovydoc.java @@ -28,23 +28,23 @@ import java.util.Objects; public class Groovydoc { private final String content; private List tagList; -private final GroovydocHolder groovydocHolder; +private final GroovydocHolder holder; public Groovydoc(String content, GroovydocHolder groovydocHolder) { this.content = content; -this.groovydocHolder = groovydocHolder; +this.holder = groovydocHolder; } public Groovydoc(final String content, final AnnotatedElement annotatedElement) { this.content = content; -this.groovydocHolder = new GroovydocHolder() { +this.holder = new GroovydocHolder() { @Override public Groovydoc getGroovydoc() { return Groovydoc.this; } @Override -public Object getInstance() { +public AnnotatedElement getInstance() { return annotatedElement; } }; @@ -71,8 +71,8 @@ public class Groovydoc { * Get the holder of the groovydoc * @return the groovydoc holder */ -public GroovydocHolder getGroovydocHolder() { -return groovydocHolder; +public GroovydocHolder getHolder() { +return holder; } @Override @@ -81,12 +81,12 @@ public class Groovydoc { if (o == null || getClass() != o.getClass()) return false; Groovydoc groovydoc = (Groovydoc) o; return Objects.equals(content, groovydoc.content) && -Objects.equals(groovydocHolder, groovydoc.groovydocHolder); +Objects.equals(holder, groovydoc.holder); } @Override public int hashCode() { -return Objects.hash(content, groovydocHolder); +return Objects.hash(content, holder); } @Override http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/groovy/lang/groovydoc/GroovydocHolder.java -- diff --git a/src/main/groovy/lang/groovydoc/GroovydocHolder.java b/src/main/groovy/lang/groovydoc/GroovydocHolder.java index 8db3135..eb41df4 100644 --- a/src/main/groovy/lang/groovydoc/GroovydocHolder.java +++ b/src/main/groovy/lang/groovydoc/GroovydocHolder.java @@ -21,7 +21,7 @@ package groovy.lang.groovydoc; /** * Represents Groovydoc Holder */ -public interface GroovydocHolder { +public interface GroovydocHolder { String DOC_COMMENT = "_DOC_COMMENT"; // keys for meta data /** * Get the groovydoc @@ -29,5 +29,9 @@ public interface GroovydocHolder { */ Groovydoc getGroovydoc(); -Object getInstance(); +/** + * Get GroovydocHolder instance + * @return GroovydocHolder instance + */ +T getInstance(); } http://git-wip-us.apache.org/repos/asf/groovy/blob/e0b787dc/src/main/org/codehaus/groovy/ast/ClassNode.java -- diff --git a/src/main/org/codehaus/groovy/ast/ClassNode.java b/src/main/org/codehaus/groovy/ast/ClassNode.java index fcf7cd6..f7ad48d 100644 --- a/src/main/org/codehaus/groovy/ast/ClassNode.java +++ b/src/main/org/codehaus/groovy/ast/ClassNode.java @@ -18,13 +18,13 @@ */ package org.codehaus.groovy.ast; +import groovy.lang.groovydoc.Groovydoc; import groovy.lang.groovydoc.GroovydocHolder; import org.codeha
groovy git commit: temporarily disable an environmentally sensitive test further
Repository: groovy Updated Branches: refs/heads/master 154b331a8 -> 378e94d23 temporarily disable an environmentally sensitive test further Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/378e94d2 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/378e94d2 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/378e94d2 Branch: refs/heads/master Commit: 378e94d23e4182689cd1b2cc6adbc2581ba03051 Parents: 154b331 Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 22:24:01 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 22:24:01 2017 +0800 -- .../groovy/tools/shell/completion/FileNameCompleterTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/378e94d2/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy -- diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy index 9bf8263..e178a83 100644 --- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy +++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy @@ -37,7 +37,7 @@ class FileNameCompleterTest extends GroovyTestCase { assert completer.render('foo \'\"bar') == 'foo\\ \\\'\\\"bar' + '' } -@Test +//@Test void _FIXME_testCompletionNoFiles() { // abusing junit testrule TemporaryFolder testFolder = null;
groovy git commit: temporarily disable an environmentally sensitive test further
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 98494d817 -> 57e54 temporarily disable an environmentally sensitive test further (cherry picked from commit 378e94d) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/57e5 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/57e5 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/57e5 Branch: refs/heads/GROOVY_2_6_X Commit: 57e5424e0f6dcf49e3cb8174be77785a75db Parents: 98494d8 Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 22:24:01 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 22:25:51 2017 +0800 -- .../groovy/tools/shell/completion/FileNameCompleterTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/57e5/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy -- diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy index 9bf8263..e178a83 100644 --- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy +++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy @@ -37,7 +37,7 @@ class FileNameCompleterTest extends GroovyTestCase { assert completer.render('foo \'\"bar') == 'foo\\ \\\'\\\"bar' + '' } -@Test +//@Test void _FIXME_testCompletionNoFiles() { // abusing junit testrule TemporaryFolder testFolder = null;
groovy git commit: Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m"
Repository: groovy Updated Branches: refs/heads/master 5306a0d2e -> 1186414b0 Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m" Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1186414b Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1186414b Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1186414b Branch: refs/heads/master Commit: 1186414b09c9781fe6618e76efad2ea8017fc1d4 Parents: 5306a0d Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 21:06:56 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 21:08:15 2017 +0800 -- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/1186414b/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 9bf1700..ad71dcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,8 @@ matrix: install: true +before_script: unset _JAVA_OPTIONS + script: travis_wait 60 ./gradlew test before_cache: @@ -35,3 +37,4 @@ cache: directories: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ +
groovy git commit: Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m"
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X c110326d1 -> e705cffca Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m" (cherry picked from commit 1186414) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e705cffc Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e705cffc Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e705cffc Branch: refs/heads/GROOVY_2_6_X Commit: e705cffca204a074a8d17dc2e7eacdc4c7762977 Parents: c110326 Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 21:06:56 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 21:38:56 2017 +0800 -- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/e705cffc/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index e4f512c..323386c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,8 @@ matrix: install: true +before_script: unset _JAVA_OPTIONS + script: travis_wait 60 ./gradlew -PuseAntlr4=true test before_cache:
groovy git commit: Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m"
Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X ac48eb390 -> 0f68c2aa3 Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m" (cherry picked from commit 1186414) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/0f68c2aa Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0f68c2aa Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0f68c2aa Branch: refs/heads/GROOVY_2_4_X Commit: 0f68c2aa3a908271a5d393b823b85f59134092ef Parents: ac48eb3 Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 21:06:56 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 21:42:59 2017 +0800 -- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/0f68c2aa/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 6e223d7..e38bbb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ jdk: install: true +before_script: unset _JAVA_OPTIONS + script: travis_wait 60 ./gradlew test before_cache: @@ -30,3 +32,4 @@ cache: directories: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ +
groovy git commit: Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m"
Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X 195a95670 -> cbf9f73ad Fix travis-ci issue "java.lang.RuntimeException: Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m" (cherry picked from commit 1186414) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/cbf9f73a Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/cbf9f73a Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/cbf9f73a Branch: refs/heads/GROOVY_2_5_X Commit: cbf9f73addfc3ed0e5fea5372eafdf91ada5ba09 Parents: 195a956 Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 21:06:56 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 21:41:40 2017 +0800 -- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/cbf9f73a/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index df5ff70..41c71d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,9 @@ matrix: install: true -script: travis_wait 40 ./gradlew test +before_script: unset _JAVA_OPTIONS + +script: travis_wait 60 ./gradlew test before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
[1/2] groovy git commit: temporarily disable an environmentally sensitive test
Repository: groovy Updated Branches: refs/heads/GROOVY_2_5_X cbf9f73ad -> 894de84ef temporarily disable an environmentally sensitive test (cherry picked from commit 154b331) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/44a5d056 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/44a5d056 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/44a5d056 Branch: refs/heads/GROOVY_2_5_X Commit: 44a5d056e8f986792c8a06918ac48133834c57c1 Parents: cbf9f73 Author: paulk <pa...@asert.com.au> Authored: Tue Sep 12 21:33:26 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 22:26:36 2017 +0800 -- .../groovy/tools/shell/completion/FileNameCompleterTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/44a5d056/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy -- diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy index 867371e..9bf8263 100644 --- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy +++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy @@ -38,7 +38,7 @@ class FileNameCompleterTest extends GroovyTestCase { } @Test -void testCompletionNoFiles() { +void _FIXME_testCompletionNoFiles() { // abusing junit testrule TemporaryFolder testFolder = null; try {
[2/2] groovy git commit: temporarily disable an environmentally sensitive test further
temporarily disable an environmentally sensitive test further (cherry picked from commit 378e94d) Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/894de84e Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/894de84e Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/894de84e Branch: refs/heads/GROOVY_2_5_X Commit: 894de84ef1cc9bdf743ab98748ae7b58cc6a6fd7 Parents: 44a5d05 Author: sunlan <sun...@apache.org> Authored: Tue Sep 12 22:24:01 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Tue Sep 12 22:26:42 2017 +0800 -- .../groovy/tools/shell/completion/FileNameCompleterTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/894de84e/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy -- diff --git a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy index 9bf8263..e178a83 100644 --- a/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy +++ b/subprojects/groovy-groovysh/src/test/groovy/org/codehaus/groovy/tools/shell/completion/FileNameCompleterTest.groovy @@ -37,7 +37,7 @@ class FileNameCompleterTest extends GroovyTestCase { assert completer.render('foo \'\"bar') == 'foo\\ \\\'\\\"bar' + '' } -@Test +//@Test void _FIXME_testCompletionNoFiles() { // abusing junit testrule TemporaryFolder testFolder = null;
groovy git commit: Disable the gradle daemon
Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 120f252a8 -> ccdd5008d Disable the gradle daemon Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ccdd5008 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ccdd5008 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ccdd5008 Branch: refs/heads/GROOVY_2_6_X Commit: ccdd5008d4158541a9fcf5dc48a424861ab14ffa Parents: 120f252 Author: sunlan <sun...@apache.org> Authored: Mon Sep 25 22:24:41 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Sep 25 22:24:41 2017 +0800 -- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- http://git-wip-us.apache.org/repos/asf/groovy/blob/ccdd5008/.travis.yml -- diff --git a/.travis.yml b/.travis.yml index 323386c..e1d9081 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ install: true before_script: unset _JAVA_OPTIONS -script: travis_wait 60 ./gradlew -PuseAntlr4=true test +script: travis_wait 60 ./gradlew --no-daemon -PuseAntlr4=true test before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock