protected IEventMethod getDelegatingContent(WidgetAdapter adapter, EventSetDescriptor eventSet, MethodDescriptor methodDesc, Block body, SingleVariableDeclaration var) {
List statements = body.statements();
if (statements.size() == 1) {
Object stmt = statements.get(0);
if (stmt instanceof ExpressionStatement) {
ExpressionStatement es = (ExpressionStatement) stmt;
Expression expression = es.getExpression();
if (expression instanceof MethodInvocation) {
MethodInvocation mi = (MethodInvocation) expression;
Expression optional = mi.getExpression();
if (optional == null||optional instanceof ThisExpression) {
List list = mi.arguments();
if (list.size() != 1) {
return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
}
Expression exp = (Expression) list.get(0);
if (exp instanceof SimpleName) {
SimpleName sn = (SimpleName) exp;
SimpleName varn = var.getName();
if (sn.getFullyQualifiedName().equals(varn.getFullyQualifiedName()))
return new EventDelegation(methodDesc, mi.getName().getFullyQualifiedName());
}
return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
} else {
return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
}
} else
return new CodeSnippet(adapter, eventSet, methodDesc, es.toString());
} else
return new CodeSnippet(adapter, eventSet, methodDesc, stmt.toString());
} else {
StringBuilder builder = new StringBuilder();
for (Object stmt : statements) {