groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: GROOVY-8261: Adding some getText overrides (closes #574)
Date Tue, 18 Jul 2017 05:55:37 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_6_X 435bb12c3 -> 98b4e57d9


GROOVY-8261: Adding some getText overrides (closes #574)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 98b4e57d98ce201650ad92ee4b1598ccbce6bbaa
Parents: 435bb12
Author: Jesse Glick <jglick@cloudbees.com>
Authored: Wed Jul 12 13:16:36 2017 -0400
Committer: paulk <paulk@asert.com.au>
Committed: Tue Jul 18 15:55:26 2017 +1000

----------------------------------------------------------------------
 .../groovy/ast/stmt/ExpressionStatement.java    |  2 +-
 .../groovy/ast/stmt/ThrowStatement.java         |  6 ++++
 .../ast/stmt/ExpressionStatementTest.groovy     | 35 ++++++++++++++++++
 .../groovy/ast/stmt/ThrowStatementTest.groovy   | 37 ++++++++++++++++++++
 4 files changed, 79 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/98b4e57d/src/main/org/codehaus/groovy/ast/stmt/ExpressionStatement.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/stmt/ExpressionStatement.java b/src/main/org/codehaus/groovy/ast/stmt/ExpressionStatement.java
index 6a1472a..c6376b2 100644
--- a/src/main/org/codehaus/groovy/ast/stmt/ExpressionStatement.java
+++ b/src/main/org/codehaus/groovy/ast/stmt/ExpressionStatement.java
@@ -51,7 +51,7 @@ public class ExpressionStatement extends Statement {
     }
 
     public String getText() {
-        return this.toString();
+        return expression.getText();
     }
 
     public String toString() {

http://git-wip-us.apache.org/repos/asf/groovy/blob/98b4e57d/src/main/org/codehaus/groovy/ast/stmt/ThrowStatement.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/ast/stmt/ThrowStatement.java b/src/main/org/codehaus/groovy/ast/stmt/ThrowStatement.java
index 978b1ff..a217840 100644
--- a/src/main/org/codehaus/groovy/ast/stmt/ThrowStatement.java
+++ b/src/main/org/codehaus/groovy/ast/stmt/ThrowStatement.java
@@ -45,4 +45,10 @@ public class ThrowStatement extends Statement {
     public void setExpression(Expression expression) {
         this.expression = expression;
     }
+
+    @Override
+    public String getText() {
+        return "throw " + expression.getText();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/groovy/blob/98b4e57d/src/test/org/codehaus/groovy/ast/stmt/ExpressionStatementTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/stmt/ExpressionStatementTest.groovy b/src/test/org/codehaus/groovy/ast/stmt/ExpressionStatementTest.groovy
new file mode 100644
index 0000000..9cd657f
--- /dev/null
+++ b/src/test/org/codehaus/groovy/ast/stmt/ExpressionStatementTest.groovy
@@ -0,0 +1,35 @@
+/*
+ *  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.ast.stmt
+
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.expr.ArgumentListExpression
+import org.codehaus.groovy.ast.expr.ConstructorCallExpression
+
+class ExpressionStatementTest extends GroovyTestCase {
+
+    void testGetText() {
+        assert new ExpressionStatement(
+            new ConstructorCallExpression(
+                new ClassNode(Object),
+                new ArgumentListExpression())).
+            text == 'new java.lang.Object()'
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/98b4e57d/src/test/org/codehaus/groovy/ast/stmt/ThrowStatementTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/stmt/ThrowStatementTest.groovy b/src/test/org/codehaus/groovy/ast/stmt/ThrowStatementTest.groovy
new file mode 100644
index 0000000..f8033c1
--- /dev/null
+++ b/src/test/org/codehaus/groovy/ast/stmt/ThrowStatementTest.groovy
@@ -0,0 +1,37 @@
+/*
+ *  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.ast.stmt
+
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.expr.ArgumentListExpression
+import org.codehaus.groovy.ast.expr.ConstantExpression
+import org.codehaus.groovy.ast.expr.ConstructorCallExpression
+
+class ThrowStatementTest extends GroovyTestCase {
+
+    void testGetText() {
+        assert new ThrowStatement(
+            new ConstructorCallExpression(
+                new ClassNode(Exception),
+                new ArgumentListExpression(
+                    new ConstantExpression('oops')))).
+            text == 'throw new java.lang.Exception(oops)'
+    }
+
+}


Mime
View raw message