Class JvmTypesBuilder


  • public class JvmTypesBuilder
    extends java.lang.Object
    A set of factory and builder functions, used to create instances of (TypesPackage). It's meant to be used from an implementation of IJvmModelInferrer.
    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
      void addAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationTarget target, XAnnotation annotation)
      Translates an XAnnotation to a JvmAnnotationReference and adds them to the given JvmAnnotationTarget.
      void addAnnotations​(org.eclipse.xtext.common.types.JvmAnnotationTarget target, java.lang.Iterable<? extends XAnnotation> annotations)
      Translates XAnnotations to JvmAnnotationReferences and adds them to the given JvmAnnotationTarget.
      org.eclipse.xtext.common.types.JvmTypeReference addArrayTypeDimension​(org.eclipse.xtext.common.types.JvmTypeReference componentType)  
      <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.
      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.
      org.eclipse.xtext.common.types.JvmTypeReference cloneWithProxies​(org.eclipse.xtext.common.types.JvmTypeReference typeRef)
      Creates a clone of the given JvmTypeReference without resolving any proxies.
      <T extends org.eclipse.xtext.common.types.JvmIdentifiableElement>
      T
      cloneWithProxies​(T original)
      Creates a clone of the given JvmIdentifiableElement without resolving any proxies.
      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.
      protected org.eclipse.xtext.common.types.JvmGenericType createJvmGenericType​(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String name)  
      java.lang.String getDocumentation​(org.eclipse.emf.ecore.EObject source)
      Retrieves the attached documentation for the given source element.
      XExpression getExpression​(org.eclipse.xtext.common.types.JvmMember member)
      Looks up and returns a logically contained expression.
      XExpression getInitializer​(org.eclipse.xtext.common.types.JvmMember member)
      Deprecated.
      org.eclipse.xtext.common.types.JvmAnnotationReference getJvmAnnotationReference​(XAnnotation anno)
      Translates a single XAnnotation to JvmAnnotationReference that can be added to a JvmAnnotationTarget.
      org.eclipse.xtext.common.types.JvmTypeReference inferredType()
      Produces an inferred type which will be resolved on demand.
      org.eclipse.xtext.common.types.JvmTypeReference inferredType​(XExpression expression)
      Produces an inferred type which will be resolved on demand.
      protected <T extends org.eclipse.emf.ecore.EObject>
      T
      initializeSafely​(T targetElement, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<? super T> initializer)  
      protected void internalSetExtension​(org.eclipse.xtext.common.types.JvmAnnotationTarget annotationTarget, org.eclipse.emf.ecore.EObject sourceElement, boolean value)  
      protected boolean isPrimitiveBoolean​(org.eclipse.xtext.common.types.JvmTypeReference typeRef)
      Detects whether the type reference refers to primitive boolean.
      protected boolean isValidSource​(org.eclipse.emf.ecore.EObject sourceElement)  
      org.eclipse.xtext.common.types.JvmTypeReference newTypeRef​(org.eclipse.emf.ecore.EObject ctx, java.lang.Class<?> clazz, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)
      org.eclipse.xtext.common.types.JvmTypeReference newTypeRef​(org.eclipse.emf.ecore.EObject ctx, java.lang.String typeName, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)
      org.eclipse.xtext.common.types.JvmTypeReference newTypeRef​(org.eclipse.xtext.common.types.JvmType type, org.eclipse.xtext.common.types.JvmTypeReference... typeArgs)
      <T> boolean operator_add​(org.eclipse.emf.common.util.EList<? super T> list, java.lang.Iterable<? extends T> elements)
      Overrides the default operator_add() to ignore null elements.
      <T> boolean operator_add​(org.eclipse.emf.common.util.EList<? super T> list, T element)
      Overrides the default operator_add() to ignore null elements.
      void removeExistingBody​(org.eclipse.xtext.common.types.JvmMember member)
      Detaches any existing bodies from the JvmMember.
      void setBody​(org.eclipse.xtext.common.types.JvmExecutable executable, org.eclipse.xtend2.lib.StringConcatenationClient strategy)
      Attaches the given compile strategy to the given JvmExecutable such that the compiler knows how to implement the JvmExecutable when it is translated to Java source code.
      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 given JvmExecutable such that the compiler knows how to implement the JvmExecutable when it is translated to Java source code.
      void setBody​(org.eclipse.xtext.common.types.JvmExecutable logicalContainer, XExpression expr)
      Sets the given JvmExecutable as the logical container for the given XExpression.
      protected void setCompilationStrategy​(org.eclipse.xtext.common.types.JvmMember member, org.eclipse.xtend2.lib.StringConcatenationClient strategy)  
      protected void setCompilationStrategy​(org.eclipse.xtext.common.types.JvmMember member, org.eclipse.xtext.xbase.lib.Procedures.Procedure1<ITreeAppendable> strategy)  
      void setDocumentation​(org.eclipse.xtext.common.types.JvmIdentifiableElement jvmElement, java.lang.String documentation)
      Attaches the given documentation to the given jvmElement.
      void setExtension​(org.eclipse.xtext.common.types.JvmField field, org.eclipse.emf.ecore.EObject sourceElement, boolean value)
      Adds or removes the annotation @Extension from the given field.
      void setExtension​(org.eclipse.xtext.common.types.JvmFormalParameter parameter, org.eclipse.emf.ecore.EObject sourceElement, boolean value)
      Adds or removes the annotation @Extension from the given parameter.
      void setFileHeader​(org.eclipse.xtext.common.types.JvmDeclaredType jvmDeclaredType, java.lang.String headerText)
      Attaches the given headText to the given JvmDeclaredType.
      void setInitializer​(org.eclipse.xtext.common.types.JvmField field, org.eclipse.xtend2.lib.StringConcatenationClient strategy)
      Attaches the given compile strategy to the given JvmField such that the compiler knows how to initialize the JvmField when it is translated to Java source code.
      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 given JvmField such that the compiler knows how to initialize the JvmField when it is translated to Java source code.
      void setInitializer​(org.eclipse.xtext.common.types.JvmField field, XExpression expr)
      Sets the given JvmField as the logical container for the given XExpression.
      protected org.eclipse.xtext.util.Pair<java.lang.String,​java.lang.String> splitQualifiedName​(java.lang.String name)  
      org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation​(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType)
      org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation​(org.eclipse.emf.ecore.EObject sourceElement, java.lang.Class<?> annotationType, java.lang.Object value)
      org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation​(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName)
      org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation​(org.eclipse.emf.ecore.EObject sourceElement, java.lang.String annotationTypeName, java.lang.Object value)
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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.
      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 as toEnumerationLiteral(EObject, String) but with an initializer passed as the last argument.
      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.
      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.
      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 :-)
      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 :-)
      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.
      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 as toField(EObject, String, JvmTypeReference) but with an initializer passed as the last argument.
      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.
      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 for toGetter(sourceElement, name, name, typeRef).
      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 :-)
      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 :-)
      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.
      org.eclipse.xtext.common.types.JvmAnnotationValue toJvmAnnotationValue​(XExpression value)
      Removes the given expression from its current logical container and creates a fresh detached JvmAnnotationValue, that needs to be put into some JvmAnnotationReference
      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.
      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.
      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.
      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 for toSetter(sourceElement, name, name, typeRef)
      org.eclipse.xtext.common.types.JvmOperation toToStringMethod​(org.eclipse.emf.ecore.EObject sourceElement, org.eclipse.xtext.common.types.JvmDeclaredType declaredType)
      Creates a toString() method accumulating the values of all fields.
      void translateAnnotationsTo​(java.lang.Iterable<? extends XAnnotation> annotations, org.eclipse.xtext.common.types.JvmAnnotationTarget target)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JvmTypesBuilder

        public JvmTypesBuilder()
    • Method Detail

      • operator_add

        public <T> boolean operator_add​(org.eclipse.emf.common.util.EList<? super T> list,
                                        T element)
        Overrides the default operator_add() to ignore null elements.
      • operator_add

        public <T> boolean operator_add​(org.eclipse.emf.common.util.EList<? super T> list,
                                        java.lang.Iterable<? extends T> elements)
        Overrides the default operator_add() to ignore null elements.
      • setBody

        public void setBody​(org.eclipse.xtext.common.types.JvmExecutable logicalContainer,
                            XExpression expr)
        Sets the given JvmExecutable as the logical container for the given XExpression. This defines the context and the scope for the given expression. Also it defines how the given JvmExecutable can be executed. For instance JvmModelGenerator automatically translates any given XExpression into corresponding Java source code as the body of the given JvmExecutable.
        Parameters:
        logicalContainer - the JvmExecutable the expression is associated with. Can be null in which case this function does nothing.
        expr - the expression. Can be null in which case this function does nothing.
      • removeExistingBody

        public void removeExistingBody​(org.eclipse.xtext.common.types.JvmMember member)
        Detaches any existing bodies from the JvmMember. A body could be a logically container XExpression or 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 null if no expression is contained.
      • 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 given JvmExecutable such that the compiler knows how to implement the JvmExecutable when it is translated to Java source code.
        Parameters:
        executable - the operation or constructor to add the method body to. If null this method does nothing.
        strategy - the compilation strategy. If null this 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 given JvmExecutable such that the compiler knows how to implement the JvmExecutable when it is translated to Java source code.
        Parameters:
        executable - the operation or constructor to add the method body to. If null this method does nothing.
        strategy - the compilation strategy. If null this 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, null if source is null or 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 given JvmDeclaredType.
      • 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 JvmGenericType representing a Java class of the given name, null if either parameter is null.
      • 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 JvmGenericType representing a Java class of the given name, null if either parameter is null.
      • 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 - the QualifiedName of the resulting class.
        initializer - the initializer to apply on the created class element. If null, the class won't be initialized.
        Returns:
        a JvmGenericType representing a Java class of the given name, null if sourceElement or name are null.
      • 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. If null, the class won't be initialized.
        Returns:
        a JvmGenericType representing a Java class of the given name, null if sourceElement or name are null.
      • 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. If null, the interface won't be initialized.
        Returns:
        a JvmGenericType representing a Java class of the given name, null if sourceElement or name are null.
      • 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 JvmAnnotationType representing a Java annotation of the given name, null if sourceElement or name are null.
      • 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. If null, the annotation won't be initialized.
        Returns:
        a JvmAnnotationType representing a Java annotation of the given name, null if sourceElement or name are null.
      • 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, null if sourceElement or name are null.
        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. If null, the enum won't be initialized.
        Returns:
        a result representing a Java enum type with the given name, null if sourceElement or name are null.
      • 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, null if sourceElement or name are null.
      • 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 as toEnumerationLiteral(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 JvmField representing 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 as toField(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 @Extension from the given field. If the annotation is already present, nothing is done if value is true. If it is not present and value is false, this is a no-op, too.
        Parameters:
        field - the field that will be processed
        sourceElement - the context that shall be used to lookup the annotation type.
        value - true if the parameter shall be marked as extension, false if 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 @Extension from the given parameter. If the annotation is already present, nothing is done if value is true. If it is not present and value is false, this is a no-op, too.
        Parameters:
        parameter - the parameter that will be processed
        sourceElement - the context that shall be used to lookup the annotation type.
        value - true if the parameter shall be marked as extension, false if 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. If null, the method won't be initialized.
        Returns:
        a result representing a Java method with the given name, null if sourceElement or name are null.
      • 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 be null.
        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 for toGetter(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, null if sourceElement or name are null.
      • 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 for toSetter(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, null if sourceElement or name are null.
      • 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, null if sourceElement or name are null.
      • 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. If null, the method won't be initialized.
        Returns:
        a result representing a Java constructor with the given name, null if sourceElement is null.
      • toToStringMethod

        public org.eclipse.xtext.common.types.JvmOperation toToStringMethod​(org.eclipse.emf.ecore.EObject sourceElement,
                                                                            org.eclipse.xtext.common.types.JvmDeclaredType declaredType)
        Creates a toString() method accumulating the values of all fields.
        Returns:
        a result representing a Java toString() method, null if sourceElement or declaredType are null.
      • 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,
                                                                                  java.lang.Object value)
        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 be null if the reference doesn't have any value.
        Returns:
        a result representing an annotation reference to the given annotation type, null if sourceElement or annotationType are null.
      • toAnnotation

        @Deprecated
        public org.eclipse.xtext.common.types.JvmAnnotationReference toAnnotation​(org.eclipse.emf.ecore.EObject sourceElement,
                                                                                  java.lang.String annotationTypeName,
                                                                                  java.lang.Object value)
        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 be null if the reference doesn't have any value.
        Returns:
        a result representing an annotation reference to the given annotation type, null if sourceElement or annotationType are null.
      • cloneWithProxies

        public org.eclipse.xtext.common.types.JvmTypeReference cloneWithProxies​(org.eclipse.xtext.common.types.JvmTypeReference typeRef)
        Creates a clone of the given JvmTypeReference without resolving any proxies. The clone will be associated with the original element by means of associations.
        Parameters:
        typeRef - the type reference to be cloned.
        Returns:
        a clone of typeRef, null if typeRef is null or a JvmUnknownTypeReference if 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 given JvmIdentifiableElement without resolving any proxies. The clone will be associated with the original element by means of associations.
        Parameters:
        original - the element to be cloned.
        Returns:
        a clone of original associated with the original, null if original is null.
      • 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, null if original is null.
      • 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, null if original is null.
      • 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 given JvmField such that the compiler knows how to initialize the JvmField when it is translated to Java source code.
        Parameters:
        field - the field to add the initializer to. If null this method does nothing.
        strategy - the compilation strategy. If null this 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 given JvmField such that the compiler knows how to initialize the JvmField when it is translated to Java source code.
        Parameters:
        field - the field to add the initializer to. If null this method does nothing.
        strategy - the compilation strategy. If null this method does nothing.
      • setInitializer

        public void setInitializer​(org.eclipse.xtext.common.types.JvmField field,
                                   XExpression expr)
        Sets the given JvmField as the logical container for the given XExpression. This defines the context and the scope for the given expression.
        Parameters:
        field - the JvmField that is initialized by the expression. If null this method does nothing.
        expr - the initialization expression. Can be null in 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)
        Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.
        Parameters:
        ctx - an EMF context, which is used to look up the JvmType for 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)
        Creates a new JvmTypeReference pointing to the given class and containing the given type arguments.
        Parameters:
        ctx - an EMF context, which is used to look up the JvmType for 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)
        Creates a new JvmTypeReference pointing 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 JvmTypeReference is already an array.
      • addAnnotations

        public void addAnnotations​(org.eclipse.xtext.common.types.JvmAnnotationTarget target,
                                   java.lang.Iterable<? extends XAnnotation> annotations)
        Translates XAnnotations to JvmAnnotationReferences and adds them to the given JvmAnnotationTarget.
        Parameters:
        target - the annotation target. If null this method does nothing.
        annotations - the annotations. If null this method does nothing.
      • addAnnotation

        public void addAnnotation​(org.eclipse.xtext.common.types.JvmAnnotationTarget target,
                                  XAnnotation annotation)
        Translates an XAnnotation to a JvmAnnotationReference and adds them to the given JvmAnnotationTarget.
        Parameters:
        target - the annotation target. If null this method does nothing.
        annotation - the annotation. If null this method does nothing.
      • translateAnnotationsTo

        @Deprecated
        public void translateAnnotationsTo​(java.lang.Iterable<? extends XAnnotation> annotations,
                                           org.eclipse.xtext.common.types.JvmAnnotationTarget target)
        Translates XAnnotations to JvmAnnotationReferences and adds them to the given JvmAnnotationTarget.
        Parameters:
        target - the annotation target. If null this method does nothing.
        annotations - the annotations. If null this method does nothing.
      • getJvmAnnotationReference

        public org.eclipse.xtext.common.types.JvmAnnotationReference getJvmAnnotationReference​(XAnnotation anno)
        Translates a single XAnnotation to JvmAnnotationReference that can be added to a JvmAnnotationTarget.
        Parameters:
        anno - the source annotation
        Returns:
        a JvmAnnotationReference that can be attached to some JvmAnnotationTarget
      • toJvmAnnotationValue

        public org.eclipse.xtext.common.types.JvmAnnotationValue toJvmAnnotationValue​(XExpression value)
        Removes the given expression from its current logical container and creates a fresh detached JvmAnnotationValue, that needs to be put into some JvmAnnotationReference
        Parameters:
        value - the expression to use as annotation value
        Returns:
        a JvmAnnotationValue that needs to be put into some JvmAnnotationReference
        Since:
        2.4