Search in sources :

Example 21 with CtConstructor

use of spoon.reflect.declaration.CtConstructor in project spoon by INRIA.

the class MethodTypingContext method setExecutableReference.

public MethodTypingContext setExecutableReference(CtExecutableReference<?> execRef) {
    if (classTypingContext == null) {
        CtTypeReference<?> declaringTypeRef = execRef.getDeclaringType();
        if (declaringTypeRef != null) {
            classTypingContext = new ClassTypingContext(declaringTypeRef);
        }
    }
    CtExecutable<?> exec = execRef.getExecutableDeclaration();
    if (exec == null) {
        throw new SpoonException("Cannot create MethodTypingContext from CtExecutable of CtExecutableReference is null");
    }
    if (exec instanceof CtMethod<?>) {
        setMethod((CtMethod<?>) exec);
    } else if (exec instanceof CtConstructor<?>) {
        setConstructor((CtConstructor<?>) exec);
    } else {
        throw new SpoonException("Cannot create MethodTypingContext from " + exec.getClass().getName());
    }
    this.actualTypeArguments = execRef.getActualTypeArguments();
    return this;
}
Also used : SpoonException(spoon.SpoonException) CtMethod(spoon.reflect.declaration.CtMethod) CtConstructor(spoon.reflect.declaration.CtConstructor)

Aggregations

CtConstructor (spoon.reflect.declaration.CtConstructor)21 CtMethod (spoon.reflect.declaration.CtMethod)10 CtClass (spoon.reflect.declaration.CtClass)9 Test (org.junit.Test)7 Factory (spoon.reflect.factory.Factory)6 CtAnonymousExecutable (spoon.reflect.declaration.CtAnonymousExecutable)5 CtParameter (spoon.reflect.declaration.CtParameter)5 CtTypeMember (spoon.reflect.declaration.CtTypeMember)5 ArrayList (java.util.ArrayList)4 CtType (spoon.reflect.declaration.CtType)4 Annotation (java.lang.annotation.Annotation)3 CtBlock (spoon.reflect.code.CtBlock)3 CtConstructorCall (spoon.reflect.code.CtConstructorCall)3 CtIf (spoon.reflect.code.CtIf)3 CtSwitch (spoon.reflect.code.CtSwitch)3 CtAnnotation (spoon.reflect.declaration.CtAnnotation)3 CtElement (spoon.reflect.declaration.CtElement)3 CtExecutable (spoon.reflect.declaration.CtExecutable)3 CtField (spoon.reflect.declaration.CtField)3 Executable (java.lang.reflect.Executable)2