Class ParameterizedTypeReference
- java.lang.Object
-
- org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference
-
- org.eclipse.xtext.xbase.typesystem.references.ParameterizedTypeReference
-
- Direct Known Subclasses:
FunctionTypeReference
,InnerTypeReference
public class ParameterizedTypeReference extends LightweightTypeReference
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference
LightweightTypeReference.IdentifierFunction, LightweightTypeReference.JavaIdentifierFunction, LightweightTypeReference.SimpleNameFunction, LightweightTypeReference.UniqueIdentifierFunction
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
resolved
-
Fields inherited from class org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference
KIND_ANY_TYPE_REFERENCE, KIND_ARRAY_TYPE_REFERENCE, KIND_COMPOUND_TYPE_REFERENCE, KIND_FUNCTION_TYPE_REFERENCE, KIND_INNER_FUNCTION_TYPE_REFERENCE, KIND_INNER_TYPE_REFERENCE, KIND_LIGHTWEIGHT_TYPE_REFERENCE, KIND_PARAMETERIZED_TYPE_REFERENCE, KIND_UNBOUND_TYPE_REFERENCE, KIND_UNKNOWN_TYPE_REFERENCE, KIND_WILDCARD_TYPE_REFERENCE
-
-
Constructor Summary
Constructors Constructor Description ParameterizedTypeReference(ITypeReferenceOwner owner, org.eclipse.xtext.common.types.JvmType type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(TypeReferenceVisitor visitor)
<Param> void
accept(TypeReferenceVisitorWithParameter<Param> visitor, Param param)
<Param,Result>
Resultaccept(TypeReferenceVisitorWithParameterAndResult<Param,Result> visitor, Param param)
<Result> Result
accept(TypeReferenceVisitorWithResult<Result> visitor)
void
addTypeArgument(LightweightTypeReference argument)
protected void
checkStaticFlag(org.eclipse.xtext.common.types.JvmDeclaredType type)
protected void
copyTypeArguments(ParameterizedTypeReference result, ITypeReferenceOwner owner)
protected LightweightTypeReference
createRawTypeReference(org.eclipse.xtext.common.types.JvmType rawType)
protected ParameterizedTypeReference
doCopyInto(ITypeReferenceOwner owner)
FunctionTypeReference
getAsFunctionTypeReference()
Returns the equivalentFunctionTypeReference
if this reference points to afunction
orprocedure
or if it is already a function type reference.protected java.lang.String
getAsString(java.lang.String type, com.google.common.base.Function<LightweightTypeReference,java.lang.String> format)
LightweightTypeReference
getConstraintSubstitute()
Returns the constraint type of this reference.FunctionTypeKind
getFunctionTypeKind()
java.lang.String
getIdentifier()
Returns the identifier of this type reference.java.lang.String
getJavaIdentifier()
int
getKind()
Subclasses must override this method.LightweightTypeReference
getPrimitiveIfWrapperType()
org.eclipse.xtext.common.types.util.Primitives.Primitive
getPrimitiveKind()
org.eclipse.xtext.common.types.util.Primitives.Primitive
getPrimitiveKindIfWrapperType()
LightweightTypeReference
getRawSuperType(org.eclipse.xtext.common.types.JvmType rawType)
LightweightTypeReference
getRawTypeReference()
java.util.List<org.eclipse.xtext.common.types.JvmType>
getRawTypes()
java.lang.String
getSimpleName()
Prints the simple name of this type reference.LightweightTypeReference
getSuperType(java.lang.Class<?> rawType)
Returns the resolved super type for the given raw type ornull
if the raw type is not a valid super type of this type.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.protected java.util.List<LightweightTypeReference>
getSuperTypes(TypeParameterSubstitutor<?> substitutor)
org.eclipse.xtext.common.types.JvmType
getType()
java.util.List<LightweightTypeReference>
getTypeArguments()
Returns the type arguments of this reference if it has any.java.lang.String
getUniqueIdentifier()
Returns an identifier that allows to disambiguate type parameter names that have different origins.LightweightTypeReference
getWrapperTypeIfPrimitive()
boolean
isAnonymous()
protected boolean
isInner(org.eclipse.xtext.common.types.JvmType type)
boolean
isInterfaceType()
boolean
isOwnedBy(ITypeReferenceOwner owner)
boolean
isPrimitive()
boolean
isPrimitiveVoid()
boolean
isRawType()
Returnstrue
is this type points to a raw type.boolean
isResolved()
boolean
isType(java.lang.Class<?> clazz)
Returns true if this type reference represents an type with the given raw typeclazz
.protected boolean
isTypeVisible(IVisibilityHelper visibilityHelper)
boolean
isVisible(IVisibilityHelper visibilityHelper)
Returnstrue
if this type is fully visible according to the givenvisibilityHelper
.boolean
isWrapper()
ParameterizedTypeReference
toInstanceTypeReference()
Returns a projection of this type to the instance level.org.eclipse.xtext.common.types.JvmTypeReference
toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper)
Converts this type reference to aJvmTypeReference
that can be used in Java source code.org.eclipse.xtext.common.types.JvmTypeReference
toTypeReference()
ArrayTypeReference
tryConvertToArray()
Returns the array representation of this reference if its represents a subtype ofIterable
or already an array itself.FunctionTypeReference
tryConvertToFunctionTypeReference(boolean rawType)
Converts this reference to aFunctionTypeReference
if the referenced type is a SAM type.LightweightTypeReference
tryConvertToListType()
Returns the list representation of this reference if it represents an array or is already a subtype ofList
.-
Methods inherited from class org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference
collectSuperTypes, collectSuperTypes, copyInto, createSubstitutor, expose, findNonNullType, findType, getAllSuperTypes, getComponentType, getHumanReadableName, getInvariantBoundSubstitute, getLowerBoundSubstitute, getMultiTypeComponents, getNamedType, getNonInterfaceTypes, getOuter, getOwner, getServices, getSuperTypes, getTypesFactory, getUniqueIdentifier, getUpperBoundSubstitute, hasTypeArguments, internalFindTopLevelType, internalIsAssignableFrom, isAny, isArray, isAssignableFrom, isAssignableFrom, isAssignableFrom, isAssignableFrom, isFunctionType, isMultiType, isSubtypeOf, isSubtypeOf, isSynonym, isUnknown, isValidHint, isWildcard, toJavaCompliantTypeReference, toJavaCompliantTypeReference, toJavaType, toString
-
-
-
-
Constructor Detail
-
ParameterizedTypeReference
public ParameterizedTypeReference(ITypeReferenceOwner owner, org.eclipse.xtext.common.types.JvmType type)
-
-
Method Detail
-
checkStaticFlag
protected void checkStaticFlag(org.eclipse.xtext.common.types.JvmDeclaredType type)
-
getKind
public int getKind()
Subclasses must override this method.- Overrides:
getKind
in classLightweightTypeReference
-
toTypeReference
public org.eclipse.xtext.common.types.JvmTypeReference toTypeReference()
- Specified by:
toTypeReference
in classLightweightTypeReference
-
getRawTypeReference
public LightweightTypeReference getRawTypeReference()
- Overrides:
getRawTypeReference
in classLightweightTypeReference
- Returns:
- the erasure type of this type reference
-
getConstraintSubstitute
public LightweightTypeReference getConstraintSubstitute()
Description copied from class:LightweightTypeReference
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 formCharSequence & Serializable
.- Overrides:
getConstraintSubstitute
in classLightweightTypeReference
-
getRawTypes
public java.util.List<org.eclipse.xtext.common.types.JvmType> getRawTypes()
- Overrides:
getRawTypes
in classLightweightTypeReference
-
isTypeVisible
protected boolean isTypeVisible(IVisibilityHelper visibilityHelper)
-
isVisible
public boolean isVisible(IVisibilityHelper visibilityHelper)
Description copied from class:LightweightTypeReference
Returnstrue
if this type is fully visible according to the givenvisibilityHelper
. All components and bounds are taken into account, e.g.arrays
use theircomponent type
andgenerified types
check their type arguments, too.- Specified by:
isVisible
in classLightweightTypeReference
-
toJavaCompliantTypeReference
public org.eclipse.xtext.common.types.JvmTypeReference toJavaCompliantTypeReference(IVisibilityHelper visibilityHelper)
Description copied from class:LightweightTypeReference
Converts this type reference to aJvmTypeReference
that can be used in Java source code.- Specified by:
toJavaCompliantTypeReference
in classLightweightTypeReference
-
getType
public org.eclipse.xtext.common.types.JvmType getType()
- Specified by:
getType
in classLightweightTypeReference
-
isRawType
public boolean isRawType()
Description copied from class:LightweightTypeReference
Returnstrue
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.- Overrides:
isRawType
in classLightweightTypeReference
-
isOwnedBy
public boolean isOwnedBy(ITypeReferenceOwner owner)
- Overrides:
isOwnedBy
in classLightweightTypeReference
-
getWrapperTypeIfPrimitive
public LightweightTypeReference getWrapperTypeIfPrimitive()
- Overrides:
getWrapperTypeIfPrimitive
in classLightweightTypeReference
-
getPrimitiveIfWrapperType
public LightweightTypeReference getPrimitiveIfWrapperType()
- Overrides:
getPrimitiveIfWrapperType
in classLightweightTypeReference
-
isAnonymous
public boolean isAnonymous()
- Overrides:
isAnonymous
in classLightweightTypeReference
-
isPrimitive
public boolean isPrimitive()
- Overrides:
isPrimitive
in classLightweightTypeReference
-
getPrimitiveKind
public org.eclipse.xtext.common.types.util.Primitives.Primitive getPrimitiveKind()
- Overrides:
getPrimitiveKind
in classLightweightTypeReference
-
getPrimitiveKindIfWrapperType
public org.eclipse.xtext.common.types.util.Primitives.Primitive getPrimitiveKindIfWrapperType()
- Overrides:
getPrimitiveKindIfWrapperType
in classLightweightTypeReference
-
isPrimitiveVoid
public boolean isPrimitiveVoid()
- Overrides:
isPrimitiveVoid
in classLightweightTypeReference
-
isInterfaceType
public boolean isInterfaceType()
- Overrides:
isInterfaceType
in classLightweightTypeReference
-
isWrapper
public boolean isWrapper()
- Overrides:
isWrapper
in classLightweightTypeReference
-
getSuperTypes
protected java.util.List<LightweightTypeReference> getSuperTypes(TypeParameterSubstitutor<?> substitutor)
- Specified by:
getSuperTypes
in classLightweightTypeReference
-
getSuperType
public LightweightTypeReference getSuperType(java.lang.Class<?> rawType)
Description copied from class:LightweightTypeReference
Returns the resolved super type for the given raw type ornull
if the raw type is not a valid super type of this type.- Overrides:
getSuperType
in classLightweightTypeReference
- 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)
Description copied from class:LightweightTypeReference
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.- Overrides:
getSuperType
in classLightweightTypeReference
- Parameters:
rawType
- the raw type that should be resolved.- Returns:
- the resolved super type.
-
getRawSuperType
public LightweightTypeReference getRawSuperType(org.eclipse.xtext.common.types.JvmType rawType)
-
createRawTypeReference
protected LightweightTypeReference createRawTypeReference(org.eclipse.xtext.common.types.JvmType rawType)
-
isInner
protected boolean isInner(org.eclipse.xtext.common.types.JvmType type)
-
getTypeArguments
public java.util.List<LightweightTypeReference> getTypeArguments()
Description copied from class:LightweightTypeReference
Returns the type arguments of this reference if it has any. The type argument ofList<String>
isString
.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.- Overrides:
getTypeArguments
in classLightweightTypeReference
-
doCopyInto
protected ParameterizedTypeReference doCopyInto(ITypeReferenceOwner owner)
- Specified by:
doCopyInto
in classLightweightTypeReference
-
copyTypeArguments
protected void copyTypeArguments(ParameterizedTypeReference result, ITypeReferenceOwner owner)
-
isResolved
public boolean isResolved()
- Overrides:
isResolved
in classLightweightTypeReference
-
addTypeArgument
public void addTypeArgument(LightweightTypeReference argument)
-
getSimpleName
public java.lang.String getSimpleName()
Description copied from class:LightweightTypeReference
Prints the simple name of this type reference. Useful for testing.- Specified by:
getSimpleName
in classLightweightTypeReference
-
getIdentifier
public java.lang.String getIdentifier()
Description copied from class:LightweightTypeReference
Returns the identifier of this type reference. Usually the qualified name with a dollar delimiter.- Specified by:
getIdentifier
in classLightweightTypeReference
-
getUniqueIdentifier
public java.lang.String getUniqueIdentifier()
Description copied from class:LightweightTypeReference
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.- Specified by:
getUniqueIdentifier
in classLightweightTypeReference
-
getJavaIdentifier
public java.lang.String getJavaIdentifier()
- Specified by:
getJavaIdentifier
in classLightweightTypeReference
-
getAsString
protected java.lang.String getAsString(java.lang.String type, com.google.common.base.Function<LightweightTypeReference,java.lang.String> format)
-
isType
public boolean isType(java.lang.Class<?> clazz)
Description copied from class:LightweightTypeReference
Returns true if this type reference represents an type with the given raw typeclazz
. Returns false if this is not exactly the given type, but a sub type, a super type or a completely unrelated type.- Specified by:
isType
in classLightweightTypeReference
-
accept
public void accept(TypeReferenceVisitor visitor)
- Overrides:
accept
in classLightweightTypeReference
-
accept
public <Param> void accept(TypeReferenceVisitorWithParameter<Param> visitor, Param param)
- Overrides:
accept
in classLightweightTypeReference
-
accept
public <Result> Result accept(TypeReferenceVisitorWithResult<Result> visitor)
- Overrides:
accept
in classLightweightTypeReference
-
accept
public <Param,Result> Result accept(TypeReferenceVisitorWithParameterAndResult<Param,Result> visitor, Param param)
- Overrides:
accept
in classLightweightTypeReference
-
getFunctionTypeKind
public FunctionTypeKind getFunctionTypeKind()
- Overrides:
getFunctionTypeKind
in classLightweightTypeReference
-
getAsFunctionTypeReference
public FunctionTypeReference getAsFunctionTypeReference()
Returns the equivalentFunctionTypeReference
if this reference points to afunction
orprocedure
or if it is already a function type reference. Otherwise returnsnull
.- Overrides:
getAsFunctionTypeReference
in classLightweightTypeReference
- See Also:
FunctionTypes.getAsFunctionTypeReference(ParameterizedTypeReference)
-
tryConvertToFunctionTypeReference
public FunctionTypeReference tryConvertToFunctionTypeReference(boolean rawType)
Converts this reference to aFunctionTypeReference
if the referenced type is a SAM type. Returnsnull
if this reference does not point to a valid function type.- Overrides:
tryConvertToFunctionTypeReference
in classLightweightTypeReference
- Parameters:
rawType
- if a raw view on the function type is sufficient.- See Also:
FunctionTypes.tryConvertToFunctionTypeReference(ParameterizedTypeReference, boolean)
-
tryConvertToArray
public ArrayTypeReference tryConvertToArray()
Returns the array representation of this reference if its represents a subtype ofIterable
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 returnnull
if the conversion is not possible.- Overrides:
tryConvertToArray
in classLightweightTypeReference
- Returns:
- an equivalent
ArrayTypeReference
ornull
. - See Also:
ArrayTypes.tryConvertToArray(ParameterizedTypeReference)
-
tryConvertToListType
public LightweightTypeReference tryConvertToListType()
Description copied from class:LightweightTypeReference
Returns the list representation of this reference if it represents an array or is already a subtype ofList
. If the array's type is a primitive, the list's element type is the wrapper. May returnnull
if the conversion is not possible.- Overrides:
tryConvertToListType
in classLightweightTypeReference
- Returns:
- an equivalent list type or
null
.
-
toInstanceTypeReference
public ParameterizedTypeReference toInstanceTypeReference()
Returns a projection of this type to the instance level. That is, type arguments will be replaced by their invariant bounds. The instance projection ofArrayList<? extends Iterable<? extends String>>
isArrayList<Iterable<? extends String>>
since it is possible to create instances ofArrayList<Iterable<? extends String>>
.
-
-