Class LightweightTypeReference

    • Field Detail

      • KIND_LIGHTWEIGHT_TYPE_REFERENCE

        public static final int KIND_LIGHTWEIGHT_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_ANY_TYPE_REFERENCE

        public static final int KIND_ANY_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_ARRAY_TYPE_REFERENCE

        public static final int KIND_ARRAY_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_COMPOUND_TYPE_REFERENCE

        public static final int KIND_COMPOUND_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_PARAMETERIZED_TYPE_REFERENCE

        public static final int KIND_PARAMETERIZED_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_UNBOUND_TYPE_REFERENCE

        public static final int KIND_UNBOUND_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_UNKNOWN_TYPE_REFERENCE

        public static final int KIND_UNKNOWN_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_WILDCARD_TYPE_REFERENCE

        public static final int KIND_WILDCARD_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_FUNCTION_TYPE_REFERENCE

        public static final int KIND_FUNCTION_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_INNER_TYPE_REFERENCE

        public static final int KIND_INNER_TYPE_REFERENCE
        See Also:
        Constant Field Values
      • KIND_INNER_FUNCTION_TYPE_REFERENCE

        public static final int KIND_INNER_FUNCTION_TYPE_REFERENCE
        See Also:
        Constant Field Values
    • Constructor Detail

    • Method Detail

      • getKind

        public int getKind()
        Subclasses must override this method.
      • getTypeArguments

        public java.util.List<LightweightTypeReference> getTypeArguments()
        Returns the type arguments of this reference if it has any. The type argument of List<String> is String. is also the type argument of a wildcard reference with upper bound ? extends List<String>. Raw types don't carry type arguments. Wildcards with more than one upper bound don't carry type arguments.
      • hasTypeArguments

        public boolean hasTypeArguments()
      • isResolved

        public boolean isResolved()
      • getTypesFactory

        protected org.eclipse.xtext.common.types.TypesFactory getTypesFactory()
      • expose

        protected <T> java.util.List<T> expose​(java.util.List<T> list)
      • toTypeReference

        public abstract org.eclipse.xtext.common.types.JvmTypeReference toTypeReference()
      • toJavaCompliantTypeReference

        public final org.eclipse.xtext.common.types.JvmTypeReference toJavaCompliantTypeReference()
        Converts this type reference to a JvmTypeReference that can be used in Java source code.
      • isVisible

        public abstract boolean isVisible​(IVisibilityHelper visibilityHelper)
        Returns true if this type is fully visible according to the given visibilityHelper. All components and bounds are taken into account, e.g. arrays use their component type and generified types check their type arguments, too.
      • toJavaCompliantTypeReference

        public abstract org.eclipse.xtext.common.types.JvmTypeReference toJavaCompliantTypeReference​(IVisibilityHelper visibilityHelper)
        Converts this type reference to a JvmTypeReference that can be used in Java source code.
      • toJavaCompliantTypeReference

        protected org.eclipse.xtext.common.types.JvmTypeReference toJavaCompliantTypeReference​(java.util.List<LightweightTypeReference> types,
                                                                                               IVisibilityHelper visibilityHelper)
      • getType

        public abstract org.eclipse.xtext.common.types.JvmType getType()
      • getPrimitiveKind

        public org.eclipse.xtext.common.types.util.Primitives.Primitive getPrimitiveKind()
      • getPrimitiveKindIfWrapperType

        public org.eclipse.xtext.common.types.util.Primitives.Primitive getPrimitiveKindIfWrapperType()
      • getRawTypes

        public java.util.List<org.eclipse.xtext.common.types.JvmType> getRawTypes()
      • getRawTypeReference

        public LightweightTypeReference getRawTypeReference()
        Returns:
        the erasure type of this type reference
      • getUpperBoundSubstitute

        public LightweightTypeReference getUpperBoundSubstitute()
        Returns the upper bound of this reference. The upper bound of a wildcard reference is its upper constraint, e.g. ? extends CharSequence has the upper bound CharSequence.
      • getLowerBoundSubstitute

        public LightweightTypeReference getLowerBoundSubstitute()
        Returns the lower bound of this reference. The lower bound of a wildcard reference is its lower constraint, e.g. ? super CharSequence has the upper bound CharSequence.
      • getInvariantBoundSubstitute

        public LightweightTypeReference getInvariantBoundSubstitute()
        Returns the invariant bound of this reference. The invariant bound of a wildcard reference is its lower constraint, if any. Otherwise it's the upper bound.
      • getConstraintSubstitute

        public LightweightTypeReference getConstraintSubstitute()
        Returns the constraint type of this reference. The constraint of a type parameter is its declared super type. T extends CharSequence & Serializable has a compound constraint substitute of the form CharSequence & Serializable.
      • isRawType

        public boolean isRawType()
        Returns true is this type points to a raw type. That is, it points to a parameterized type but does not define type arguments or it points to an external type parameter that has a raw type constraint. Type parameters that are declared by the current owner are not considered to be raw types. A type is also a raw type if it inherits from a raw type.
      • isArray

        public boolean isArray()
      • isAny

        public boolean isAny()
      • isAnonymous

        public boolean isAnonymous()
      • isUnknown

        public boolean isUnknown()
      • tryConvertToListType

        public LightweightTypeReference tryConvertToListType()
        Returns the list representation of this reference if it represents an array or is already a subtype of List. If the array's type is a primitive, the list's element type is the wrapper. May return null if the conversion is not possible.
        Returns:
        an equivalent list type or null.
      • getComponentType

        public LightweightTypeReference getComponentType()
        Returns the component type of the current array type. Does not attempt to convert this reference from iterable to array, first.
        Returns:
        the compoent type of the current array or null.
        See Also:
        isArray()
      • getSuperTypes

        public java.util.List<LightweightTypeReference> getSuperTypes()
        Returns the list of immediate super types which includes the super class and the implemented interfaces. The type parameters of the provided super types are resolved. That means, the super type of List<String> is Collection<String> rather than Collection<E>.
        Returns:
        the list of super types, can be empty.
      • getSuperType

        public LightweightTypeReference getSuperType​(java.lang.Class<?> rawType)
        Returns the resolved super type for the given raw type or null if the raw type is not a valid super type of this type.
        Parameters:
        rawType - the raw type that should be resolved.
        Returns:
        the resolved super type.
      • getSuperType

        public LightweightTypeReference getSuperType​(org.eclipse.xtext.common.types.JvmType rawType)
        Returns the resolved super type for the given raw type or null if the raw type is not a valid super type of this type.
        Parameters:
        rawType - the raw type that should be resolved.
        Returns:
        the resolved super type.
      • getAllSuperTypes

        public java.util.List<LightweightTypeReference> getAllSuperTypes()
        Returns the list of all super types which includes the super class and the implemented interfaces. The type parameters of the provided super types are resolved. That means, the super types of ArrayList<String> includes List<String> and Collection<String> rather than Collection<E>.
        Returns:
        the list of all super types, can be empty.
      • isPrimitive

        public boolean isPrimitive()
      • isWrapper

        public boolean isWrapper()
      • isPrimitiveVoid

        public boolean isPrimitiveVoid()
      • isAssignableFrom

        public boolean isAssignableFrom​(LightweightTypeReference reference)
        Determines if this type reference denotes the same or a supertype of the given reference.
      • isAssignableFrom

        public boolean isAssignableFrom​(java.lang.Class<?> clazz)
        Determines if this type reference denotes the same type or a supertype of the given clazz.
      • isAssignableFrom

        public boolean isAssignableFrom​(org.eclipse.xtext.common.types.JvmType type)
        Determines if this type reference denotes the same type or a supertype of the given type.
      • isSubtypeOf

        public boolean isSubtypeOf​(java.lang.Class<?> clazz)
        Determines if this type reference denotes the same type or a subtype of the given clazz.
      • isSubtypeOf

        public boolean isSubtypeOf​(org.eclipse.xtext.common.types.JvmType type)
        Determines if this type reference denotes the same type or a subtype of the given type.
      • toString

        public final java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getSimpleName

        public abstract java.lang.String getSimpleName()
        Prints the simple name of this type reference. Useful for testing.
      • getHumanReadableName

        public java.lang.String getHumanReadableName()
        Prints a human readable name of this type reference. May be specialized by means of a custom implementation. This is the variant that should be used in the UI.
      • getIdentifier

        public abstract java.lang.String getIdentifier()
        Returns the identifier of this type reference. Usually the qualified name with a dollar delimiter.
      • getUniqueIdentifier

        public abstract java.lang.String getUniqueIdentifier()
        Returns an identifier that allows to disambiguate type parameter names that have different origins. Rather than just giving the name of the type parameter, it also prints the declarator.
      • getUniqueIdentifier

        protected java.lang.String getUniqueIdentifier​(org.eclipse.xtext.common.types.JvmType type)
      • getJavaIdentifier

        public abstract java.lang.String getJavaIdentifier()
      • findType

        protected org.eclipse.xtext.common.types.JvmType findType​(java.lang.Class<?> type)
      • internalFindTopLevelType

        protected LightweightTypeReference internalFindTopLevelType​(java.lang.Class<?> rawType)
        Noreference:
        This method is not intended to be referenced by clients.
      • findNonNullType

        protected org.eclipse.xtext.common.types.JvmType findNonNullType​(java.lang.Class<?> type)
      • isType

        public abstract boolean isType​(java.lang.Class<?> clazz)
        Returns true if this type reference represents an type with the given raw type clazz. Returns false if this is not exactly the given type, but a sub type, a super type or a completely unrelated type.
      • isFunctionType

        public boolean isFunctionType()
      • isInterfaceType

        public boolean isInterfaceType()
      • tryConvertToFunctionTypeReference

        public FunctionTypeReference tryConvertToFunctionTypeReference​(boolean rawType)
        Converts this reference to a FunctionTypeReference if the referenced type is a SAM type. Returns null if this reference does not point to a valid function type.
        Parameters:
        rawType - if a raw view on the function type is sufficient.
        See Also:
        getAsFunctionTypeReference()
      • tryConvertToArray

        public ArrayTypeReference tryConvertToArray()
        Returns the array representation of this reference if its represents a subtype of Iterable or already an array itself. If the iterable's type is a primitive wrapper, the array is not the primitive array but the wrapper array. May return null if the conversion is not possible.
        Returns:
        an equivalent ArrayTypeReference or null.
      • isWildcard

        public boolean isWildcard()
      • isMultiType

        public boolean isMultiType()
      • isSynonym

        public boolean isSynonym()
      • toJavaType

        public LightweightTypeReference toJavaType()
        Converts types to references that can be expressed as Java type references in source code. Any types will be expressed as Object whereas multi types will be expressed as their common super type. Unknown types are considered to be ok thus returned as is.