String heightString) throws Exception {
// may be setRect(left, top, width, height)
List<MethodInvocation> invocations = getMethodInvocations("setRect(int,int,int,int)");
if (!invocations.isEmpty()) {
MethodInvocation invocation = invocations.get(0);
AstEditor editor = m_object.getEditor();
{
Integer widthInteger = getIntegerValue(widthString);
Integer heightInteger = getIntegerValue(heightString);
// replace "int" width/height
if (widthHas && heightHas) {
if (widthInteger != null && heightInteger != null) {
editor.replaceInvocationArgument(invocation, 2, widthInteger.toString());
editor.replaceInvocationArgument(invocation, 3, heightInteger.toString());
return;
}
}
// replace "int" width
if (widthHas && !heightHas) {
if (widthInteger != null) {
editor.replaceInvocationArgument(invocation, 2, widthInteger.toString());
return;
}
}
// replace "int" height
if (heightHas && !widthHas) {
if (heightInteger != null) {
editor.replaceInvocationArgument(invocation, 3, heightInteger.toString());
return;
}
}
}
// replace with "moveTo"
{
List<Expression> arguments = DomGenerics.arguments(invocation);
String args =
editor.getSource(arguments.get(0)) + ", " + editor.getSource(arguments.get(1));
m_object.addMethodInvocation("moveTo(int,int)", args);
// remove "setRect"
editor.removeEnclosingStatement(invocation);
}
}
// continue
super.setSize0_addInvocation(target, widthHas, heightHas, widthString, heightString);
}