use of spoon.support.visitor.java.internal.TypeRuntimeBuilderContext in project spoon by INRIA.
the class JavaReflectionTreeBuilder method visitInterface.
@Override
public <T> void visitInterface(Class<T> clazz) {
final CtInterface<Object> ctInterface = factory.Core().createInterface();
ctInterface.setSimpleName(clazz.getSimpleName());
setModifier(ctInterface, clazz.getModifiers());
enter(new TypeRuntimeBuilderContext(ctInterface) {
@Override
public void addMethod(CtMethod ctMethod) {
super.addMethod(ctMethod);
ctMethod.setBody(null);
}
});
super.visitInterface(clazz);
exit();
contexts.peek().addType(ctInterface);
}
use of spoon.support.visitor.java.internal.TypeRuntimeBuilderContext in project spoon by INRIA.
the class JavaReflectionTreeBuilder method visitAnnotationClass.
@Override
public <T extends Annotation> void visitAnnotationClass(Class<T> clazz) {
final CtAnnotationType<?> ctAnnotationType = factory.Core().createAnnotationType();
ctAnnotationType.setSimpleName(clazz.getSimpleName());
setModifier(ctAnnotationType, clazz.getModifiers());
enter(new TypeRuntimeBuilderContext(ctAnnotationType) {
@Override
public void addMethod(CtMethod ctMethod) {
final CtField<Object> field = factory.Core().createField();
field.setSimpleName(ctMethod.getSimpleName());
field.setModifiers(ctMethod.getModifiers());
field.setType(ctMethod.getType());
ctAnnotationType.addField(field);
}
});
super.visitAnnotationClass(clazz);
exit();
contexts.peek().addType(ctAnnotationType);
}
use of spoon.support.visitor.java.internal.TypeRuntimeBuilderContext in project spoon by INRIA.
the class JavaReflectionTreeBuilder method visitEnum.
@Override
public <T> void visitEnum(Class<T> clazz) {
final CtEnum ctEnum = factory.Core().createEnum();
ctEnum.setSimpleName(clazz.getSimpleName());
setModifier(ctEnum, clazz.getModifiers());
enter(new TypeRuntimeBuilderContext(ctEnum) {
@Override
public void addConstructor(CtConstructor<?> ctConstructor) {
ctEnum.addConstructor(ctConstructor);
}
@Override
public void addEnumValue(CtEnumValue<?> ctEnumValue) {
ctEnum.addEnumValue(ctEnumValue);
}
});
super.visitEnum(clazz);
exit();
contexts.peek().addType(ctEnum);
}
use of spoon.support.visitor.java.internal.TypeRuntimeBuilderContext in project spoon by INRIA.
the class JavaReflectionTreeBuilder method visitClass.
@Override
public <T> void visitClass(Class<T> clazz) {
final CtClass ctClass = factory.Core().createClass();
ctClass.setSimpleName(clazz.getSimpleName());
setModifier(ctClass, clazz.getModifiers());
enter(new TypeRuntimeBuilderContext(ctClass) {
@Override
public void addConstructor(CtConstructor<?> ctConstructor) {
ctClass.addConstructor(ctConstructor);
}
@Override
public void addClassReference(CtTypeReference<?> typeReference) {
ctClass.setSuperclass(typeReference);
}
});
super.visitClass(clazz);
exit();
contexts.peek().addType(ctClass);
}
use of spoon.support.visitor.java.internal.TypeRuntimeBuilderContext in project spoon by INRIA.
the class JavaReflectionTreeBuilder method visitTypeParameter.
@Override
public <T extends GenericDeclaration> void visitTypeParameter(TypeVariable<T> parameter) {
final CtTypeParameter typeParameter = factory.Core().createTypeParameter();
typeParameter.setSimpleName(parameter.getName());
enter(new TypeRuntimeBuilderContext(typeParameter));
super.visitTypeParameter(parameter);
exit();
contexts.peek().addFormalType(typeParameter);
}
Aggregations