Package spoon.reflect.factory
Interface CoreFactory
- All Known Implementing Classes:
DefaultCoreFactory
public interface CoreFactory
This interface defines the core creation methods for the meta-model (to be
implemented so that Spoon can manipulate other meta-model implementations).
Important: a required post-condition for all the created elements is
that the factory (see FactoryAccessor.getFactory())
is correctly initialized with the main factory returned by
getMainFactory(), which cannot be null.
-
Method Summary
Modifier and TypeMethodDescription<T extends CtElement>
Tclone(T element)Recursively clones a given element of the metamodel and all its child elements.Creates an instance of the concrete metamodel class given as parameter.<A extends Annotation>
CtAnnotation<A>Creates an annotation.<T> CtAnnotationFieldAccess<T>Create an access to annotation value<T> CtAnnotationMethod<T>Creates an annotation method.<T extends Annotation>
CtAnnotationType<T>Creates an annotation type.Creates an anonymous executable.<T> CtArrayRead<T>Creates an array read access expression.<T> CtArrayTypeReference<T>Creates an array type reference.<T> CtArrayWrite<T>Creates an array write access expression.<T> CtAssert<T>Creates anassertstatement.<T, A extends T>
CtAssignment<T,A>Creates an assignment expression.<T> CtBinaryOperator<T>Creates a binary operator.<R> CtBlock<R>Creates a block.createBodyHolderSourcePosition(CompilationUnit compilationUnit, int nameSource, int nameEnd, int modifierStart, int modifierEnd, int declarationStart, int declarationEnd, int bodyStart, int bodyEnd, int[] lineSeparatorPositions)Creates a body holder source position.Creates abreakstatement.<S> CtCase<S>Creates acaseclause.Creates acatchclause.<T> CtCatchVariable<T>Creates a catch variable declaration statement.<T> CtCatchVariableReference<T>Creates a catch variable reference.<T> CtClass<T>Creates a class.<T> CtCodeSnippetExpression<T>Creates a code snippet expression.Creates a code snippet statement.Creates a comment.Creates a compilation unit.createCompoundSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int declarationStart, int declarationEnd, int[] lineSeparatorPositions)Creates a compound source position.<T> CtConditional<T>Creates a conditional expression (boolExpr?ifTrue:ifFalse).<T> CtConstructor<T>Creates a constructor.<T> CtConstructorCall<T>Creates a constructor call expression.Creates acontinuestatement.createDeclarationSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int modifierStart, int modifierEnd, int declarationStart, int declarationEnd, int[] lineSeparatorPositions)Creates a declaration source position.createDo()Creates adoloop.Creates an enum.<T> CtEnumValue<T>Creates an enum value.<T> CtExecutableReference<T>Creates an executable reference.<T, E extends CtExpression<?>>
CtExecutableReferenceExpression<T,E>Creates a new executable reference expression.<T> CtField<T>Creates a field.<T> CtFieldRead<T>Creates a field read access.<T> CtFieldReference<T>Creates a field reference.<T> CtFieldWrite<T>Creates a field write access.Creates aforloop.Creates aforeachloop.createIf()Creates anifstatement.Creates an import.<T> CtInterface<T>Creates an interface.<T> CtIntersectionTypeReference<T>Creates an intersection type reference.<T> CtConstructor<T>Creates an invisible array constructor.<T> CtInvocation<T>Creates an invocation expression.Creates a javadoc comment.Creates a javadoc tag.<T> CtLambda<T>Creates a new anonymous method expression.<T> CtLiteral<T>Creates a literal expression.<T> CtLocalVariable<T>Creates a local variable declaration statement.<T> CtLocalVariableReference<T>Creates a local variable reference.<T> CtMethod<T>Creates a method.Creates a Java 9 moduleCreates a reference to a Java 9 moduleCreates a "requires" directive for a Java 9 module file<T> CtNewArray<T>Creates a new array expression.<T> CtNewClass<T>Creates a new anonymous class expression.<T, A extends T>
CtOperatorAssignment<T,A>Creates a new operator assignment (like +=).Creates a package.Creates a package declaration.Creates a "export" directive for a Java 9 module fileCreates a package reference.<T> CtParameter<T>Creates a parameter.<T> CtParameterReference<T>Creates a parameter reference.createPartialSourcePosition(CompilationUnit compilationUnit)Creates a source position that points to the given compilation unitCreates a "provides" directive for a Java 9 module fileCreates a record.Creates a record component.<R> CtReturn<R>Creates areturnstatement.createSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int[] lineSeparatorPositions)Creates a source position.<R> CtStatementListCreates a statement list.<T> CtSuperAccess<T>Creates an access expression to super.<S> CtSwitch<S>Creates aswitchstatement.<T, S> CtSwitchExpression<T,S>Creates aswitchexpression.Creates asynchronizedstatement.Creates a TextBlock String Literal<T> CtThisAccess<T>Creates an access expression to this.Creates athrowstatement.Creates atryblock.Creates atrywith resource block.<T> CtTypeAccess<T>Creates a type access expression.Create a wildcard reference to a type member, used in a static importCreates a type parameter declaration.Creates a type parameter reference.Creates a Type Pattern<T> CtTypeReference<T>Creates a type reference.<T> CtUnaryOperator<T>Creates a unary operator expression.<T> CtUnboundVariableReference<T>Creates an unbound variable used in noclasspath.Creates an unresolved import.Creates a "uses" directive for a Java 9 module file<T> CtVariableRead<T>Creates a variable read expression.<T> CtVariableWrite<T>Creates a variable write expression.Creates awhileloop.Creates a wildcard reference.Creates ayieldstatementGets the main factory of that core factory (cannot benull).voidsetMainFactory(Factory mainFactory)Sets the main factory of that core factory.
-
Method Details
-
clone
Recursively clones a given element of the metamodel and all its child elements.- Type Parameters:
T- the element's type- Parameters:
element- the element- Returns:
- a clone of
element - See Also:
CtElement.clone()
-
createAnnotation
Creates an annotation. -
createAnnotationType
Creates an annotation type. -
createAnonymousExecutable
CtAnonymousExecutable createAnonymousExecutable()Creates an anonymous executable. -
createArrayRead
Creates an array read access expression. -
createArrayWrite
Creates an array write access expression. -
createArrayTypeReference
Creates an array type reference. -
createAssert
Creates anassertstatement. -
createAssignment
Creates an assignment expression. -
createBinaryOperator
Creates a binary operator. -
createBlock
Creates a block. -
createBreak
CtBreak createBreak()Creates abreakstatement. -
createCase
Creates acaseclause. -
createCatch
CtCatch createCatch()Creates acatchclause. -
createClass
Creates a class. -
createTypeParameter
CtTypeParameter createTypeParameter()Creates a type parameter declaration. -
createConditional
Creates a conditional expression (boolExpr?ifTrue:ifFalse). -
createConstructor
Creates a constructor. -
createInvisibleArrayConstructor
Creates an invisible array constructor. -
createContinue
CtContinue createContinue()Creates acontinuestatement. -
createDo
CtDo createDo()Creates adoloop. -
createEnum
Creates an enum. -
createExecutableReference
Creates an executable reference. -
createField
Creates a field. -
createEnumValue
Creates an enum value. -
createFieldRead
Creates a field read access. -
createFieldWrite
Creates a field write access. -
createThisAccess
Creates an access expression to this. -
createSuperAccess
Creates an access expression to super. -
createFieldReference
Creates a field reference. -
createFor
CtFor createFor()Creates aforloop. -
createForEach
CtForEach createForEach()Creates aforeachloop. -
createIf
CtIf createIf()Creates anifstatement. -
createInterface
Creates an interface. -
createInvocation
Creates an invocation expression. -
createLiteral
Creates a literal expression. -
createLocalVariable
Creates a local variable declaration statement. -
createLocalVariableReference
Creates a local variable reference. -
createCatchVariable
Creates a catch variable declaration statement. -
createCatchVariableReference
Creates a catch variable reference. -
createMethod
Creates a method. -
createAnnotationMethod
Creates an annotation method. -
createNewArray
Creates a new array expression. -
createConstructorCall
Creates a constructor call expression. Example to build "new Foo()":CtConstructorCall call = spoon.getFactory().Core().createConstructorCall(); call.setType(spoon.getFactory().Core().createTypeReference().setSimpleName("Foo")); -
createNewClass
Creates a new anonymous class expression. -
createLambda
Creates a new anonymous method expression. -
createExecutableReferenceExpression
<T, E extends CtExpression<?>> CtExecutableReferenceExpression<T,E> createExecutableReferenceExpression()Creates a new executable reference expression. -
createOperatorAssignment
Creates a new operator assignment (like +=). -
createPackage
CtPackage createPackage()Creates a package. -
createPackageReference
CtPackageReference createPackageReference()Creates a package reference. -
createParameter
Creates a parameter. -
createParameterReference
Creates a parameter reference. -
createReturn
Creates areturnstatement. -
createSourcePosition
SourcePosition createSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int[] lineSeparatorPositions)Creates a source position. -
createPartialSourcePosition
Creates a source position that points to the given compilation unit -
createCompoundSourcePosition
CompoundSourcePosition createCompoundSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int declarationStart, int declarationEnd, int[] lineSeparatorPositions)Creates a compound source position. -
createDeclarationSourcePosition
DeclarationSourcePosition createDeclarationSourcePosition(CompilationUnit compilationUnit, int startSource, int end, int modifierStart, int modifierEnd, int declarationStart, int declarationEnd, int[] lineSeparatorPositions)Creates a declaration source position. -
createBodyHolderSourcePosition
BodyHolderSourcePosition createBodyHolderSourcePosition(CompilationUnit compilationUnit, int nameSource, int nameEnd, int modifierStart, int modifierEnd, int declarationStart, int declarationEnd, int bodyStart, int bodyEnd, int[] lineSeparatorPositions)Creates a body holder source position. -
createStatementList
Creates a statement list. -
createSwitch
Creates aswitchstatement. -
createSwitchExpression
Creates aswitchexpression. -
createSynchronized
CtSynchronized createSynchronized()Creates asynchronizedstatement. -
createThrow
CtThrow createThrow()Creates athrowstatement. -
createTry
CtTry createTry()Creates atryblock. -
createTryWithResource
CtTryWithResource createTryWithResource()Creates atrywith resource block. -
createTypeParameterReference
CtTypeParameterReference createTypeParameterReference()Creates a type parameter reference. -
createWildcardReference
CtWildcardReference createWildcardReference()Creates a wildcard reference. -
createIntersectionTypeReference
Creates an intersection type reference. -
createTypeReference
Creates a type reference. -
createTypeAccess
Creates a type access expression. -
createUnaryOperator
Creates a unary operator expression. -
createVariableRead
Creates a variable read expression. -
createVariableWrite
Creates a variable write expression. -
createWhile
CtWhile createWhile()Creates awhileloop. -
createCodeSnippetExpression
Creates a code snippet expression. -
createCodeSnippetStatement
CtCodeSnippetStatement createCodeSnippetStatement()Creates a code snippet statement. -
createComment
CtComment createComment()Creates a comment. -
createJavaDoc
CtJavaDoc createJavaDoc()Creates a javadoc comment. -
createJavaDocTag
CtJavaDocTag createJavaDocTag()Creates a javadoc tag. -
createImport
CtImport createImport()Creates an import. -
createUnresolvedImport
CtImport createUnresolvedImport()Creates an unresolved import. CtUnresolvedImport stores the original content of the imort as a String in order to be able to restituate it when pretty printing. -
createPackageDeclaration
CtPackageDeclaration createPackageDeclaration()Creates a package declaration. -
getMainFactory
Factory getMainFactory()Gets the main factory of that core factory (cannot benull). -
setMainFactory
Sets the main factory of that core factory. -
createCompilationUnit
CompilationUnit createCompilationUnit()Creates a compilation unit. -
createAnnotationFieldAccess
Create an access to annotation value- Returns:
-
createUnboundVariableReference
Creates an unbound variable used in noclasspath. -
create
Creates an instance of the concrete metamodel class given as parameter. This is in particular useful when one uses reflection. -
createTypeMemberWildcardImportReference
CtTypeMemberWildcardImportReference createTypeMemberWildcardImportReference()Create a wildcard reference to a type member, used in a static import -
createModule
CtModule createModule()Creates a Java 9 module -
createModuleReference
CtModuleReference createModuleReference()Creates a reference to a Java 9 module -
createModuleRequirement
CtModuleRequirement createModuleRequirement()Creates a "requires" directive for a Java 9 module file -
createPackageExport
CtPackageExport createPackageExport()Creates a "export" directive for a Java 9 module file -
createProvidedService
CtProvidedService createProvidedService()Creates a "provides" directive for a Java 9 module file -
createUsedService
CtUsedService createUsedService()Creates a "uses" directive for a Java 9 module file -
createYieldStatement
CtYieldStatement createYieldStatement()Creates ayieldstatement- Returns:
- yieldStatement
-
createTextBlock
CtTextBlock createTextBlock()Creates a TextBlock String Literal -
createTypePattern
CtTypePattern createTypePattern()Creates a Type Pattern- Returns:
- a new Type Pattern instance.
-
createRecord
CtRecord createRecord()Creates a record.- Returns:
- the created record.
-
createRecordComponent
CtRecordComponent createRecordComponent()Creates a record component.- Returns:
- the created record component.
-