I have test file as below:-
class SampleClass {
private String strCommand;
public void formStrCommand()
{
strCommand = "type trace mql on;trigger on;type trace mql on;"
}
int runCommand(Context context) {
str = MqlUtil.mqlCommand(context, strCommand, true);
}
}
I have custom rule with below overridden method:-
public void visitMethodInvocation(MethodInvocationTree tree) {
if (tree.methodSelect().is(Tree.Kind.MEMBER_SELECT)) {
MemberSelectExpressionTree memberSelect = (MemberSelectExpressionTree) tree.methodSelect();
String expr = memberSelect.expression().toString();
String idnfier = memberSelect.identifier().name();
Arguments args = (Arguments) tree.arguments();
// If the args[1] is LiteralTree I am good to get value of args[1]
// But if it is a variable / identifier, how can the value inside it be retrieved?
// In below example, how can I retrieve value of 'strCommand' in visitMethodInvocation() method ?
}
}
How can I retrieve value of variable argument at runtime in visitMethodInvocation method ?