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/10/04 20:17:53 UTC
[groovy] branch GROOVY-8258 updated: GROOVY-8258: minor refactor
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY-8258
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY-8258 by this push:
new 9d300b1 GROOVY-8258: minor refactor
9d300b1 is described below
commit 9d300b1581c2ce398988a47593fec3a2bca39227
Author: Daniel Sun <su...@apache.org>
AuthorDate: Mon Oct 5 04:17:33 2020 +0800
GROOVY-8258: minor refactor
---
.../apache/groovy/linq/LinqGroovyMethods.groovy | 32 +++++++++-------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy b/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
index cd6b502..ff368fb 100644
--- a/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
+++ b/subprojects/groovy-linq/src/main/groovy/org/apache/groovy/linq/LinqGroovyMethods.groovy
@@ -88,29 +88,23 @@ class LinqGroovyMethods {
.from($v { fromEntry.value })
}
- MethodCallExpression where =
- callX(
- from,
- "where",
- closureX(
- params(param(ClassHelper.DYNAMIC_TYPE, aliasVariable.name)),
- stmt(linqContext.whereList[0])
- )
- )
-
- MethodCallExpression select =
- callX(
- where,
- "select",
- closureX(
- params(param(ClassHelper.DYNAMIC_TYPE, aliasVariable.name)),
- stmt(linqContext.selectList[0])
- )
- )
+ MethodCallExpression where = callXWithClosure(from, "where", aliasVariable.name, linqContext.whereList[0])
+ MethodCallExpression select = callXWithClosure(where, "select", aliasVariable.name, linqContext.selectList[0])
return select
}
+ private static callXWithClosure(Expression receiver, String methodName, String closureParamName, Expression closureCode) {
+ callX(
+ receiver,
+ methodName,
+ closureX(
+ params(param(ClassHelper.DYNAMIC_TYPE, closureParamName)),
+ stmt(closureCode)
+ )
+ )
+ }
+
@ToString(includeNames=true)
static class LinqContext {
Map<VariableExpression, Expression> fromMap = new LinkedHashMap<>()