Search in sources :

Example 1 with TypeRuntimeBuilderContext

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);
}
Also used : TypeRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeRuntimeBuilderContext) CtMethod(spoon.reflect.declaration.CtMethod)

Example 2 with TypeRuntimeBuilderContext

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);
}
Also used : TypeRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeRuntimeBuilderContext) CtField(spoon.reflect.declaration.CtField) CtMethod(spoon.reflect.declaration.CtMethod)

Example 3 with TypeRuntimeBuilderContext

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);
}
Also used : TypeRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeRuntimeBuilderContext) CtEnum(spoon.reflect.declaration.CtEnum)

Example 4 with TypeRuntimeBuilderContext

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);
}
Also used : CtClass(spoon.reflect.declaration.CtClass) TypeRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeRuntimeBuilderContext)

Example 5 with TypeRuntimeBuilderContext

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);
}
Also used : CtTypeParameter(spoon.reflect.declaration.CtTypeParameter) TypeRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeRuntimeBuilderContext)

Aggregations

TypeRuntimeBuilderContext (spoon.support.visitor.java.internal.TypeRuntimeBuilderContext)5 CtMethod (spoon.reflect.declaration.CtMethod)2 CtClass (spoon.reflect.declaration.CtClass)1 CtEnum (spoon.reflect.declaration.CtEnum)1 CtField (spoon.reflect.declaration.CtField)1 CtTypeParameter (spoon.reflect.declaration.CtTypeParameter)1