aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-01-10 16:12:32 +0000
committerMichael Williamson <mike@zwobble.org>2016-01-10 16:12:32 +0000
commit1cca01d385e68aefe2131319c53c4811101f15f7 (patch)
tree08fbdf98f3e0d53ce1c64925bef8ad576c52ae64 /src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
parent29c9a38a112b53e4ca193af27818442493c876cb (diff)
Handle both static and instance method calls in one node
Diffstat (limited to 'src/main/java/org/zwobble/couscous/ast/MethodCallNode.java')
-rw-r--r--src/main/java/org/zwobble/couscous/ast/MethodCallNode.java36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java b/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
index efeee93..3bae839 100644
--- a/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
+++ b/src/main/java/org/zwobble/couscous/ast/MethodCallNode.java
@@ -8,6 +8,7 @@ import java.util.Collections;
import java.util.List;
import java.util.function.Function;
+import static org.zwobble.couscous.ast.InstanceReceiver.instanceReceiver;
import static org.zwobble.couscous.util.ExtraLists.eagerMap;
import static org.zwobble.couscous.util.ExtraLists.list;
@@ -81,30 +82,41 @@ public class MethodCallNode implements ExpressionNode {
}
public static MethodCallNode methodCall(
- ExpressionNode receiver,
- String methodName,
- List<ExpressionNode> arguments,
- TypeName type) {
+ ExpressionNode receiver,
+ String methodName,
+ List<ExpressionNode> arguments,
+ TypeName type)
+ {
+ return methodCall(instanceReceiver(receiver), methodName, arguments, type);
+ }
+
+ public static MethodCallNode methodCall(
+ Receiver receiver,
+ String methodName,
+ List<ExpressionNode> arguments,
+ TypeName type)
+ {
return new MethodCallNode(receiver, methodName, arguments, type);
}
- private final ExpressionNode receiver;
+ private final Receiver receiver;
private final String methodName;
private final List<ExpressionNode> arguments;
private final TypeName type;
- public MethodCallNode(
- ExpressionNode receiver,
- String methodName,
- List<ExpressionNode> arguments,
- TypeName type) {
+ private MethodCallNode(
+ Receiver receiver,
+ String methodName,
+ List<ExpressionNode> arguments,
+ TypeName type)
+ {
this.receiver = receiver;
this.methodName = methodName;
this.arguments = arguments;
this.type = type;
}
- public ExpressionNode getReceiver() {
+ public Receiver getReceiver() {
return receiver;
}
@@ -132,7 +144,7 @@ public class MethodCallNode implements ExpressionNode {
@Override
public ExpressionNode replaceExpressions(Function<ExpressionNode, ExpressionNode> replace) {
return new MethodCallNode(
- replace.apply(receiver),
+ receiver.replaceExpressions(replace),
methodName,
eagerMap(arguments, replace::apply),
type);