Skip to content

Commit

Permalink
Minor method reference invocation refactoring.
Browse files Browse the repository at this point in the history
	Change on 2015/08/12 by kirbs <kirbs@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=100494749
  • Loading branch information
sjkirby authored and tomball committed Aug 13, 2015
1 parent 40aee7e commit 778252e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 25 deletions.
Expand Up @@ -55,12 +55,6 @@ public MethodInvocation(IMethodBinding binding, Expression expression) {
name.set(new SimpleName(binding));
}

public MethodInvocation(IMethodBinding binding, Expression expression, SimpleName name) {
methodBinding = binding;
this.expression.set(expression);
this.name.set(name);
}

@Override
public Kind getKind() {
return Kind.METHOD_INVOCATION;
Expand Down
Expand Up @@ -52,12 +52,6 @@ public SuperMethodInvocation(IMethodBinding methodBinding) {
name.set(new SimpleName(methodBinding));
}

public SuperMethodInvocation(IMethodBinding methodBinding, Name qualifier, SimpleName name) {
this.methodBinding = methodBinding;
this.qualifier.set(qualifier);
this.name.set(name);
}

@Override
public Kind getKind() {
return Kind.SUPER_METHOD_INVOCATION;
Expand Down
Expand Up @@ -519,8 +519,7 @@ public boolean visit(CreationReference node) {
public boolean visit(ExpressionMethodReference node) {
IMethodBinding methodBinding = node.getMethodBinding().getMethodDeclaration();
Expression expression = node.getExpression().copy();
SimpleName name = node.getName().copy();
MethodInvocation invocation = new MethodInvocation(methodBinding, expression, name);
MethodInvocation invocation = new MethodInvocation(methodBinding, expression);
List<Expression> invocationArguments = invocation.getArguments();
buildMethodReferenceInvocationArguments(invocationArguments, node);
if (BindingUtil.isVoid(methodBinding.getReturnType())) {
Expand All @@ -534,8 +533,8 @@ public boolean visit(ExpressionMethodReference node) {
public boolean visit(SuperMethodReference node) {
IMethodBinding methodBinding = node.getMethodBinding().getMethodDeclaration();
Name qualifier = node.getQualifier() == null ? null : node.getQualifier().copy();
SimpleName name = node.getName().copy();
SuperMethodInvocation invocation = new SuperMethodInvocation(methodBinding, qualifier, name);
SuperMethodInvocation invocation = new SuperMethodInvocation(methodBinding);
invocation.setQualifier(qualifier);
List<Expression> invocationArguments = invocation.getArguments();
buildMethodReferenceInvocationArguments(invocationArguments, node);
if (BindingUtil.isVoid(methodBinding.getReturnType())) {
Expand All @@ -553,8 +552,10 @@ public boolean visit(SuperMethodReference node) {
* buildMethodReferenceInvocationArguments.
*/
public boolean visit(TypeMethodReference node) {
GeneratedMethodBinding methodBinding = new GeneratedMethodBinding(node.getName().toString(),
node.getMethodBinding());
IMethodBinding oldMethodBinding = node.getMethodBinding();
GeneratedMethodBinding methodBinding = GeneratedMethodBinding.newNamedMethod(
node.getName().toString(), oldMethodBinding);
methodBinding.addParameters(oldMethodBinding);
methodBinding.setModifiers(methodBinding.getModifiers() & ~Modifier.STATIC);
methodBinding.getParameters().remove(0);
IMethodBinding functionalInterface = node.getTypeBinding().getFunctionalInterfaceMethod();
Expand All @@ -565,8 +566,7 @@ public boolean visit(TypeMethodReference node) {
IVariableBinding variableBinding = new GeneratedVariableBinding(new String(var), 0,
functionalParam, false, true, null, null);
SimpleName expression = new SimpleName(variableBinding);
SimpleName name = node.getName().copy();
MethodInvocation invocation = new MethodInvocation(methodBinding, expression, name);
MethodInvocation invocation = new MethodInvocation(methodBinding, expression);
List<Expression> invocationArguments = invocation.getArguments();
if (BindingUtil.isVoid(methodBinding.getReturnType())) {
node.setInvocation(new ExpressionStatement(invocation));
Expand Down
Expand Up @@ -25,7 +25,6 @@
import org.eclipse.jdt.core.dom.IBinding;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.Modifier;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;

import java.util.Arrays;
Expand Down Expand Up @@ -70,10 +69,9 @@ public GeneratedMethodBinding(IMethodBinding m) {
addParameters(m);
}

public GeneratedMethodBinding(String name, IMethodBinding m) {
this(null, name, m.getModifiers() & ~Modifier.STATIC, m.getReturnType(), null,
m.getDeclaringClass(), m.isConstructor(), m.isVarargs());
addParameters(m);
public static GeneratedMethodBinding newNamedMethod(String name, IMethodBinding m) {
return new GeneratedMethodBinding(null, name, m.getModifiers(),
m.getReturnType(), null, m.getDeclaringClass(), m.isConstructor(), m.isVarargs());
}

public static GeneratedMethodBinding newMethod(
Expand Down

0 comments on commit 778252e

Please sign in to comment.