Reputation: 1483
I want to invoke a method using eclipse AST.
I have the MethodDeclarion
of the method to be invoked. How can I invoke this method passing appropriate DUMMY/ default arguments.
i.e.
public void setStr (String str) { ... };
public void setSomeObj (SomeObj obj ) { ... };
Suppose I have MethodDeclarion
s of the above methods.
Now I want to create a MethodInvocation
like the following.
setStr("some dummy value");
setSomeObj(new SomeObj());
The difficulty I have is generating the DUMMY/ default arguments for method invocation. Please help
Upvotes: 0
Views: 118
Reputation: 60
MethodInvocation s;
s.arguments().add(...);
if you want to add an object that is part of the existing AST it needs to be:
....add((Cast)r.createCopyTarget(Object));
Cast = you will probaby have to cast it to a certain type, eclipse will tell you which.
Upvotes: 1