Search in sources :

Example 1 with TypeReferenceRuntimeBuilderContext

use of spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext in project spoon by INRIA.

the class JavaReflectionTreeBuilder method visitInterfaceReference.

@Override
public <T> void visitInterfaceReference(Class<T> anInterface) {
    final CtTypeReference<Object> typeReference = factory.Core().createTypeReference();
    typeReference.setSimpleName(anInterface.getSimpleName());
    enter(new TypeReferenceRuntimeBuilderContext(typeReference));
    super.visitInterfaceReference(anInterface);
    exit();
    contexts.peek().addInterfaceReference(typeReference);
}
Also used : TypeReferenceRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)

Example 2 with TypeReferenceRuntimeBuilderContext

use of spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext in project spoon by INRIA.

the class JavaReflectionTreeBuilder method visitType.

@Override
public void visitType(WildcardType type) {
    final CtWildcardReference wildcard = factory.Core().createWildcardReference();
    wildcard.setUpper(type.getUpperBounds() != null && !type.getUpperBounds()[0].equals(Object.class));
    enter(new TypeReferenceRuntimeBuilderContext(wildcard));
    super.visitType(type);
    exit();
    contexts.peek().addTypeName(wildcard);
}
Also used : CtWildcardReference(spoon.reflect.reference.CtWildcardReference) TypeReferenceRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)

Example 3 with TypeReferenceRuntimeBuilderContext

use of spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext in project spoon by INRIA.

the class JavaReflectionTreeBuilder method visitType.

@Override
public void visitType(Type type) {
    CtTypeReference<?> ctTypeReference;
    if (type instanceof TypeVariable) {
        ctTypeReference = factory.Core().createTypeParameterReference();
    } else {
        ctTypeReference = factory.Core().createTypeReference();
    }
    enter(new TypeReferenceRuntimeBuilderContext(ctTypeReference));
    ctTypeReference.setSimpleName(getTypeName(type));
    super.visitType(type);
    exit();
    contexts.peek().addTypeName(ctTypeReference);
}
Also used : TypeVariable(java.lang.reflect.TypeVariable) TypeReferenceRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)

Example 4 with TypeReferenceRuntimeBuilderContext

use of spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext in project spoon by INRIA.

the class JavaReflectionTreeBuilder method visitClassReference.

@Override
public <T> void visitClassReference(Class<T> clazz) {
    final CtTypeReference<Object> typeReference = factory.Core().createTypeReference();
    typeReference.setSimpleName(clazz.getSimpleName());
    enter(new TypeReferenceRuntimeBuilderContext(typeReference));
    super.visitClassReference(clazz);
    exit();
    contexts.peek().addClassReference(typeReference);
}
Also used : TypeReferenceRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)

Example 5 with TypeReferenceRuntimeBuilderContext

use of spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext in project spoon by INRIA.

the class JavaReflectionTreeBuilder method visitType.

@Override
public void visitType(ParameterizedType type) {
    final CtTypeReference<?> ctTypeReference = factory.Core().createTypeReference();
    enter(new TypeReferenceRuntimeBuilderContext(ctTypeReference) {

        @Override
        public void addClassReference(CtTypeReference<?> typeReference) {
            ctTypeReference.setSimpleName(typeReference.getSimpleName());
            ctTypeReference.setPackage(typeReference.getPackage());
            ctTypeReference.setDeclaringType(typeReference.getDeclaringType());
            ctTypeReference.setActualTypeArguments(typeReference.getActualTypeArguments());
            ctTypeReference.setAnnotations(typeReference.getAnnotations());
        }

        @Override
        public void addType(CtType<?> aType) {
        }
    });
    super.visitType(type);
    exit();
    contexts.peek().addTypeName(ctTypeReference);
}
Also used : TypeReferenceRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)

Aggregations

TypeReferenceRuntimeBuilderContext (spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)7 TypeVariable (java.lang.reflect.TypeVariable)1 CtTypeParameterReference (spoon.reflect.reference.CtTypeParameterReference)1 CtWildcardReference (spoon.reflect.reference.CtWildcardReference)1