use of act.cli.meta.CommandMethodMetaInfo in project actframework by actframework.
the class CommanderEnhancer method visitMethod.
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
if (null == metaInfo || isConstructor(name)) {
return mv;
}
final CommandMethodMetaInfo methodInfo = metaInfo.command(name);
if (null == methodInfo) {
return mv;
}
if (isPublic(access) && !isConstructor(name)) {
return new MethodVisitor(ASM5, mv) {
private Set<Integer> skipNaming = new HashSet<Integer>();
@Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
if ("Ljavax/inject/Named;".equals(desc)) {
skipNaming.add(parameter);
}
return super.visitParameterAnnotation(parameter, desc, visible);
}
@Override
public void visitEnd() {
int sz = methodInfo.paramCount();
for (int i = 0; i < sz; ++i) {
if (!skipNaming.contains(i)) {
String name = methodInfo.param(i).name();
AnnotationVisitor av = mv.visitParameterAnnotation(i, "Ljavax/inject/Named;", true);
av.visit("value", name);
}
}
super.visitEnd();
}
};
}
return mv;
}
Aggregations