Package org.eclipse.xtext.xbase.jvmmodel
Class JvmTypesBuilder
- java.lang.Object
-
- org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
-
public class JvmTypesBuilder extends java.lang.ObjectA set of factory and builder functions, used to create instances of (TypesPackage). It's meant to be used from an implementation ofIJvmModelInferrer.- Since:
- 2.7
- Noextend:
- This class is not intended to be subclassed by clients.
- Noinstantiate:
- This class is not intended to be instantiated by clients.
-
-
Constructor Summary
Constructors Constructor Description JvmTypesBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddAnnotation(org.eclipse.xtext.common.types.JvmAnnotationTarget target, XAnnotation annotation)Translates anXAnnotationto aJvmAnnotationReferenceand adds them to the givenJvmAnnotationTarget.voidaddAnnotations(org.eclipse.xtext.common.types.JvmAnnotationTarget target, java.lang.Iterable<? extends XAnnotation> annotations)org.eclipse.xtext.common.types.JvmTypeReferenceaddArrayTypeDimension(org.eclipse.xtext.common.types.JvmTypeReference componentType)<T extends org.eclipse.emf.ecore.EObject>
Tassociate(org.eclipse.emf.ecore.EObject sourceElement, T target)Associates a source element with a target element.protected <T extends org.eclipse.emf.ecore.EObject>
TcloneAndAssociate(T original)Creates a deep copy of the given object and associates each copied instance with the clone.org.eclipse.xtext.common.types.JvmTypeReferencecloneWithProxies(org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a clone of the givenJvmTypeReferencewithout resolving any proxies.<T extends org.eclipse.xtext.common.types.JvmIdentifiableElement>
TcloneWithProxies(T original)Creates a clone of the givenJvmIdentifiableElementwithout resolving any proxies.voidcopyDocumentationTo(org.eclipse.emf.ecore.EObject source, org.eclipse.xtext.common.types.JvmIdentifiableElement jvmElement)Attaches the given documentation of the source element to the given jvmElement.protected org.eclipse.xtext.common.types.JvmGenericTypecreateJvmGenericType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)java.lang.StringgetDocumentation(org.eclipse.emf.ecore.EObject source)Retrieves the attached documentation for the given source element.XExpressiongetExpression(org.eclipse.xtext.common.types.JvmMember member)Looks up and returns a logically contained expression.XExpressiongetInitializer(org.eclipse.xtext.common.types.JvmMember member)Deprecated.usegetExpression(JvmMember)insteadorg.eclipse.xtext.common.types.JvmAnnotationReferencegetJvmAnnotationReference(XAnnotation anno)Translates a singleXAnnotationtoJvmAnnotationReferencethat can be added to aJvmAnnotationTarget.org.eclipse.xtext.common.types.JvmTypeReferenceinferredType()Produces an inferred type which will be resolved on demand.org.eclipse.xtext.common.types.JvmTypeReferenceinferredType(XExpression expression)Produces an inferred type which will be resolved on demand.protected <T extends org.eclipse.emf.ecore.EObject>
TinitializeSafely(T targetElement, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super T> initializer)protected voidinternalSetExtension(org.eclipse.xtext.common.types.JvmAnnotationTarget annotationTarget, org.eclipse.emf.ecore.EObject sourceElement, boolean value)protected booleanisPrimitiveBoolean(org.eclipse.xtext.common.types.JvmTypeReference typeRef)Detects whether the type reference refers to primitive boolean.protected booleanisValidSource(org.eclipse.emf.ecore.EObject sourceElement)org.eclipse.xtext.common.types.JvmTypeReferencenewTypeRef(org.eclipse.emf.ecore.EObject ctx, java.lang.Class<?> clazz, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)Deprecated.org.eclipse.xtext.common.types.JvmTypeReferencenewTypeRef(org.eclipse.emf.ecore.EObject ctx, java.lang.String typeName, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)Deprecated.org.eclipse.xtext.common.types.JvmTypeReferencenewTypeRef(org.eclipse.xtext.common.types.JvmType type, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)Deprecated.<T> booleanoperator_add(org.eclipse.emf.common.util.EList<? super T> list, java.lang.Iterable<? extends T> elements)Overrides the defaultoperator_add()to ignorenullelements.<T> booleanoperator_add(org.eclipse.emf.common.util.EList<? super T> list, T element)Overrides the defaultoperator_add()to ignorenullelements.voidremoveExistingBody(org.eclipse.xtext.common.types.JvmMember member)Detaches any existing bodies from theJvmMember.voidsetBody(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtend2.lib.StringConcatenationClient strategy)Attaches the given compile strategy to the givenJvmExecutablesuch that the compiler knows how to implement theJvmExecutablewhen it is translated to Java source code.voidsetBody(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)Attaches the given compile strategy to the givenJvmExecutablesuch that the compiler knows how to implement theJvmExecutablewhen it is translated to Java source code.voidsetBody(org.eclipse.xtext.common.types.JvmExecutable logicalContainer, XExpression expr)Sets the givenJvmExecutableas the logical container for the givenXExpression.protected voidsetCompilationStrategy(org.eclipse.xtext.common.types.JvmMember member, org.eclipse.xtend2.lib.StringConcatenationClient strategy)protected voidsetCompilationStrategy(org.eclipse.xtext.common.types.JvmMember member, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)voidsetDocumentation(org.eclipse.xtext.common.types.JvmIdentifiableElement jvmElement, java.lang.String documentation)Attaches the given documentation to the given jvmElement.voidsetExtension(org.eclipse.xtext.common.types.JvmField field, org.eclipse.emf.ecore.EObject sourceElement, boolean value)Adds or removes the annotation@Extensionfrom the given field.voidsetExtension(org.eclipse.xtext.common.types.JvmFormalParameter parameter, org.eclipse.emf.ecore.EObject sourceElement, boolean value)Adds or removes the annotation@Extensionfrom the given parameter.voidsetFileHeader(org.eclipse.xtext.common.types.JvmDeclaredType jvmDeclaredType, java.lang.String headerText)Attaches the given headText to the givenJvmDeclaredType.voidsetInitializer(org.eclipse.xtext.common.types.JvmField field, org.eclipse.xtend2.lib.StringConcatenationClient strategy)Attaches the given compile strategy to the givenJvmFieldsuch that the compiler knows how to initialize theJvmFieldwhen it is translated to Java source code.voidsetInitializer(org.eclipse.xtext.common.types.JvmField field, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)Attaches the given compile strategy to the givenJvmFieldsuch that the compiler knows how to initialize theJvmFieldwhen it is translated to Java source code.voidsetInitializer(org.eclipse.xtext.common.types.JvmField field, XExpression expr)Sets the givenJvmFieldas the logical container for the givenXExpression.protected org.eclipse.xtext.util.Pair<java.lang.String,java.lang.String>splitQualifiedName(java.lang.String name)org.eclipse.xtext.common.types.JvmAnnotationReferencetoAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType)Deprecated.org.eclipse.xtext.common.types.JvmAnnotationReferencetoAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType, java.lang.Object value)Deprecated.org.eclipse.xtext.common.types.JvmAnnotationReferencetoAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName)Deprecated.org.eclipse.xtext.common.types.JvmAnnotationReferencetoAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName, java.lang.Object value)Deprecated.org.eclipse.xtext.common.types.JvmAnnotationTypetoAnnotationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public annotation declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmAnnotationTypetoAnnotationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmAnnotationType> initializer)Creates a public annotation declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmGenericTypetoClass(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public class declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmGenericTypetoClass(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmGenericType> initializer)Creates a public class declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmGenericTypetoClass(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.naming.QualifiedName name)Creates a public class declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmGenericTypetoClass(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.naming.QualifiedName name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmGenericType> initializer)Creates a public class declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmConstructortoConstructor(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmConstructor> initializer)Creates and returns a constructor with the given simple name associated to the given source element.org.eclipse.xtext.common.types.JvmEnumerationLiteraltoEnumerationLiteral(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public enumeration literal, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmEnumerationLiteraltoEnumerationLiteral(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmEnumerationLiteral> initializer)Same astoEnumerationLiteral(EObject, String)but with an initializer passed as the last argument.org.eclipse.xtext.common.types.JvmEnumerationTypetoEnumerationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public enum declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmEnumerationTypetoEnumerationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmEnumerationType> initializer)Creates a public enum declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmOperationtoEqualsMethod(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType, boolean isDelegateToSuperEquals)Deprecated.build your own :-)org.eclipse.xtext.common.types.JvmOperationtoEqualsMethod(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType, boolean isDelegateToSuperEquals, org.eclipse.xtext.common.types.JvmField... jvmFields)Deprecated.build your own :-)org.eclipse.xtext.common.types.JvmFieldtoField(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a private field with the given name and the given type associated to the given sourceElement.org.eclipse.xtext.common.types.JvmFieldtoField(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmField> initializer)Same astoField(EObject, String, JvmTypeReference)but with an initializer passed as the last argument.org.eclipse.xtext.common.types.JvmOperationtoGetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String propertyName, java.lang.String fieldName, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a getter method for the given property name and the field name.org.eclipse.xtext.common.types.JvmOperationtoGetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)shorthand fortoGetter(sourceElement, name, name, typeRef).org.eclipse.xtext.common.types.JvmOperationtoHashCodeMethod(org.eclipse.emf.ecore.EObject sourceElement, boolean extendsSomethingWithProperHashCode, org.eclipse.xtext.common.types.JvmDeclaredType declaredType)Deprecated.build your own :-)org.eclipse.xtext.common.types.JvmOperationtoHashCodeMethod(org.eclipse.emf.ecore.EObject sourceElement, boolean extendsSomethingWithProperHashCode, org.eclipse.xtext.common.types.JvmField... jvmFields)Deprecated.build your own :-)org.eclipse.xtext.common.types.JvmGenericTypetoInterface(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmGenericType> initializer)Creates a public interface declaration, associated to the given sourceElement.org.eclipse.xtext.common.types.JvmAnnotationValuetoJvmAnnotationValue(XExpression value)Removes the given expression from its current logical container and creates a fresh detachedJvmAnnotationValue, that needs to be put into someJvmAnnotationReferenceorg.eclipse.xtext.common.types.JvmOperationtoMethod(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference returnType, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmOperation> initializer)Creates a public method with the given name and the given return type and associates it with the given sourceElement.org.eclipse.xtext.common.types.JvmFormalParametertoParameter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates and returns a formal parameter for the given name and type, which is associated to the given source element.org.eclipse.xtext.common.types.JvmOperationtoSetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String propertyName, java.lang.String fieldName, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a setter method for the given properties name with the standard implementation assigning the passed parameter to a similarly named field.org.eclipse.xtext.common.types.JvmOperationtoSetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)shorthand fortoSetter(sourceElement, name, name, typeRef)org.eclipse.xtext.common.types.JvmOperationtoToStringMethod(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType)Creates atoString()method accumulating the values of all fields.voidtranslateAnnotationsTo(java.lang.Iterable<? extends XAnnotation> annotations, org.eclipse.xtext.common.types.JvmAnnotationTarget target)Deprecated.useaddAnnotations(JvmAnnotationTarget, Iterable)instead
-
-
-
Method Detail
-
operator_add
public <T> boolean operator_add(org.eclipse.emf.common.util.EList<? super T> list, T element)Overrides the defaultoperator_add()to ignorenullelements.
-
operator_add
public <T> boolean operator_add(org.eclipse.emf.common.util.EList<? super T> list, java.lang.Iterable<? extends T> elements)Overrides the defaultoperator_add()to ignorenullelements.
-
setBody
public void setBody(org.eclipse.xtext.common.types.JvmExecutable logicalContainer, XExpression expr)Sets the givenJvmExecutableas the logical container for the givenXExpression. This defines the context and the scope for the given expression. Also it defines how the given JvmExecutable can be executed. For instanceJvmModelGeneratorautomatically translates any givenXExpressioninto corresponding Java source code as the body of the givenJvmExecutable.- Parameters:
logicalContainer- theJvmExecutablethe expression is associated with. Can benullin which case this function does nothing.expr- the expression. Can benullin which case this function does nothing.
-
removeExistingBody
public void removeExistingBody(org.eclipse.xtext.common.types.JvmMember member)
Detaches any existing bodies from theJvmMember. A body could be a logically containerXExpressionor a black box compilation strategy.- Parameters:
member- the member to remove the body from
-
getExpression
public XExpression getExpression(org.eclipse.xtext.common.types.JvmMember member)
Looks up and returns a logically contained expression.- Parameters:
member- the member containing the expression- Returns:
- the expression logically contained in the given member or
nullif no expression is contained.
-
getInitializer
@Deprecated public XExpression getInitializer(org.eclipse.xtext.common.types.JvmMember member)
Deprecated.usegetExpression(JvmMember)instead
-
initializeSafely
protected <T extends org.eclipse.emf.ecore.EObject> T initializeSafely(T targetElement, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super T> initializer)
-
setBody
public void setBody(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)Attaches the given compile strategy to the givenJvmExecutablesuch that the compiler knows how to implement theJvmExecutablewhen it is translated to Java source code.- Parameters:
executable- the operation or constructor to add the method body to. Ifnullthis method does nothing.strategy- the compilation strategy. Ifnullthis method does nothing.
-
setBody
public void setBody(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtend2.lib.StringConcatenationClient strategy)Attaches the given compile strategy to the givenJvmExecutablesuch that the compiler knows how to implement theJvmExecutablewhen it is translated to Java source code.- Parameters:
executable- the operation or constructor to add the method body to. Ifnullthis method does nothing.strategy- the compilation strategy. Ifnullthis method does nothing.
-
getDocumentation
public java.lang.String getDocumentation(org.eclipse.emf.ecore.EObject source)
Retrieves the attached documentation for the given source element. By default this implementation provides the text of a multi line comment preceding the definition of the given source element.- Returns:
- the documentation of the given source,
nullif source isnullor doesn't have any documentation.
-
setDocumentation
public void setDocumentation(org.eclipse.xtext.common.types.JvmIdentifiableElement jvmElement, java.lang.String documentation)Attaches the given documentation to the given jvmElement.
-
copyDocumentationTo
public void copyDocumentationTo(org.eclipse.emf.ecore.EObject source, org.eclipse.xtext.common.types.JvmIdentifiableElement jvmElement)Attaches the given documentation of the source element to the given jvmElement. The documentation is computed lazily.
-
setFileHeader
public void setFileHeader(org.eclipse.xtext.common.types.JvmDeclaredType jvmDeclaredType, java.lang.String headerText)Attaches the given headText to the givenJvmDeclaredType.
-
toClass
public org.eclipse.xtext.common.types.JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.naming.QualifiedName name)Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualifiedName of the resulting class.- Returns:
- a
JvmGenericTyperepresenting a Java class of the given name,nullif either parameter isnull.
-
toClass
public org.eclipse.xtext.common.types.JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualifiedName of the resulting class.- Returns:
- a
JvmGenericTyperepresenting a Java class of the given name,nullif either parameter isnull.
-
toClass
public org.eclipse.xtext.common.types.JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.naming.QualifiedName name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmGenericType> initializer)Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- theQualifiedNameof the resulting class.initializer- the initializer to apply on the created class element. Ifnull, the class won't be initialized.- Returns:
- a
JvmGenericTyperepresenting a Java class of the given name,nullif sourceElement or name arenull.
-
toClass
public org.eclipse.xtext.common.types.JvmGenericType toClass(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmGenericType> initializer)Creates a public class declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualified name of the resulting class.initializer- the initializer to apply on the created class element. Ifnull, the class won't be initialized.- Returns:
- a
JvmGenericTyperepresenting a Java class of the given name,nullif sourceElement or name arenull.
-
toInterface
public org.eclipse.xtext.common.types.JvmGenericType toInterface(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmGenericType> initializer)Creates a public interface declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualified name of the resulting class.initializer- the initializer to apply on the created interface element. Ifnull, the interface won't be initialized.- Returns:
- a
JvmGenericTyperepresenting a Java class of the given name,nullif sourceElement or name arenull.
-
toAnnotationType
public org.eclipse.xtext.common.types.JvmAnnotationType toAnnotationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public annotation declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualified name of the resulting class.- Returns:
- a
JvmAnnotationTyperepresenting a Java annotation of the given name,nullif sourceElement or name arenull.
-
toAnnotationType
public org.eclipse.xtext.common.types.JvmAnnotationType toAnnotationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmAnnotationType> initializer)Creates a public annotation declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualified name of the resulting class.initializer- the initializer to apply on the created annotation. Ifnull, the annotation won't be initialized.- Returns:
- a
JvmAnnotationTyperepresenting a Java annotation of the given name,nullif sourceElement or name arenull.
-
toEnumerationType
public org.eclipse.xtext.common.types.JvmEnumerationType toEnumerationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public enum declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualified name of the resulting enum type.- Returns:
- a result representing a Java enum type with the given name,
nullif sourceElement or name arenull. - Since:
- 2.8
-
toEnumerationType
public org.eclipse.xtext.common.types.JvmEnumerationType toEnumerationType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmEnumerationType> initializer)Creates a public enum declaration, associated to the given sourceElement. It sets the given name, which might be fully qualified using the standard Java notation.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the qualified name of the resulting enum type.initializer- the initializer to apply on the created enumeration type. Ifnull, the enum won't be initialized.- Returns:
- a result representing a Java enum type with the given name,
nullif sourceElement or name arenull.
-
toEnumerationLiteral
public org.eclipse.xtext.common.types.JvmEnumerationLiteral toEnumerationLiteral(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)Creates a public enumeration literal, associated to the given sourceElement.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the simple name of the resulting enumeration literal.- Returns:
- a result representing a Java enumeration literal with the given name,
nullif sourceElement or name arenull.
-
toEnumerationLiteral
public org.eclipse.xtext.common.types.JvmEnumerationLiteral toEnumerationLiteral(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmEnumerationLiteral> initializer)Same astoEnumerationLiteral(EObject, String)but with an initializer passed as the last argument.
-
createJvmGenericType
protected org.eclipse.xtext.common.types.JvmGenericType createJvmGenericType(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)
-
splitQualifiedName
protected org.eclipse.xtext.util.Pair<java.lang.String,java.lang.String> splitQualifiedName(java.lang.String name)
-
toField
public org.eclipse.xtext.common.types.JvmField toField(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a private field with the given name and the given type associated to the given sourceElement.- Parameters:
sourceElement- the sourceElement the resulting element is associated with.name- the simple name of the resulting field.typeRef- the type of the field- Returns:
- a
JvmFieldrepresenting a Java field with the given simple name and type.
-
toField
public org.eclipse.xtext.common.types.JvmField toField(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmField> initializer)Same astoField(EObject, String, JvmTypeReference)but with an initializer passed as the last argument.
-
setExtension
public void setExtension(org.eclipse.xtext.common.types.JvmField field, org.eclipse.emf.ecore.EObject sourceElement, boolean value)Adds or removes the annotation@Extensionfrom the given field. If the annotation is already present, nothing is done ifvalueistrue. If it is not present andvalueisfalse, this is a no-op, too.- Parameters:
field- the field that will be processedsourceElement- the context that shall be used to lookup theannotation type.value-trueif the parameter shall be marked as extension,falseif it should be unmarked.
-
setExtension
public void setExtension(org.eclipse.xtext.common.types.JvmFormalParameter parameter, org.eclipse.emf.ecore.EObject sourceElement, boolean value)Adds or removes the annotation@Extensionfrom the given parameter. If the annotation is already present, nothing is done ifvalueistrue. If it is not present andvalueisfalse, this is a no-op, too.- Parameters:
parameter- the parameter that will be processedsourceElement- the context that shall be used to lookup theannotation type.value-trueif the parameter shall be marked as extension,falseif it should be unmarked.
-
internalSetExtension
protected void internalSetExtension(org.eclipse.xtext.common.types.JvmAnnotationTarget annotationTarget, org.eclipse.emf.ecore.EObject sourceElement, boolean value)
-
associate
public <T extends org.eclipse.emf.ecore.EObject> T associate(org.eclipse.emf.ecore.EObject sourceElement, T target)Associates a source element with a target element. This association is used for tracing. Navigation, for instance, uses this information to find the real declaration of a Jvm element.- Returns:
- the target for convenience.
- See Also:
IJvmModelAssociator,IJvmModelAssociations
-
isValidSource
protected boolean isValidSource(org.eclipse.emf.ecore.EObject sourceElement)
-
toMethod
public org.eclipse.xtext.common.types.JvmOperation toMethod(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference returnType, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmOperation> initializer)Creates a public method with the given name and the given return type and associates it with the given sourceElement.- Parameters:
sourceElement- the sourceElement the method should be associated with.name- the simple name of the method to be created.returnType- the return type of the created method.initializer- the initializer to apply on the created method. Ifnull, the method won't be initialized.- Returns:
- a result representing a Java method with the given name,
nullif sourceElement or name arenull.
-
inferredType
public org.eclipse.xtext.common.types.JvmTypeReference inferredType()
Produces an inferred type which will be resolved on demand. It should not be attempted to resolve this type during the model inference.- Returns:
- an inferred type.
-
inferredType
public org.eclipse.xtext.common.types.JvmTypeReference inferredType(XExpression expression)
Produces an inferred type which will be resolved on demand. It should not be attempted to resolve this type during the model inference.- Parameters:
expression- the expression that will be used resolve the type. May not benull.- Returns:
- an inferred type.
-
toGetter
public org.eclipse.xtext.common.types.JvmOperation toGetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)shorthand fortoGetter(sourceElement, name, name, typeRef).
-
toGetter
public org.eclipse.xtext.common.types.JvmOperation toGetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String propertyName, java.lang.String fieldName, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a getter method for the given property name and the field name. Example:public String getPropertyName() { return this.fieldName; }- Returns:
- a getter method for a JavaBeans property,
nullif sourceElement or name arenull.
-
isPrimitiveBoolean
protected boolean isPrimitiveBoolean(org.eclipse.xtext.common.types.JvmTypeReference typeRef)
Detects whether the type reference refers to primitive boolean.- Since:
- 2.9
-
toSetter
public org.eclipse.xtext.common.types.JvmOperation toSetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)shorthand fortoSetter(sourceElement, name, name, typeRef)
-
toSetter
public org.eclipse.xtext.common.types.JvmOperation toSetter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String propertyName, java.lang.String fieldName, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates a setter method for the given properties name with the standard implementation assigning the passed parameter to a similarly named field. Example:public void setFoo(String foo) { this.foo = foo; }- Returns:
- a setter method for a JavaBeans property with the given name,
nullif sourceElement or name arenull.
-
toParameter
public org.eclipse.xtext.common.types.JvmFormalParameter toParameter(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name, org.eclipse.xtext.common.types.JvmTypeReference typeRef)Creates and returns a formal parameter for the given name and type, which is associated to the given source element.- Returns:
- a Java parameter given name,
nullif sourceElement or name arenull.
-
toConstructor
public org.eclipse.xtext.common.types.JvmConstructor toConstructor(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super org.eclipse.xtext.common.types.JvmConstructor> initializer)Creates and returns a constructor with the given simple name associated to the given source element. By default the constructor will have an empty body and no arguments, hence the Java default constructor.- Parameters:
sourceElement- the sourceElement the constructor should be associated with.initializer- the initializer to apply on the created constructor. Ifnull, the method won't be initialized.- Returns:
- a result representing a Java constructor with the given name,
nullif sourceElement isnull.
-
toToStringMethod
public org.eclipse.xtext.common.types.JvmOperation toToStringMethod(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType)Creates atoString()method accumulating the values of all fields.- Returns:
- a result representing a Java toString() method,
nullif sourceElement or declaredType arenull.
-
toHashCodeMethod
@Deprecated public org.eclipse.xtext.common.types.JvmOperation toHashCodeMethod(org.eclipse.emf.ecore.EObject sourceElement, boolean extendsSomethingWithProperHashCode, org.eclipse.xtext.common.types.JvmDeclaredType declaredType)Deprecated.build your own :-)
-
toHashCodeMethod
@Deprecated public org.eclipse.xtext.common.types.JvmOperation toHashCodeMethod(org.eclipse.emf.ecore.EObject sourceElement, boolean extendsSomethingWithProperHashCode, org.eclipse.xtext.common.types.JvmField... jvmFields)Deprecated.build your own :-)
-
toEqualsMethod
@Deprecated public org.eclipse.xtext.common.types.JvmOperation toEqualsMethod(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType, boolean isDelegateToSuperEquals)Deprecated.build your own :-)
-
toEqualsMethod
@Deprecated public org.eclipse.xtext.common.types.JvmOperation toEqualsMethod(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType, boolean isDelegateToSuperEquals, org.eclipse.xtext.common.types.JvmField... jvmFields)Deprecated.build your own :-)
-
toAnnotation
@Deprecated public org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType)Deprecated.Creates and returns an annotation reference of the given annotation type.- See Also:
toAnnotation(EObject, Class, Object)
-
toAnnotation
@Deprecated public org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName)Deprecated.Creates and returns an annotation reference of the given annotation type's name.- See Also:
toAnnotation(EObject, String, Object)
-
toAnnotation
@Deprecated public org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType, java.lang.Object value)Deprecated.Creates and returns an annotation reference of the given annotation type's name and the given value.- Parameters:
sourceElement- the source element to associate the created element with.annotationType- the type of the created annotation reference.value- the value of the annotation reference. Can benullif the reference doesn't have any value.- Returns:
- a result representing an annotation reference to the given annotation type,
nullif sourceElement or annotationType arenull.
-
toAnnotation
@Deprecated public org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName, java.lang.Object value)Deprecated.Creates and returns an annotation reference of the given annotation type's name and the given value.- Parameters:
sourceElement- the source element to associate the created element with.annotationTypeName- the type name of the created annotation.value- the value of the annotation reference. Can benullif the reference doesn't have any value.- Returns:
- a result representing an annotation reference to the given annotation type,
nullif sourceElement or annotationType arenull.
-
cloneWithProxies
public org.eclipse.xtext.common.types.JvmTypeReference cloneWithProxies(org.eclipse.xtext.common.types.JvmTypeReference typeRef)
Creates a clone of the givenJvmTypeReferencewithout resolving any proxies. The clone will be associated with the original element by means ofassociations.- Parameters:
typeRef- the type reference to be cloned.- Returns:
- a clone of typeRef,
nullif typeRef isnullor aJvmUnknownTypeReferenceif there is a problem with the typeRef.
-
cloneWithProxies
public <T extends org.eclipse.xtext.common.types.JvmIdentifiableElement> T cloneWithProxies(T original)
Creates a clone of the givenJvmIdentifiableElementwithout resolving any proxies. The clone will be associated with the original element by means ofassociations.- Parameters:
original- the element to be cloned.- Returns:
- a clone of original associated with the original,
nullif original isnull.
-
cloneAndAssociate
protected <T extends org.eclipse.emf.ecore.EObject> T cloneAndAssociate(T original)
Creates a deep copy of the given object and associates each copied instance with the clone. Does not resolve any proxies.- Parameters:
original- the root element to be cloned.- Returns:
- a clone of tree rooted in original associated with the original,
nullif original isnull.
-
cloneAndAssociate
protected <T extends org.eclipse.xtext.common.types.JvmTypeReference> T cloneAndAssociate(T original)
Creates a deep copy of the given object and associates each copied instance with the clone. Does not resolve any proxies.- Parameters:
original- the root element to be cloned.- Returns:
- a clone of tree rooted in original associated with the original,
nullif original isnull.
-
setInitializer
public void setInitializer(org.eclipse.xtext.common.types.JvmField field, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)Attaches the given compile strategy to the givenJvmFieldsuch that the compiler knows how to initialize theJvmFieldwhen it is translated to Java source code.- Parameters:
field- the field to add the initializer to. Ifnullthis method does nothing.strategy- the compilation strategy. Ifnullthis method does nothing.
-
setInitializer
public void setInitializer(org.eclipse.xtext.common.types.JvmField field, org.eclipse.xtend2.lib.StringConcatenationClient strategy)Attaches the given compile strategy to the givenJvmFieldsuch that the compiler knows how to initialize theJvmFieldwhen it is translated to Java source code.- Parameters:
field- the field to add the initializer to. Ifnullthis method does nothing.strategy- the compilation strategy. Ifnullthis method does nothing.
-
setInitializer
public void setInitializer(org.eclipse.xtext.common.types.JvmField field, XExpression expr)Sets the givenJvmFieldas the logical container for the givenXExpression. This defines the context and the scope for the given expression.- Parameters:
field- theJvmFieldthat is initialized by the expression. Ifnullthis method does nothing.expr- the initialization expression. Can benullin which case this function does nothing.
-
setCompilationStrategy
protected void setCompilationStrategy(org.eclipse.xtext.common.types.JvmMember member, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)
-
setCompilationStrategy
protected void setCompilationStrategy(org.eclipse.xtext.common.types.JvmMember member, org.eclipse.xtend2.lib.StringConcatenationClient strategy)
-
newTypeRef
@Deprecated public org.eclipse.xtext.common.types.JvmTypeReference newTypeRef(org.eclipse.emf.ecore.EObject ctx, java.lang.Class<?> clazz, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)Deprecated.Creates a newJvmTypeReferencepointing to the given class and containing the given type arguments.- Parameters:
ctx- an EMF context, which is used to look up theJvmTypefor the given clazz.clazz- the class the type reference shall point to.typeArgs- type arguments- Returns:
- the newly created
JvmTypeReference
-
newTypeRef
@Deprecated public org.eclipse.xtext.common.types.JvmTypeReference newTypeRef(org.eclipse.emf.ecore.EObject ctx, java.lang.String typeName, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)Deprecated.Creates a newJvmTypeReferencepointing to the given class and containing the given type arguments.- Parameters:
ctx- an EMF context, which is used to look up theJvmTypefor the given clazz.typeName- the name of the type the reference shall point to.typeArgs- type arguments- Returns:
- the newly created
JvmTypeReference
-
newTypeRef
@Deprecated public org.eclipse.xtext.common.types.JvmTypeReference newTypeRef(org.eclipse.xtext.common.types.JvmType type, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)Deprecated.Creates a newJvmTypeReferencepointing to the given class and containing the given type arguments.- Parameters:
type- the type the reference shall point to.typeArgs- type arguments- Returns:
- the newly created
JvmTypeReference
-
addArrayTypeDimension
public org.eclipse.xtext.common.types.JvmTypeReference addArrayTypeDimension(org.eclipse.xtext.common.types.JvmTypeReference componentType)
- Returns:
- an array type of the given type reference. Add one dimension if the given
JvmTypeReferenceis already an array.
-
addAnnotations
public void addAnnotations(org.eclipse.xtext.common.types.JvmAnnotationTarget target, java.lang.Iterable<? extends XAnnotation> annotations)- Parameters:
target- the annotation target. Ifnullthis method does nothing.annotations- the annotations. Ifnullthis method does nothing.
-
addAnnotation
public void addAnnotation(org.eclipse.xtext.common.types.JvmAnnotationTarget target, XAnnotation annotation)Translates anXAnnotationto aJvmAnnotationReferenceand adds them to the givenJvmAnnotationTarget.- Parameters:
target- the annotation target. Ifnullthis method does nothing.annotation- the annotation. Ifnullthis method does nothing.
-
translateAnnotationsTo
@Deprecated public void translateAnnotationsTo(java.lang.Iterable<? extends XAnnotation> annotations, org.eclipse.xtext.common.types.JvmAnnotationTarget target)
Deprecated.useaddAnnotations(JvmAnnotationTarget, Iterable)instead- Parameters:
target- the annotation target. Ifnullthis method does nothing.annotations- the annotations. Ifnullthis method does nothing.
-
getJvmAnnotationReference
public org.eclipse.xtext.common.types.JvmAnnotationReference getJvmAnnotationReference(XAnnotation anno)
Translates a singleXAnnotationtoJvmAnnotationReferencethat can be added to aJvmAnnotationTarget.- Parameters:
anno- the source annotation- Returns:
- a
JvmAnnotationReferencethat can be attached to someJvmAnnotationTarget
-
toJvmAnnotationValue
public org.eclipse.xtext.common.types.JvmAnnotationValue toJvmAnnotationValue(XExpression value)
Removes the given expression from its current logical container and creates a fresh detachedJvmAnnotationValue, that needs to be put into someJvmAnnotationReference- Parameters:
value- the expression to use as annotation value- Returns:
- a
JvmAnnotationValuethat needs to be put into someJvmAnnotationReference - Since:
- 2.4
-
-