Search in sources :

Example 6 with ThrowStatement

use of org.eclipse.jdt.core.dom.ThrowStatement in project evosuite by EvoSuite.

the class TestExtractingVisitor method endVisit.

/**
 * {@inheritDoc}
 */
@Override
public void endVisit(ClassInstanceCreation instanceCreation) {
    if (instanceCreation.getParent() instanceof ThrowStatement) {
        logger.warn("Ignoring throw statements!");
        return;
    }
    List<?> paramTypes = Arrays.asList(instanceCreation.resolveConstructorBinding().getParameterTypes());
    List<?> paramValues = instanceCreation.arguments();
    Constructor<?> constructor = retrieveConstructor(instanceCreation.getType(), paramTypes, paramValues);
    List<VariableReference> params = convertParams(instanceCreation.arguments(), paramTypes);
    VariableReference retVal = retrieveVariableReference(instanceCreation, null);
    retVal.setOriginalCode(instanceCreation.toString());
    ConstructorStatement statement = new ValidConstructorStatement(testCase.getReference(), constructor, retVal, params);
    testCase.addStatement(statement);
}
Also used : ConstructorStatement(org.evosuite.testcase.ConstructorStatement) VariableReference(org.evosuite.testcase.VariableReference) ThrowStatement(org.eclipse.jdt.core.dom.ThrowStatement)

Aggregations

ThrowStatement (org.eclipse.jdt.core.dom.ThrowStatement)6 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 ASTNode (org.eclipse.jdt.core.dom.ASTNode)2 CastExpression (org.eclipse.jdt.core.dom.CastExpression)2 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)2 Expression (org.eclipse.jdt.core.dom.Expression)2 IBinding (org.eclipse.jdt.core.dom.IBinding)2 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)2 MethodInvocation (org.eclipse.jdt.core.dom.MethodInvocation)2 ParenthesizedExpression (org.eclipse.jdt.core.dom.ParenthesizedExpression)2 SimpleName (org.eclipse.jdt.core.dom.SimpleName)2 SuperMethodInvocation (org.eclipse.jdt.core.dom.SuperMethodInvocation)2 ThisExpression (org.eclipse.jdt.core.dom.ThisExpression)2 ScopeAnalyzer (org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer)2 RenameNodeCorrectionProposal (org.eclipse.jdt.internal.ui.text.correction.proposals.RenameNodeCorrectionProposal)1 ReplaceCorrectionProposal (org.eclipse.jdt.internal.ui.text.correction.proposals.ReplaceCorrectionProposal)1 ConstructorStatement (org.evosuite.testcase.ConstructorStatement)1 VariableReference (org.evosuite.testcase.VariableReference)1