You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/09/02 12:00:28 UTC
groovy git commit: use assertions instead of println in a test,
fix javadoc
Repository: groovy
Updated Branches:
refs/heads/master 6ad26afba -> ab9c39dac
use assertions instead of println in a test, fix javadoc
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ab9c39da
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ab9c39da
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ab9c39da
Branch: refs/heads/master
Commit: ab9c39dacd624903ee182f617b9ae3d4d09df710
Parents: 6ad26af
Author: Paul King <pa...@asert.com.au>
Authored: Sun Sep 2 22:00:15 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Sun Sep 2 22:00:15 2018 +1000
----------------------------------------------------------------------
.../groovy/control/CompilerConfiguration.java | 12 ++++----
.../groovy/transform/GlobalTransformTest.groovy | 28 ++++++------------
.../groovy/transform/TestTransform.groovy | 30 +++++++++-----------
3 files changed, 30 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/ab9c39da/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
index 87402aa..865e2d38 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -195,9 +195,9 @@ public class CompilerConfiguration {
private final List<CompilationCustomizer> compilationCustomizers = new LinkedList<CompilationCustomizer>();
/**
- * Sets a list of global AST transformations which should not be loaded even if they are
- * defined in META-INF/org.codehaus.groovy.transform.ASTTransformation files. By default,
- * none is disabled.
+ * Global AST transformations which should not be loaded even if they are
+ * defined in META-INF/services/org.codehaus.groovy.transform.ASTTransformation files.
+ * By default, none are disabled.
*/
private Set<String> disabledGlobalASTTransformations;
@@ -871,13 +871,15 @@ public class CompilerConfiguration {
}
/**
- * Disables global AST transformations. In order to avoid class loading side effects, it is not recommended
+ * Disables the specified global AST transformations. In order to avoid class loading side effects, it is not recommended
* to use MyASTTransformation.class.getName() by directly use the class name as a string. Disabled AST transformations
* only apply to automatically loaded global AST transformations, that is to say transformations defined in a
- * META-INF/org.codehaus.groovy.transform.ASTTransformation file. If you explicitly add a global AST transformation
+ * META-INF/services/org.codehaus.groovy.transform.ASTTransformation file.
+ * If you explicitly add a global AST transformation
* in your compilation process, for example using the {@link org.codehaus.groovy.control.customizers.ASTTransformationCustomizer} or
* using a {@link org.codehaus.groovy.control.CompilationUnit.PrimaryClassNodeOperation}, then nothing will prevent
* the transformation from being loaded.
+ *
* @param disabledGlobalASTTransformations a set of fully qualified class names of global AST transformations
* which should not be loaded.
*/
http://git-wip-us.apache.org/repos/asf/groovy/blob/ab9c39da/src/test/org/codehaus/groovy/transform/GlobalTransformTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/transform/GlobalTransformTest.groovy b/src/test/org/codehaus/groovy/transform/GlobalTransformTest.groovy
index aa2e35e..fd13db3 100644
--- a/src/test/org/codehaus/groovy/transform/GlobalTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/GlobalTransformTest.groovy
@@ -18,28 +18,18 @@
*/
package org.codehaus.groovy.transform
-/**
- * @author Danno.Ferrin
- * @author Alex Tkachman
- */
-class GlobalTransformTest extends GroovyShellTestCase {
-
- URL transformRoot = new File(getClass().classLoader.
- getResource("org/codehaus/groovy/transform/META-INF/services/org.codehaus.groovy.transform.ASTTransformation").
- toURI()).parentFile.parentFile.parentFile.toURL()
+class GlobalLegacyTransformTest extends GroovyTestCase {
+ def path = "org/codehaus/groovy/transform/META-INF/services/org.codehaus.groovy.transform.ASTTransformation"
+ URL transformRoot = new File(getClass().classLoader.getResource(path).toURI()).parentFile.parentFile.parentFile.toURI().toURL()
void testGlobalTransform() {
+ def shell = new GroovyShell()
shell.classLoader.addURL(transformRoot)
shell.evaluate("""
- import org.codehaus.groovy.control.CompilePhase
-
- if (org.codehaus.groovy.transform.TestTransform.phases == [CompilePhase.CONVERSION, CompilePhase.CLASS_GENERATION]) {
- println "Phase sync bug fixed"
- } else if (org.codehaus.groovy.transform.TestTransform.phases == [CompilePhase.CONVERSION, CompilePhase.INSTRUCTION_SELECTION]) {
- println "Phase sync bug still present"
- } else {
- assert false, "FAIL"
- }
+ import static org.codehaus.groovy.control.CompilePhase.*
+ def ph = org.codehaus.groovy.transform.TestTransform.phases
+ assert ph.TestTransformConversion == [CONVERSION]
+ assert ph.TestTransformClassGeneration == [CLASS_GENERATION]
""")
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/groovy/blob/ab9c39da/src/test/org/codehaus/groovy/transform/TestTransform.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/transform/TestTransform.groovy b/src/test/org/codehaus/groovy/transform/TestTransform.groovy
index c0b3752..587c487 100644
--- a/src/test/org/codehaus/groovy/transform/TestTransform.groovy
+++ b/src/test/org/codehaus/groovy/transform/TestTransform.groovy
@@ -18,33 +18,31 @@
*/
package org.codehaus.groovy.transform
+import groovy.transform.CompilationUnitAware
import org.codehaus.groovy.ast.ASTNode
+import org.codehaus.groovy.control.CompilationUnit
import org.codehaus.groovy.control.CompilePhase
import org.codehaus.groovy.control.SourceUnit
-import org.codehaus.groovy.transform.ASTTransformation
-import org.codehaus.groovy.transform.GroovyASTTransformation
-
-/**
- * @author Danno.Ferrin
- */
-class TestTransform implements ASTTransformation {
+class TestTransform implements ASTTransformation, CompilationUnitAware {
static List<ASTNode[]> visitedNodes = []
- static List<CompilePhase> phases = []
+ static Map<String, List<CompilePhase>> phases = [:].withDefault{ [] }
+ CompilationUnit unit = null
- public void visit(ASTNode[] nodes, SourceUnit source) {
+ void visit(ASTNode[] nodes, SourceUnit source) {
visitedNodes += nodes
- phases += CompilePhase.phases[source.getPhase()]
+ // TODO work out why source.phase is not equal to unit.phase in all cases
+ phases[getClass().simpleName] += CompilePhase.phases[unit.phase]
}
+ @Override
+ void setCompilationUnit(CompilationUnit unit) {
+ this.unit = unit
+ }
}
@GroovyASTTransformation(phase=CompilePhase.CONVERSION)
-class TestTransformConversion extends TestTransform {
-
-}
+class TestTransformConversion extends TestTransform { }
@GroovyASTTransformation(phase=CompilePhase.CLASS_GENERATION)
-class TestTransformClassGeneration extends TestTransform {
-
-}
\ No newline at end of file
+class TestTransformClassGeneration extends TestTransform { }