Search in sources :

Example 6 with TypeReferenceRuntimeBuilderContext

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

the class JavaReflectionTreeBuilder method visitTypeParameterReference.

@Override
public <T extends GenericDeclaration> void visitTypeParameterReference(TypeVariable<T> parameter) {
    final CtTypeParameterReference typeParameterReference = factory.Core().createTypeParameterReference();
    typeParameterReference.setSimpleName(parameter.getName());
    enter(new TypeReferenceRuntimeBuilderContext(typeParameterReference));
    super.visitTypeParameterReference(parameter);
    exit();
    contexts.peek().addTypeName(typeParameterReference);
}
Also used : CtTypeParameterReference(spoon.reflect.reference.CtTypeParameterReference) TypeReferenceRuntimeBuilderContext(spoon.support.visitor.java.internal.TypeReferenceRuntimeBuilderContext)

Example 7 with TypeReferenceRuntimeBuilderContext

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

the class JavaReflectionTreeBuilder method visitArrayReference.

@Override
public <T> void visitArrayReference(final Class<T> typeArray) {
    final CtArrayTypeReference<?> arrayTypeReference = factory.Core().createArrayTypeReference();
    enter(new TypeReferenceRuntimeBuilderContext(arrayTypeReference) {

        @Override
        public void addClassReference(CtTypeReference<?> typeReference) {
            if (typeArray.getSimpleName().equals(typeReference.getSimpleName())) {
                arrayTypeReference.setComponentType(typeReference);
            } else {
                arrayTypeReference.setDeclaringType(typeReference);
            }
        }

        @Override
        public void addArrayReference(CtArrayTypeReference<?> typeReference) {
            arrayTypeReference.setComponentType(typeReference);
        }
    });
    super.visitArrayReference(typeArray);
    exit();
    contexts.peek().addArrayReference(arrayTypeReference);
}
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