private MethodDeclaration createMockMethodStub(final AST ast, final ASTRewrite rewrite,
final CodeGenerationSettings settings) throws CoreException, JavaModelException
{
ITypeBinding declaringType = method.getDeclaringClass();
MethodDeclaration stub = StubUtility2.createImplementationStub(fCompilationUnit, rewrite,
importRewrite, context, method, declaringType.getName(), settings, false);
if( !Object.class.getName().equals( method.getDeclaringClass().getQualifiedName() ) )
{
stub.modifiers().clear();
}
ASTUtil.addAnnotation("Mock", fJavaProject, rewrite, stub, method);
importRewrite.addImport(MockUtil.MOCK, context);
if( method.isConstructor() )
{
stub.setName( ast.newSimpleName(MockUtil.CTOR) );
stub.getBody().statements().clear();
}
else
{
setReturnStatement(stub, method, declaringType, ast, rewrite);
}
if( "void".equals(method.getReturnType().getName()) )
{
stub.getBody().statements().clear();
}
return stub;
}