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 2017/04/07 13:31:22 UTC

[39/50] [abbrv] groovy git commit: add license header and remove some dead code (closes #472)

add license header and remove some dead code (closes #472)


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

Branch: refs/heads/parrot
Commit: e0655ebefd5bf067b2ae7e6f1072e3a4b92e47cf
Parents: 3094904
Author: Sergei Egorov <se...@zeroturnaround.com>
Authored: Mon Mar 27 13:20:53 2017 +0300
Committer: paulk <pa...@asert.com.au>
Committed: Tue Mar 28 16:04:02 2017 +1000

----------------------------------------------------------------------
 .../groovy/macro/methods/MacroGroovyMethods.java  | 11 ++---------
 .../macro/transform/MacroClassTransformation.java |  2 +-
 .../groovy/macro/ExampleMacroMethods.java         | 18 ++++++++++++++++++
 .../org/codehaus/groovy/macro/MacroTest.groovy    |  6 ++++++
 4 files changed, 27 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e0655ebe/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/methods/MacroGroovyMethods.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/methods/MacroGroovyMethods.java b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/methods/MacroGroovyMethods.java
index d9f00e6..ae2a568 100644
--- a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/methods/MacroGroovyMethods.java
+++ b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/methods/MacroGroovyMethods.java
@@ -106,13 +106,6 @@ public class MacroGroovyMethods {
 
         Boolean asIs = (Boolean) asIsConstantExpression.getValue();
 
-        TupleExpression macroArguments = getMacroArguments(macroContext.getSourceUnit(), macroContext.getCall());
-
-        if (macroArguments == null) {
-            // FIXME
-            return macroContext.getCall();
-        }
-
         return callX(
                 propX(classX(ClassHelper.makeWithoutCaching(MacroBuilder.class, false)), "INSTANCE"),
                 "macro",
@@ -120,13 +113,13 @@ public class MacroGroovyMethods {
                         phaseExpression != null ? phaseExpression : constX(null),
                         asIsConstantExpression,
                         constX(source),
-                        buildSubstitutionMap(macroContext.getSourceUnit(), closureExpression),
+                        buildSubstitutions(macroContext.getSourceUnit(), closureExpression),
                         classX(ClassHelper.makeWithoutCaching(MacroBuilder.getMacroValue(closureBlock, asIs).getClass(), false))
                 )
         );
     }
 
-    public static ListExpression buildSubstitutionMap(final SourceUnit source, final ASTNode expr) {
+    public static ListExpression buildSubstitutions(final SourceUnit source, final ASTNode expr) {
         final ListExpression listExpression = new ListExpression();
 
         ClassCodeVisitorSupport visitor = new ClassCodeVisitorSupport() {

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0655ebe/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/transform/MacroClassTransformation.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/transform/MacroClassTransformation.java b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/transform/MacroClassTransformation.java
index 4ecd42e..6777933 100644
--- a/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/transform/MacroClassTransformation.java
+++ b/subprojects/groovy-macro/src/main/groovy/org/codehaus/groovy/macro/transform/MacroClassTransformation.java
@@ -101,7 +101,7 @@ public class MacroClassTransformation extends MethodCallTransformation {
                                 MACRO_METHOD,
                                 args(
                                         constX(source),
-                                        MacroGroovyMethods.buildSubstitutionMap(sourceUnit, type),
+                                        MacroGroovyMethods.buildSubstitutions(sourceUnit, type),
                                         classX(ClassHelper.make(ClassNode.class))
                                 )
                         );

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0655ebe/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/ExampleMacroMethods.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/ExampleMacroMethods.java b/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/ExampleMacroMethods.java
index 3b32ab8..3fc8574 100644
--- a/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/ExampleMacroMethods.java
+++ b/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/ExampleMacroMethods.java
@@ -1,3 +1,21 @@
+/*
+ *  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.codehaus.groovy.macro;
 
 import org.codehaus.groovy.ast.expr.*;

http://git-wip-us.apache.org/repos/asf/groovy/blob/e0655ebe/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/MacroTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/MacroTest.groovy b/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/MacroTest.groovy
index 69139b2..4ccb46b 100644
--- a/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/MacroTest.groovy
+++ b/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/MacroTest.groovy
@@ -224,4 +224,10 @@ class MacroTest extends GroovyTestCase {
         assert ast1.getField("str") != null
 '''
     }
+
+    void testNotAMacroCall() {
+        shouldFail(MissingMethodException) {
+            assertScript 'macro()'
+        }
+    }
 }