[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.jdt] How to modify the parameters of a MethodInvocation node
|
Hi,
I was instrumenting the source code file with some method call.
But I had some problems modifying the parameters of a MethodInvocation node.
Given the following code snippet on some ast,
SimpleName methodName = ast.newSimpleName("someMethodCall");
MethodInvocation methodEntry = ast.newMethodInvocation();
methodEntry.setName(methodName);
List<Expression> arguments = (List<Expression>) methodEntry.arguments();
StringLiteral currentObject = ast.newStringLiteral();
currentObject.setLiteralValue("this");
arguments.add(currentObject);
List<Expression> arguments2 = (List<Expression>) methodEntry.arguments();
StringLiteral currentClass = ast.newStringLiteral();
currentObject.setLiteralValue("someclass");
arguments2.add(currentClass);
as I expect, it should generate the statement
someMethodCall(this, someclass)
But instead it would produce
someMethodCall(someclass, "")
I was so frustrated that It could only reflect the last change you made to
the arguments list.
My intention is to let someMethodCall have 5 StringLiteral parameters which
I never achieved.
I doubt is there something wrong with my code.
You help would be much appreciated.
Kevin