public <T> void visitCtMethod(CtMethod<T> m) { if (!m.getFormalTypeParameters().isEmpty()) { scan(m.getFormalTypeParameters()); write(" "); } scan(m.getType()); write(" "); write(m.getSimpleName()); write("("); for (CtParameter<?> p : m.getParameters()) { scan(p.getType()); write(","); } if (!m.getParameters().isEmpty()) { clearLast(); } write(")"); }
public <T> void visitCtMethod(CtMethod<T> m) { enter(m); scan(m.getAnnotations()); scan(m.getType()); scan(m.getParameters()); scanReferences(m.getThrownTypes()); scanReferences(m.getFormalTypeParameters()); scan(m.getBody()); exit(m); }
write("default "); writeFormalTypeParameters(m.getFormalTypeParameters()); scan(m.getType()); write(" ");
/** * Creates a constructor into a target class by copying it from a source * method. * * @param target * the target class * @param source * the method to be copied * @return the new constructor */ @SuppressWarnings("unchecked") public <T> CtConstructor<T> create(CtClass<T> target, CtMethod<?> source) { CtMethod<T> method = factory.Core().clone((CtMethod<T>) source); CtConstructor<T> newConstructor = factory.Core().createConstructor(); newConstructor.setAnnotations(method.getAnnotations()); newConstructor.setBody(method.getBody()); newConstructor.setDocComment(method.getDocComment()); newConstructor.setFormalTypeParameters(method.getFormalTypeParameters()); newConstructor.setModifiers(method.getModifiers()); newConstructor.setParameters(method.getParameters()); target.addConstructor(newConstructor); return newConstructor; }