You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/03/28 12:53:36 UTC
[groovy] branch GROOVY_3_0_X updated (ce4faff -> 8f614a8)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a change to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git.
from ce4faff Now groovy refactoring is possible via VsCode (closes #1209)
new 318fbe6 Fix 'Save changes?' dialog quitting on cancel with Java 11 on OSX
new a778e87 fix javadoc warnings
new 67b6c87 GROOVY-9485: metaclass is not initialized
new b08230d GROOVY-9310: Groovy does not ignore second bash directive(closes #1203)
new 7ec653b Update package.html
new 8f614a8 GROOVY-9486: Remove redundant code `Sentinel` (#1212)
The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
gradle/docs.gradle | 3 +++
src/antlr/GroovyLexer.g4 | 7 +++++-
src/main/java/groovy/inspect/package.html | 3 ++-
.../groovy/transform/stc/ClosureSignatureHint.java | 4 ++--
.../codehaus/groovy/reflection/CachedClass.java | 4 +++-
.../org/codehaus/groovy/reflection/ClassInfo.java | 14 ------------
.../groovy/runtime/DefaultGroovyMethods.java | 26 +++++++++++-----------
.../main/groovy/groovy/console/ui/Console.groovy | 13 +++++++----
.../groovy/parser/antlr4/GroovyParserTest.groovy | 4 ++++
.../src/test/resources/core/Comments_03x.groovy} | 5 +++--
10 files changed, 45 insertions(+), 38 deletions(-)
copy subprojects/{groovy-test/src/test/groovy/groovy/test/suite/ATestScriptThatsNoTestCase.groovy => parser-antlr4/src/test/resources/core/Comments_03x.groovy} (90%)
[groovy] 05/06: Update package.html
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 7ec653b24ca5df26bf934c8159b356e53eaa7e61
Author: Rubén <ru...@protonmail.com>
AuthorDate: Wed Mar 25 14:10:04 2020 +0100
Update package.html
Fix for https://sonarcloud.io/project/issues?id=apache_groovy&open=AXD-_jqMDC9Fk2pZiWTt&resolved=false&types=BUG
(cherry picked from commit 45b64598cb191fd12b5eafcbf5bc1f636250bf48)
---
src/main/java/groovy/inspect/package.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/main/java/groovy/inspect/package.html b/src/main/java/groovy/inspect/package.html
index 6d80c2b..d1b0332 100644
--- a/src/main/java/groovy/inspect/package.html
+++ b/src/main/java/groovy/inspect/package.html
@@ -18,7 +18,8 @@
under the License.
-->
-<html>
+<!DOCTYPE html>
+<html lang="en">
<head>
<title>package groovy.inspect.*</title>
</head>
[groovy] 01/06: Fix 'Save changes?' dialog quitting on cancel with
Java 11 on OSX
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 318fbe6440e2e3d7af861c033798eaf5431a3f47
Author: timyates <ti...@gmail.com>
AuthorDate: Fri Mar 27 19:07:39 2020 +0000
Fix 'Save changes?' dialog quitting on cancel with Java 11 on OSX
If the user quits the Groovy console with unsaved changes, it asks if
they want to 'Save changes?'
Under Java 11, this still quits if they click 'Cancel'
Looks like we need to cancel the quit event if cancel was pressed
(cherry picked from commit e9804c4acafff379d738a28c0a7ff05110a13406)
---
.../src/main/groovy/groovy/console/ui/Console.groovy | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
index dc8cf38..24d74be 100644
--- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
+++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy
@@ -780,13 +780,17 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener, Fo
}
void exitDesktop(EventObject evt = null, quitResponse = null) {
- exit(evt)
- quitResponse.performQuit()
+ if (exit(evt)) {
+ quitResponse.performQuit()
+ } else {
+ quitResponse.cancelQuit()
+ }
}
- void exit(EventObject evt = null) {
+ boolean exit(EventObject evt = null) {
if (askToInterruptScript()) {
- if (askToSaveFile()) {
+ def exit = askToSaveFile()
+ if (exit) {
if (frame instanceof Window) {
frame.hide()
frame.dispose()
@@ -799,6 +803,7 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener, Fo
systemErrorInterceptor.stop()
}
}
+ return exit
}
}
[groovy] 02/06: fix javadoc warnings
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit a778e87da82875689bbf32a2bc3cf2f53125f763
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat Mar 28 10:28:37 2020 +1000
fix javadoc warnings
(cherry picked from commit 02c2518a5f07967a190940ffa37bb366f48066b6)
---
gradle/docs.gradle | 3 +++
.../groovy/transform/stc/ClosureSignatureHint.java | 4 ++--
.../groovy/runtime/DefaultGroovyMethods.java | 26 +++++++++++-----------
3 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/gradle/docs.gradle b/gradle/docs.gradle
index d91243a..4b589a8 100644
--- a/gradle/docs.gradle
+++ b/gradle/docs.gradle
@@ -33,6 +33,9 @@ task asciidocAll(type: Copy) {
def javadocSpec = {
maxMemory = javaDoc_mx
project.configure(options) {
+ if (JavaVersion.current().isJava9Compatible()) {
+ options.addBooleanOption('html5', true)
+ }
windowTitle = doc.title
docTitle = doc.title
locale = 'en_US'
diff --git a/src/main/java/groovy/transform/stc/ClosureSignatureHint.java b/src/main/java/groovy/transform/stc/ClosureSignatureHint.java
index 0525a98..ce36a03 100644
--- a/src/main/java/groovy/transform/stc/ClosureSignatureHint.java
+++ b/src/main/java/groovy/transform/stc/ClosureSignatureHint.java
@@ -92,11 +92,11 @@ public abstract class ClosureSignatureHint {
* }</code>
*
* <p>The <i>collect</i> method accepts a closure, but normally, the type checker doesn't have enough type information
- * in the sole {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#collect(java.util.Collection, groovy.lang.Closure)} method
+ * in the sole {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#collect(java.lang.Iterable, groovy.lang.Closure)} method
* signature to infer the type of <i>it</i>. With the annotation, it will now try to find an annotation on the closure parameter.
* If it finds it, then an instance of the hint class is created and the type checker calls it with the following arguments:</p>
* <ul>
- * <li>the method node corresponding to the target method (here, the {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#collect(java.util.Collection, groovy.lang.Closure)} method</li>
+ * <li>the method node corresponding to the target method (here, the {@link org.codehaus.groovy.runtime.DefaultGroovyMethods#collect(java.lang.Iterable, groovy.lang.Closure)} method</li>
* <li>the (optional) list of options found in the annotation</li>
* </ul>
*
diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 4f0690e..3fd10bd 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -3806,7 +3806,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an Iterable
* @param projection a projecting Closure returning a collection of items
* @return a list created from the projected collections concatenated (flattened) together
- * @see #sum(java.util.Collection, groovy.lang.Closure)
+ * @see #sum(java.lang.Iterable, groovy.lang.Closure)
* @since 2.2.0
*/
public static <T,E> List<T> collectMany(Iterable<E> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<? extends Collection<? extends T>> projection) {
@@ -5729,7 +5729,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an array to group and count
* @param closure a closure mapping items to the frequency keys
* @return a new Map grouped by keys with frequency counts
- * @see #countBy(Collection, Closure)
+ * @see #countBy(java.lang.Iterable, Closure)
* @since 1.8.0
*/
public static <K,E> Map<K, Integer> countBy(E[] self, @ClosureParams(FirstParam.Component.class) Closure<K> closure) {
@@ -5749,7 +5749,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an iterator to group and count
* @param closure a closure mapping items to the frequency keys
* @return a new Map grouped by keys with frequency counts
- * @see #countBy(Collection, Closure)
+ * @see #countBy(java.lang.Iterable, Closure)
* @since 1.8.0
*/
public static <K,E> Map<K, Integer> countBy(Iterator<E> self, @ClosureParams(FirstParam.FirstGenericType.class) Closure<K> closure) {
@@ -7210,7 +7210,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
*
* @param self an Iterator
* @return the minimum value
- * @see #min(java.util.Collection)
+ * @see #min(java.lang.Iterable)
* @since 1.5.5
*/
public static <T> T min(Iterator<T> self) {
@@ -7222,7 +7222,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
*
* @param self an array
* @return the minimum value
- * @see #min(java.util.Collection)
+ * @see #min(java.lang.Iterable)
* @since 1.5.5
*/
public static <T> T min(T[] self) {
@@ -7268,7 +7268,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an Iterator
* @param comparator a Comparator
* @return the minimum value
- * @see #min(java.util.Collection, java.util.Comparator)
+ * @see #min(java.lang.Iterable, java.util.Comparator)
* @since 1.5.5
*/
public static <T> T min(Iterator<T> self, Comparator<T> comparator) {
@@ -7281,7 +7281,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an array
* @param comparator a Comparator
* @return the minimum value
- * @see #min(java.util.Collection, java.util.Comparator)
+ * @see #min(java.lang.Iterable, java.util.Comparator)
* @since 1.5.5
*/
public static <T> T min(T[] self, Comparator<T> comparator) {
@@ -7445,7 +7445,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an Iterator
* @param closure a Closure used to determine the correct ordering
* @return the minimum value
- * @see #min(java.util.Collection, groovy.lang.Closure)
+ * @see #min(java.lang.Iterable, groovy.lang.Closure)
* @since 1.5.5
*/
public static <T> T min(Iterator<T> self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {
@@ -7468,7 +7468,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an array
* @param closure a Closure used to determine the correct ordering
* @return the minimum value
- * @see #min(java.util.Collection, groovy.lang.Closure)
+ * @see #min(java.lang.Iterable, groovy.lang.Closure)
* @since 1.5.5
*/
public static <T> T min(T[] self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {
@@ -7518,7 +7518,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
*
* @param self an array
* @return the maximum value
- * @see #max(java.util.Collection)
+ * @see #max(java.lang.Iterable)
* @since 1.5.5
*/
public static <T> T max(T[] self) {
@@ -7601,7 +7601,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an Iterator
* @param closure a Closure used to determine the correct ordering
* @return the maximum value
- * @see #max(java.util.Collection, groovy.lang.Closure)
+ * @see #max(java.lang.Iterable, groovy.lang.Closure)
* @since 1.5.5
*/
public static <T> T max(Iterator<T> self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {
@@ -7624,7 +7624,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* @param self an array
* @param closure a Closure used to determine the correct ordering
* @return the maximum value
- * @see #max(java.util.Collection, groovy.lang.Closure)
+ * @see #max(java.lang.Iterable, groovy.lang.Closure)
* @since 1.5.5
*/
public static <T> T max(T[] self, @ClosureParams(value=FromString.class, options={"T","T,T"}) Closure closure) {
@@ -17277,7 +17277,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
* def first = ChronoUnit.findIndexOf(nameStartsWithM)
* def last = ChronoUnit.findLastIndexOf(nameStartsWithM)
* // should have found 2 unique index values for MICROS, MILLIS, MINUTES, MONTHS, ...
- * assert first != -1 && last != -1 && first != last
+ * assert first != -1 && last != -1 && first != last
* </pre>
*
* @param self the iteration object over which to iterate
[groovy] 04/06: GROOVY-9310: Groovy does not ignore second bash
directive(closes #1203)
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit b08230d4ee893d86dde7a1add3bf938192a99364
Author: John Mercier <mo...@gmail.com>
AuthorDate: Sat Mar 28 17:38:30 2020 +0800
GROOVY-9310: Groovy does not ignore second bash directive(closes #1203)
(cherry picked from commit 52259d567e91cbdab03dad0c5b30f47ff758ebc7)
---
src/antlr/GroovyLexer.g4 | 7 ++++++-
.../groovy/parser/antlr4/GroovyParserTest.groovy | 4 ++++
.../src/test/resources/core/Comments_03x.groovy | 23 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/antlr/GroovyLexer.g4 b/src/antlr/GroovyLexer.g4
index 9348ef4..4c3b76d 100644
--- a/src/antlr/GroovyLexer.g4
+++ b/src/antlr/GroovyLexer.g4
@@ -918,6 +918,11 @@ JavaLetterOrDigitInGString
: JavaLetterOrDigit { _input.LA(-1) != '$' }?
;
+fragment
+ShCommand
+ : ~[\r\n\uFFFF]*
+ ;
+
//
// Additional symbols not defined in the lexical specification
//
@@ -948,7 +953,7 @@ SL_COMMENT
// Script-header comments.
// The very first characters of the file may be "#!". If so, ignore the first line.
SH_COMMENT
- : '#!' { require(0 == this.tokenIndex, "Shebang comment should appear at the first line", -2, true); } ~[\r\n\uFFFF]* -> skip
+ : '#!' { require(0 == this.tokenIndex, "Shebang comment should appear at the first line", -2, true); } ShCommand (LineTerminator '#!' ShCommand)* -> skip
;
// Unexpected characters will be handled by groovy parser later.
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 a32b079..aefac72 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
@@ -44,6 +44,10 @@ final class GroovyParserTest extends GroovyTestCase {
doTestAttachedComments()
}
+ void "test groovy core - Shebang Comments"() {
+ doRunAndTestAntlr4('core/Comments_03x.groovy')
+ }
+
// java.lang.ClassFormatError: Illegal method name "test IO stream/reader closed by the parser properly" when using Java9
void "test IO reader closed by the parser properly"() {
def f = File.createTempFile("Script${System.nanoTime()}", ".groovy")
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Comments_03x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Comments_03x.groovy
new file mode 100644
index 0000000..18d2b03
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Comments_03x.groovy
@@ -0,0 +1,23 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -i groovy -p groovy
+#! other directives
+/*
+ * 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.
+ */
+
+assert true
[groovy] 03/06: GROOVY-9485: metaclass is not initialized
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 67b6c87313c073c921609113cd50073175daf6d0
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Mar 28 16:29:42 2020 +0800
GROOVY-9485: metaclass is not initialized
(cherry picked from commit 6c7b4e193d12fcc793401e0bb9097bca30dd2c65)
---
src/main/java/org/codehaus/groovy/reflection/CachedClass.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/codehaus/groovy/reflection/CachedClass.java b/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
index 0f4314d..c4740d8 100644
--- a/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
+++ b/src/main/java/org/codehaus/groovy/reflection/CachedClass.java
@@ -379,7 +379,9 @@ public class CachedClass {
if (metaClass.getClass() == MetaClassImpl.class) {
classInfo.setStrongMetaClass(null);
updateSetNewMopMethods(arr);
- classInfo.setStrongMetaClass(new MetaClassImpl(metaClass.getTheClass()));
+ MetaClassImpl mci = new MetaClassImpl(metaClass.getTheClass());
+ mci.initialize();
+ classInfo.setStrongMetaClass(mci);
return;
}
[groovy] 06/06: GROOVY-9486: Remove redundant code `Sentinel`
(#1212)
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 8f614a8ad4e4ad43c438f1dcc3b6ffedcb025335
Author: Daniel.Sun <su...@apache.org>
AuthorDate: Sat Mar 28 20:43:55 2020 +0800
GROOVY-9486: Remove redundant code `Sentinel` (#1212)
(cherry picked from commit c41db0937b8d231692729e94ba5831efec48269f)
---
.../java/org/codehaus/groovy/reflection/ClassInfo.java | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java b/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
index 77b2c5f..e55b2ed 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ClassInfo.java
@@ -77,21 +77,7 @@ public class ClassInfo implements Finalizable {
private final LockableObject lock = new LockableObject();
public final int hash = -1;
private final WeakReference<Class<?>> classRef;
-
- // TODO: should be able to remove the klazz field once 2.5 becomes the mainline release
- // Gradle has a cleanup mechanism in place to reflectively access this klazz field.
- // The klazz field is being kept for compatibility so as to not break builds that depend
- // on versions of Groovy after the field was changed to a WeakReference (classRef). It
- // appears that Gradle only performs the cleanup when it detects a groovy version of 2.4.x,
- // so the klazz field and placeholder Sentinel class can likely be safely removed once
- // the release version bumps to 2.5 (or beyond).
- // See:
- // https://github.com/gradle/gradle/blob/711f64/subprojects/core/src/main/java/org/gradle/api/internal/classloading/LeakyOnJava7GroovySystemLoader.java#L74
- private static final class Sentinel {}
- private static final Class<?> klazz = Sentinel.class;
-
private final AtomicInteger version = new AtomicInteger();
-
private MetaClass strongMetaClass;
private ManagedReference<MetaClass> weakMetaClass;
MetaMethod[] dgmMetaMethods = MetaMethod.EMPTY_ARRAY;