Java Code Examples for org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReferenceFactory#toLightweightReference()
The following examples show how to use
org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReferenceFactory#toLightweightReference() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeferredTypeParameterHintCollector.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference getStricterConstraint(final UnboundTypeReference typeParameter, LightweightTypeReference hint) { final JvmTypeParameter parameter = typeParameter.getTypeParameter(); List<JvmTypeConstraint> constraints = parameter.getConstraints(); for(JvmTypeConstraint constraint: constraints) { JvmTypeReference constraintReference = constraint.getTypeReference(); if (constraintReference != null) { final boolean[] recursive = new boolean[] { false }; LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(hint.getOwner()) { @Override public LightweightTypeReference doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference) { JvmType type = reference.getType(); if (type == parameter) {// recursively bound recursive[0] = true; } return super.doVisitParameterizedTypeReference(reference); } }; LightweightTypeReference lightweightReference = factory.toLightweightReference(constraintReference); if (!recursive[0]) { if (hint.isAssignableFrom(lightweightReference)) { hint = lightweightReference; } else if (hint.isResolved() && !lightweightReference.getRawTypeReference().isAssignableFrom(hint, TypeConformanceComputationArgument.RAW)) { return null; } } } } return hint; }
Example 2
Source File: AbstractBuilder.java From sarl with Apache License 2.0 | 5 votes |
/** Replies if the first parameter is a subtype of the second parameter. * * @param context the context. * @param subType the subtype to test. * @param superType the expected super type. * @return the type reference. */ @Pure protected boolean isSubTypeOf(EObject context, JvmTypeReference subType, JvmTypeReference superType) { if (isTypeReference(superType) && isTypeReference(subType)) { StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, context); LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false); LightweightTypeReference reference = factory.toLightweightReference(subType); return reference.isSubtypeOf(superType.getType()); } return false; }
Example 3
Source File: Utils.java From sarl with Apache License 2.0 | 5 votes |
/** Convert a type reference to a lightweight type reference. * * @param typeRef - reference to convert. * @param services - services used for the conversion * @param keepUnboundWildcardInformation - indicates if the unbound wild card * information must be keeped in the lightweight reference. * @return the lightweight type reference. */ public static LightweightTypeReference toLightweightTypeReference( JvmTypeReference typeRef, CommonTypeComputationServices services, boolean keepUnboundWildcardInformation) { if (typeRef == null) { return null; } final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, typeRef); final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, keepUnboundWildcardInformation); final LightweightTypeReference reference = factory.toLightweightReference(typeRef); return reference; }
Example 4
Source File: Utils.java From sarl with Apache License 2.0 | 5 votes |
/** Convert a type to a lightweight type reference. * * @param type - type to convert. * @param services - services used for the conversion * @param keepUnboundWildcardInformation - indicates if the unbound wild card * information must be keeped in the lightweight reference. * @return the lightweight type reference. */ public static LightweightTypeReference toLightweightTypeReference( JvmType type, CommonTypeComputationServices services, boolean keepUnboundWildcardInformation) { if (type == null) { return null; } final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(services, type); final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, keepUnboundWildcardInformation); final LightweightTypeReference reference = factory.toLightweightReference(type); return reference; }
Example 5
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected LightweightTypeReference toLightweightTypeReference(JvmTypeReference typeRef, boolean keepUnboundWildcardInformation) { StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), typeRef); LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, keepUnboundWildcardInformation); LightweightTypeReference reference = factory.toLightweightReference(typeRef); return reference; }
Example 6
Source File: SARLValidator.java From sarl with Apache License 2.0 | 2 votes |
/** Create a lightweight type reference from the given type. * * @param type the type to point to. * @param context the context in which the reference is located. * @return the reference. */ protected LightweightTypeReference toLightweightTypeReference(JvmType type, EObject context) { final StandardTypeReferenceOwner owner = new StandardTypeReferenceOwner(getServices(), context); final LightweightTypeReferenceFactory factory = new LightweightTypeReferenceFactory(owner, false); return factory.toLightweightReference(type); }