groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pascalschumac...@apache.org
Subject incubator-groovy git commit: GROOVY-7675: Compiler customization builder not resolve secureAst properties (closes #190)
Date Tue, 17 Nov 2015 17:43:20 GMT
Repository: incubator-groovy
Updated Branches:
  refs/heads/master a38afed6f -> b1948e89f


GROOVY-7675: Compiler customization builder not resolve secureAst properties (closes #190)

Fix compilerCustomizationBuilder withConfig secureAst resolution


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/b1948e89
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/b1948e89
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/b1948e89

Branch: refs/heads/master
Commit: b1948e89f2f64bc5a40f437c5a6363eff8576d0b
Parents: a38afed
Author: jfranco <jorge.franco.leza@gmail.com>
Authored: Mon Nov 16 00:48:53 2015 +0100
Committer: pascalschumacher <pascalschumacher@gmx.net>
Committed: Tue Nov 17 18:42:06 2015 +0100

----------------------------------------------------------------------
 .../customizers/builder/SecureASTCustomizerFactory.java  |  1 +
 .../builder/CompilerCustomizationBuilderTest.groovy      | 11 ++++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/b1948e89/src/main/org/codehaus/groovy/control/customizers/builder/SecureASTCustomizerFactory.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/customizers/builder/SecureASTCustomizerFactory.java
b/src/main/org/codehaus/groovy/control/customizers/builder/SecureASTCustomizerFactory.java
index 6160a83..3c81dee 100644
--- a/src/main/org/codehaus/groovy/control/customizers/builder/SecureASTCustomizerFactory.java
+++ b/src/main/org/codehaus/groovy/control/customizers/builder/SecureASTCustomizerFactory.java
@@ -47,6 +47,7 @@ public class SecureASTCustomizerFactory extends AbstractFactory {
         if (node instanceof SecureASTCustomizer) {
             Closure clone = (Closure) childContent.clone();
             clone.setDelegate(node);
+            clone.setResolveStrategy(Closure.DELEGATE_FIRST);
             clone.call();
         }
         return false;

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/b1948e89/src/test/org/codehaus/groovy/control/customizers/builder/CompilerCustomizationBuilderTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/control/customizers/builder/CompilerCustomizationBuilderTest.groovy
b/src/test/org/codehaus/groovy/control/customizers/builder/CompilerCustomizationBuilderTest.groovy
index c63b300..8b38598 100644
--- a/src/test/org/codehaus/groovy/control/customizers/builder/CompilerCustomizationBuilderTest.groovy
+++ b/src/test/org/codehaus/groovy/control/customizers/builder/CompilerCustomizationBuilderTest.groovy
@@ -321,7 +321,6 @@ class CompilerCustomizationBuilderTest extends GroovyTestCase {
     }
 
     void testCompilerConfigurationBuilderStyle() {
-        println 'hello'
         def config = new CompilerConfiguration()
         // the "customizers" method is added through a custom metaclass
         CompilerCustomizationBuilder.withConfig(config) {
@@ -333,6 +332,16 @@ class CompilerCustomizationBuilderTest extends GroovyTestCase {
         assert result == 'A(1)'
     }
 
+    void testCompilerConfigurationBuilderWithSecureAstCustomizer() {
+        def config = new CompilerConfiguration()
+        CompilerCustomizationBuilder.withConfig(config) {
+            secureAst {
+                importsWhitelist = []
+            }
+        }
+        assert config.compilationCustomizers.first().importsWhitelist == []
+    }
+
     private static class SourceUnit {
         String name
     }


Mime
View raw message