Search in sources :

Example 11 with StandardEnvironment

use of spoon.support.StandardEnvironment in project spoon by INRIA.

the class Metamodel method getAllMetamodelInterfaces.

/**
 * Returns all interfaces of the Spoon metamodel.
 * This method is stateless for sake of maintenance.
 * If you need to call it several times, you should store the result.
 */
public static Set<CtType<?>> getAllMetamodelInterfaces() {
    Set<CtType<?>> result = new HashSet<>();
    Factory factory = new FactoryImpl(new DefaultCoreFactory(), new StandardEnvironment());
    result.add(factory.Type().get(spoon.reflect.code.BinaryOperatorKind.class));
    result.add(factory.Type().get(spoon.reflect.code.CtAbstractInvocation.class));
    result.add(factory.Type().get(spoon.reflect.code.CtAnnotationFieldAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtArrayAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtArrayRead.class));
    result.add(factory.Type().get(spoon.reflect.code.CtArrayWrite.class));
    result.add(factory.Type().get(spoon.reflect.code.CtAssert.class));
    result.add(factory.Type().get(spoon.reflect.code.CtAssignment.class));
    result.add(factory.Type().get(spoon.reflect.code.CtBinaryOperator.class));
    result.add(factory.Type().get(spoon.reflect.code.CtBlock.class));
    result.add(factory.Type().get(spoon.reflect.code.CtBodyHolder.class));
    result.add(factory.Type().get(spoon.reflect.code.CtBreak.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCFlowBreak.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCase.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCatch.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCatchVariable.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCodeElement.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCodeSnippetExpression.class));
    result.add(factory.Type().get(spoon.reflect.code.CtCodeSnippetStatement.class));
    result.add(factory.Type().get(spoon.reflect.code.CtComment.class));
    result.add(factory.Type().get(spoon.reflect.code.CtConditional.class));
    result.add(factory.Type().get(spoon.reflect.code.CtConstructorCall.class));
    result.add(factory.Type().get(spoon.reflect.code.CtContinue.class));
    result.add(factory.Type().get(spoon.reflect.code.CtDo.class));
    result.add(factory.Type().get(spoon.reflect.code.CtExecutableReferenceExpression.class));
    result.add(factory.Type().get(spoon.reflect.code.CtExpression.class));
    result.add(factory.Type().get(spoon.reflect.code.CtFieldAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtFieldRead.class));
    result.add(factory.Type().get(spoon.reflect.code.CtFieldWrite.class));
    result.add(factory.Type().get(spoon.reflect.code.CtFor.class));
    result.add(factory.Type().get(spoon.reflect.code.CtForEach.class));
    result.add(factory.Type().get(spoon.reflect.code.CtIf.class));
    result.add(factory.Type().get(spoon.reflect.code.CtInvocation.class));
    result.add(factory.Type().get(spoon.reflect.code.CtJavaDoc.class));
    result.add(factory.Type().get(spoon.reflect.code.CtJavaDocTag.class));
    result.add(factory.Type().get(spoon.reflect.code.CtLabelledFlowBreak.class));
    result.add(factory.Type().get(spoon.reflect.code.CtLambda.class));
    result.add(factory.Type().get(spoon.reflect.code.CtLiteral.class));
    result.add(factory.Type().get(spoon.reflect.code.CtLocalVariable.class));
    result.add(factory.Type().get(spoon.reflect.code.CtLoop.class));
    result.add(factory.Type().get(spoon.reflect.code.CtNewArray.class));
    result.add(factory.Type().get(spoon.reflect.code.CtNewClass.class));
    result.add(factory.Type().get(spoon.reflect.code.CtOperatorAssignment.class));
    result.add(factory.Type().get(spoon.reflect.code.CtRHSReceiver.class));
    result.add(factory.Type().get(spoon.reflect.code.CtReturn.class));
    result.add(factory.Type().get(spoon.reflect.code.CtStatement.class));
    result.add(factory.Type().get(spoon.reflect.code.CtStatementList.class));
    result.add(factory.Type().get(spoon.reflect.code.CtSuperAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtSwitch.class));
    result.add(factory.Type().get(spoon.reflect.code.CtSynchronized.class));
    result.add(factory.Type().get(spoon.reflect.code.CtTargetedExpression.class));
    result.add(factory.Type().get(spoon.reflect.code.CtThisAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtThrow.class));
    result.add(factory.Type().get(spoon.reflect.code.CtTry.class));
    result.add(factory.Type().get(spoon.reflect.code.CtTryWithResource.class));
    result.add(factory.Type().get(spoon.reflect.code.CtTypeAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtUnaryOperator.class));
    result.add(factory.Type().get(spoon.reflect.code.CtVariableAccess.class));
    result.add(factory.Type().get(spoon.reflect.code.CtVariableRead.class));
    result.add(factory.Type().get(spoon.reflect.code.CtVariableWrite.class));
    result.add(factory.Type().get(spoon.reflect.code.CtWhile.class));
    result.add(factory.Type().get(spoon.reflect.code.UnaryOperatorKind.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtAnnotatedElementType.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtAnnotation.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtAnnotationMethod.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtAnnotationType.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtAnonymousExecutable.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtClass.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtCodeSnippet.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtConstructor.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtElement.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtEnum.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtEnumValue.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtExecutable.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtField.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtFormalTypeDeclarer.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtInterface.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtMethod.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtModifiable.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtMultiTypedElement.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtNamedElement.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtPackage.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtParameter.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtShadowable.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtType.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtTypeInformation.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtTypeMember.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtTypeParameter.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtTypedElement.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtVariable.class));
    result.add(factory.Type().get(spoon.reflect.declaration.ModifierKind.class));
    result.add(factory.Type().get(spoon.reflect.declaration.ParentNotInitializedException.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtActualTypeContainer.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtArrayTypeReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtCatchVariableReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtExecutableReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtFieldReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtIntersectionTypeReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtLocalVariableReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtPackageReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtParameterReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtTypeParameterReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtTypeReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtUnboundVariableReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtVariableReference.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtWildcardReference.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtImport.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtImportKind.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtModule.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtModuleRequirement.class));
    result.add(factory.Type().get(CtPackageExport.class));
    result.add(factory.Type().get(CtProvidedService.class));
    result.add(factory.Type().get(spoon.reflect.reference.CtModuleReference.class));
    result.add(factory.Type().get(spoon.reflect.declaration.CtUsedService.class));
    result.add(factory.Type().get(CtModuleDirective.class));
    return result;
}
Also used : CtProvidedService(spoon.reflect.declaration.CtProvidedService) FactoryImpl(spoon.reflect.factory.FactoryImpl) HashSet(java.util.HashSet) CtPackageExport(spoon.reflect.declaration.CtPackageExport) CtType(spoon.reflect.declaration.CtType) DefaultCoreFactory(spoon.support.DefaultCoreFactory) Factory(spoon.reflect.factory.Factory) DefaultCoreFactory(spoon.support.DefaultCoreFactory) StandardEnvironment(spoon.support.StandardEnvironment) CtModuleDirective(spoon.reflect.declaration.CtModuleDirective)

Example 12 with StandardEnvironment

use of spoon.support.StandardEnvironment in project spoon by INRIA.

the class IntercessionContractTest method testContract.

@Test
public void testContract() throws Throwable {
    Factory factory = new FactoryImpl(new DefaultCoreFactory(), new StandardEnvironment());
    Object element = instance;
    if (element instanceof FactoryAccessor) {
        ((FactoryAccessor) element).setFactory(factory);
    }
    // we invoke the setter
    toTest.invoke(element, new Object[] { null });
}
Also used : FactoryAccessor(spoon.processing.FactoryAccessor) DefaultCoreFactory(spoon.support.DefaultCoreFactory) Factory(spoon.reflect.factory.Factory) DefaultCoreFactory(spoon.support.DefaultCoreFactory) ParentContractTest.createCompatibleObject(spoon.test.parent.ParentContractTest.createCompatibleObject) FactoryImpl(spoon.reflect.factory.FactoryImpl) StandardEnvironment(spoon.support.StandardEnvironment) Test(org.junit.Test)

Aggregations

StandardEnvironment (spoon.support.StandardEnvironment)12 Test (org.junit.Test)11 FactoryImpl (spoon.reflect.factory.FactoryImpl)11 DefaultCoreFactory (spoon.support.DefaultCoreFactory)11 Factory (spoon.reflect.factory.Factory)10 CtStatement (spoon.reflect.code.CtStatement)4 CtClass (spoon.reflect.declaration.CtClass)3 CtMethod (spoon.reflect.declaration.CtMethod)3 JDTSnippetCompiler (spoon.support.compiler.jdt.JDTSnippetCompiler)3 SpoonModelBuilder (spoon.SpoonModelBuilder)2 CtInvocation (spoon.reflect.code.CtInvocation)2 CoreFactory (spoon.reflect.factory.CoreFactory)2 HashSet (java.util.HashSet)1 TreeSet (java.util.TreeSet)1 Launcher (spoon.Launcher)1 FactoryAccessor (spoon.processing.FactoryAccessor)1 CtAssignment (spoon.reflect.code.CtAssignment)1 CtBlock (spoon.reflect.code.CtBlock)1 CtComment (spoon.reflect.code.CtComment)1 CtExpression (spoon.reflect.code.CtExpression)1