Contexts:
JvmLowerBound returns JvmLowerBound

Constraint:
typeReference=JvmTypeReference
176965
protected void sequence_JvmLowerBound(ISerializationContext context, JvmLowerBound semanticObject) {
		if (errorAcceptor != null) {
			if (transientValues.isValueTransient(semanticObject, TypesPackage.Literals.JVM_TYPE_CONSTRAINT__TYPE_REFERENCE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, TypesPackage.Literals.JVM_TYPE_CONSTRAINT__TYPE_REFERENCE));
		}
		SequenceFeeder feeder = createSequencerFeeder(context, semanticObject);
		feeder.accept(grammarAccess.getJvmLowerBoundAccess().getTypeReferenceJvmTypeReferenceParserRuleCall_1_0(), semanticObject.getTypeReference());
		feeder.finish();
	}
478366
@Override
    public Schema resolve(AnnotatedType annotatedType, ModelConverterContext context, Iterator<ModelConverter> next)
    {
        JavaType classType = TypeFactory.defaultInstance().constructType(annotatedType.getType());
        Class<?> rawClass = classType.getRawClass();
        JavaType resolvedType = classType;

        if ((rawClass != null) &&!resolvedType.isPrimitive())
        {
            // log.debug("resolvedType in " + resolvedType);
            if (rawClass.isAssignableFrom(ServerResponse.class))
            {
                resolvedType = classType.containedType(0);
            }
            else if (rawClass.isAssignableFrom(CompletableFuture.class))
            {
                Class<?> futureCls = classType.containedType(0).getRawClass();

                if (futureCls.isAssignableFrom(ServerResponse.class))
                {
                    // log.debug("class is assignable from ServerResponse");
                    final JavaType futureType = TypeFactory.defaultInstance().constructType(classType.containedType(0));

                    resolvedType = futureType.containedType(0);
                }
                else
                {
                    // log.debug("class is NOT assignable from ServerResponse");
                    resolvedType = classType.containedType(0);
                }
            }

            if (resolvedType != null)
            {
                if (resolvedType.getTypeName().contains("java.lang.Void"))
                {
                    resolvedType = TypeFactory.defaultInstance().constructFromCanonical(Void.class.getName());
                }
                else if (resolvedType.getTypeName().contains("Optional"))
                {
                    if (resolvedType.getTypeName().contains("java.nio.file.Path"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructParametricType(Optional.class, File.class);
                    }

                    if (resolvedType.getTypeName().contains("ByteBuffer"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructParametricType(Optional.class, File.class);
                    }
                }
                else
                {
                    if (resolvedType.getTypeName().contains("java.nio.file.Path"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructFromCanonical(File.class.getName());
                    }

                    if (resolvedType.getTypeName().contains("ByteBuffer"))
                    {
                        resolvedType = TypeFactory.defaultInstance().constructFromCanonical(File.class.getName());
                    }
                }

                annotatedType.setType(resolvedType);

                // log.debug("resolvedType out " + resolvedType);
            }
        }

        try {

            // log.info("Processing " + annotatedType + " " + classType + " " + annotatedType.getName());
            return super.resolve(annotatedType, context, next);

        } catch (Exception e) {

            log.error("Error processing " + annotatedType + " " + classType + " " + annotatedType.getName(), e);

            return null;
        }
    }
1105877
public JvmParameterizedTypeReference newTypeRef(Notifier context, String typeName) {
		return this.builder.newTypeRef(context, typeName);
	}
185463
@Override
	public LightweightTypeReference newReferenceTo(Class<?> type) {
		JvmType rawType = getServices().getTypeReferences().findDeclaredType(type, getContextResourceSet());
		if (rawType == null) {
			return newUnknownTypeReference(type.getName());
		}
		return toPlainTypeReference(rawType);
	}
228841
public final void ruleJvmParameterizedTypeReference() throws RecognitionException {

        		int stackSize = keepStackSize();
        	
        try {
            // InternalXbase.g:1679:2: ( ( ( rule__JvmParameterizedTypeReference__Group__0 ) ) )
            // InternalXbase.g:1680:2: ( ( rule__JvmParameterizedTypeReference__Group__0 ) )
            {
            // InternalXbase.g:1680:2: ( ( rule__JvmParameterizedTypeReference__Group__0 ) )
            // InternalXbase.g:1681:3: ( rule__JvmParameterizedTypeReference__Group__0 )
            {
            if ( state.backtracking==0 ) {
               before(grammarAccess.getJvmParameterizedTypeReferenceAccess().getGroup()); 
            }
            // InternalXbase.g:1682:3: ( rule__JvmParameterizedTypeReference__Group__0 )
            // InternalXbase.g:1682:4: rule__JvmParameterizedTypeReference__Group__0
            {
            pushFollow(FOLLOW_2);
            rule__JvmParameterizedTypeReference__Group__0();

            state._fsp--;
            if (state.failed) return ;

            }

            if ( state.backtracking==0 ) {
               after(grammarAccess.getJvmParameterizedTypeReferenceAccess().getGroup()); 
            }

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {

            	restoreStackSize(stackSize);

        }
        return ;
    }
804615
protected void appendCapacityContextAwareWrapper(SarlCapacity source, JvmGenericType inferredJvmType) {
		final JvmGenericType innerType = this.typesFactory.createJvmGenericType();
		innerType.setInterface(false);
		innerType.setAbstract(false);
		innerType.setVisibility(JvmVisibility.PUBLIC);
		innerType.setStatic(true);
		innerType.setStrictFloatingPoint(false);
		innerType.setFinal(false);
		final String innerTypeName = Capacity.ContextAwareCapacityWrapper.class.getSimpleName();
		innerType.setSimpleName(innerTypeName);

		inferredJvmType.getMembers().add(innerType);

		this.typeBuilder.setDocumentation(innerType, "@ExcludeFromApidoc"); //$NON-NLS-1$

		final JvmTypeParameter typeParameter = this.typesFactory.createJvmTypeParameter();
		typeParameter.setName("C"); //$NON-NLS-1$
		final JvmUpperBound constraint = this.typesFactory.createJvmUpperBound();
		constraint.setTypeReference(this._typeReferenceBuilder.typeRef(inferredJvmType));
		typeParameter.getConstraints().add(constraint);
		innerType.getTypeParameters().add(typeParameter);

		final Iterator<JvmTypeReference> extendedTypeIterator = inferredJvmType.getExtendedInterfaces().iterator();
		if (extendedTypeIterator.hasNext()) {
			final JvmTypeReference extendedType = extendedTypeIterator.next();
			final JvmTypeReference superType = this._typeReferenceBuilder.typeRef(
					extendedType.getQualifiedName() + "$" + innerTypeName, //$NON-NLS-1$
					this._typeReferenceBuilder.typeRef(typeParameter));
			innerType.getSuperTypes().add(superType);
		}

		innerType.getSuperTypes().add(this._typeReferenceBuilder.typeRef(inferredJvmType));

		final JvmConstructor constructor = this.typesFactory.createJvmConstructor();
		constructor.setVisibility(JvmVisibility.PUBLIC);
		innerType.getMembers().add(constructor);
		final JvmFormalParameter parameter1 = this.typesFactory.createJvmFormalParameter();
		parameter1.setName("capacity"); //$NON-NLS-1$
		parameter1.setParameterType(this._typeReferenceBuilder.typeRef(typeParameter));
		constructor.getParameters().add(parameter1);
		final JvmFormalParameter parameter2 = this.typesFactory.createJvmFormalParameter();
		parameter2.setName("caller"); //$NON-NLS-1$
		parameter2.setParameterType(this._typeReferenceBuilder.typeRef(AgentTrait.class));
		constructor.getParameters().add(parameter2);
		setBody(constructor, it -> {
			it.append("super(capacity, caller);"); //$NON-NLS-1$
		});

		final Set<ActionPrototype> createdActions = new TreeSet<>();
		for (final JvmGenericType sourceType : Iterables.concat(
				Collections.singletonList(inferredJvmType),
				Iterables.transform(Iterables.skip(inferredJvmType.getExtendedInterfaces(), 1), it -> {
					return (JvmGenericType) it.getType();
				}))) {
			copyNonStaticPublicJvmOperations(sourceType, innerType, createdActions, (operation, it) -> {
				it.append("try {"); //$NON-NLS-1$
				it.newLine();
				it.append("  ensureCallerInLocalThread();"); //$NON-NLS-1$
				it.newLine();
				it.append("  "); //$NON-NLS-1$
				if (operation.getReturnType() != null && !Objects.equal("void", operation.getReturnType().getIdentifier())) { //$NON-NLS-1$
					it.append("return "); //$NON-NLS-1$
				}
				it.append("this.capacity."); //$NON-NLS-1$
				it.append(operation.getSimpleName());
				it.append("("); //$NON-NLS-1$
				boolean first = true;
				for (final JvmFormalParameter fparam : operation.getParameters()) {
					if (first) {
						first = false;
					} else {
						it.append(", "); //$NON-NLS-1$
					}
					it.append(fparam.getName());
				}
				it.append(");"); //$NON-NLS-1$
				it.newLine();
				it.append("} finally {"); //$NON-NLS-1$
				it.newLine();
				it.append("  resetCallerInLocalThread();"); //$NON-NLS-1$
				it.newLine();
				it.append("}"); //$NON-NLS-1$
			});
		}
	}
490011
@SuppressWarnings("unchecked")
    public static <T> T getEntity(InputStream in, TypeReference<T> reference) {
        // If the entity type is an iterator then return a streaming iterator to prevent Jackson instantiating
        // the entire response in memory.
        Type type = reference.getType();
        if (type instanceof ParameterizedType &&
                Iterator.class.isAssignableFrom((Class<?>) ((ParameterizedType) type).getRawType())) {
            Type elementType = ((ParameterizedType) type).getActualTypeArguments()[0];
            return (T) streamingIterator(in, typeReferenceFrom(elementType));
        }

        // Use Jackson to deserialize the input stream.
        try {
            return JsonHelper.readJson(in, reference);
        } catch (IOException e) {
            throw Throwables.propagate(e);
        }
    }
1065440
public void addUpperConstraint(String type) {
		final JvmUpperBound constraint = this.jvmTypesFactory.createJvmUpperBound();
		constraint.setTypeReference(newTypeRef(this.context, type));
		getJvmTypeParameter().getConstraints().add(constraint);
	}
961805
function resolveType(x) {
	if (x instanceof TReference) {
		return resolveReference(x)
	} else if (x instanceof TMember) {
		return resolveReference(x)
	} else if (x instanceof TObject) {
        if (x.qname)
            return new TQualifiedReference(x.qname) // can happen if a qname was synthesized by resolveReference
		return resolveObject(x);
	} else if (x instanceof TQualifiedReference) {
		return x;
	} else if (x instanceof TTypeParam) {
		return new TTypeParam(x.name, x.constraint && resolveType(x.constraint))
	} else if (x instanceof TGeneric) {
		return new TGeneric(resolveType(x.base), x.args.map(resolveType))
	} else if (x instanceof TString) {
		return x;
	} else if (x instanceof TBuiltin) {
		return x;
	} else if (x instanceof TTypeQuery) {
        return resolveReference(x);
    } else if (x instanceof TEnum) {
        return x;
    }
	var msg;
	if (x.constructor.name === 'Object')
		msg = util.inspect(x)
	else
		msg = '' + x;
	throw new TypeError("Cannot canonicalize reference to " + (x && x.constructor.name + ': ' + msg))
}
1262477
static ReferenceTypeSignature parseClassBound(final Parser parser, final String definingClassName)
            throws ParseException {
        parser.expect(':');
        // May return null if there is no signature after ':' (class bound signature may be empty)
        return parseReferenceTypeSignature(parser, definingClassName);
    }
1084242
protected LightweightTypeReference createMapTypeReference(JvmGenericType mapType, LightweightTypeReference pairType, LightweightTypeReference expectation, ITypeReferenceOwner owner) {
		List<LightweightTypeReference> leftAndRight = pairType.getTypeArguments();
		
		LightweightTypeReference left = leftAndRight.get(0).getInvariantBoundSubstitute();
		LightweightTypeReference right = leftAndRight.get(1).getInvariantBoundSubstitute();
		
		LightweightTypeReference mapExpectation = getMapExpectation(expectation);
		if (mapExpectation != null) {
			List<LightweightTypeReference> typeArguments = expectation.getTypeArguments();
			left = doNormalizeElementType(left, typeArguments.get(0));
			right = doNormalizeElementType(right, typeArguments.get(1));
		}
		ParameterizedTypeReference result = owner.newParameterizedTypeReference(mapType);
		result.addTypeArgument(left.copyInto(owner));
		result.addTypeArgument(right.copyInto(owner));
		if (mapExpectation != null && !expectation.isAssignableFrom(result)) {
			// expectation does not match the computed type, but looks good according to the element types:
			// use expected type
			if (matchesExpectation(left, mapExpectation.getTypeArguments().get(0)) && matchesExpectation(right, mapExpectation.getTypeArguments().get(1))) {
				return expectation;
			}
		}
		return result;
	}
120102
public JvmTypeReference typeRef(JvmType type, JvmTypeReference... typeArgs) {
		int typeParams = 0;
		if (type instanceof JvmGenericType) {
			typeParams = ((JvmGenericType) type).getTypeParameters().size();
		}
		if (typeParams < typeArgs.length) {
			throw new IllegalArgumentException("The type "+type.getIdentifier()+" only declares "+typeParams+" type parameters. You passed "+typeArgs.length+".");
		}
		LightweightTypeReference reference = typeReferenceOwner.toPlainTypeReference(type);
		for (JvmTypeReference jvmTypeReference : typeArgs) {
			((ParameterizedTypeReference)reference).addTypeArgument(typeReferenceOwner.toLightweightTypeReference(jvmTypeReference));
		}
		return reference.toJavaCompliantTypeReference();
	}
334304
protected static List<JvmTypeReference> getSuperTypes(JvmTypeReference extension, List<? extends JvmTypeReference> implemented) {
		final List<JvmTypeReference> list = new ArrayList<>();
		if (extension != null) {
			list.add(extension);
		}
		if (implemented != null) {
			list.addAll(implemented);
		}
		return list;
	}
664759
public ResolvedFeatures getResolvedFeatures(JvmTypeReference contextType) {
		ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, contextType.eResource().getResourceSet());
		return getResolvedFeatures(owner.toLightweightTypeReference(contextType));
	}
810774
public final EObject entryRuleJvmLowerBoundAnded() throws RecognitionException {
        EObject current = null;

        EObject iv_ruleJvmLowerBoundAnded = null;


        try {
            // InternalXbase.g:6061:59: (iv_ruleJvmLowerBoundAnded= ruleJvmLowerBoundAnded EOF )
            // InternalXbase.g:6062:2: iv_ruleJvmLowerBoundAnded= ruleJvmLowerBoundAnded EOF
            {
            if ( state.backtracking==0 ) {
               newCompositeNode(grammarAccess.getJvmLowerBoundAndedRule()); 
            }
            pushFollow(FOLLOW_1);
            iv_ruleJvmLowerBoundAnded=ruleJvmLowerBoundAnded();

            state._fsp--;
            if (state.failed) return current;
            if ( state.backtracking==0 ) {
               current =iv_ruleJvmLowerBoundAnded; 
            }
            match(input,EOF,FOLLOW_2); if (state.failed) return current;

            }

        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
339064
public final EObject ruleJvmUpperBound() throws RecognitionException {
        EObject current = null;

        Token otherlv_0=null;
        EObject lv_typeReference_1_0 = null;



        	enterRule();

        try {
            // InternalPureXbase.g:6442:2: ( (otherlv_0= 'extends' ( (lv_typeReference_1_0= ruleJvmTypeReference ) ) ) )
            // InternalPureXbase.g:6443:2: (otherlv_0= 'extends' ( (lv_typeReference_1_0= ruleJvmTypeReference ) ) )
            {
            // InternalPureXbase.g:6443:2: (otherlv_0= 'extends' ( (lv_typeReference_1_0= ruleJvmTypeReference ) ) )
            // InternalPureXbase.g:6444:3: otherlv_0= 'extends' ( (lv_typeReference_1_0= ruleJvmTypeReference ) )
            {
            otherlv_0=(Token)match(input,82,FOLLOW_11); if (state.failed) return current;
            if ( state.backtracking==0 ) {

              			newLeafNode(otherlv_0, grammarAccess.getJvmUpperBoundAccess().getExtendsKeyword_0());
              		
            }
            // InternalPureXbase.g:6448:3: ( (lv_typeReference_1_0= ruleJvmTypeReference ) )
            // InternalPureXbase.g:6449:4: (lv_typeReference_1_0= ruleJvmTypeReference )
            {
            // InternalPureXbase.g:6449:4: (lv_typeReference_1_0= ruleJvmTypeReference )
            // InternalPureXbase.g:6450:5: lv_typeReference_1_0= ruleJvmTypeReference
            {
            if ( state.backtracking==0 ) {

              					newCompositeNode(grammarAccess.getJvmUpperBoundAccess().getTypeReferenceJvmTypeReferenceParserRuleCall_1_0());
              				
            }
            pushFollow(FOLLOW_2);
            lv_typeReference_1_0=ruleJvmTypeReference();

            state._fsp--;
            if (state.failed) return current;
            if ( state.backtracking==0 ) {

              					if (current==null) {
              						current = createModelElementForParent(grammarAccess.getJvmUpperBoundRule());
              					}
              					set(
              						current,
              						"typeReference",
              						lv_typeReference_1_0,
              						"org.eclipse.xtext.xbase.Xtype.JvmTypeReference");
              					afterParserOrEnumRuleCall();
              				
            }

            }


            }


            }


            }

            if ( state.backtracking==0 ) {

              	leaveRule();

            }
        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
117084
public final void ruleJvmLowerBoundAnded() throws RecognitionException {

        		int stackSize = keepStackSize();
        	
        try {
            // InternalXbase.g:1829:2: ( ( ( rule__JvmLowerBoundAnded__Group__0 ) ) )
            // InternalXbase.g:1830:2: ( ( rule__JvmLowerBoundAnded__Group__0 ) )
            {
            // InternalXbase.g:1830:2: ( ( rule__JvmLowerBoundAnded__Group__0 ) )
            // InternalXbase.g:1831:3: ( rule__JvmLowerBoundAnded__Group__0 )
            {
            if ( state.backtracking==0 ) {
               before(grammarAccess.getJvmLowerBoundAndedAccess().getGroup()); 
            }
            // InternalXbase.g:1832:3: ( rule__JvmLowerBoundAnded__Group__0 )
            // InternalXbase.g:1832:4: rule__JvmLowerBoundAnded__Group__0
            {
            pushFollow(FOLLOW_2);
            rule__JvmLowerBoundAnded__Group__0();

            state._fsp--;
            if (state.failed) return ;

            }

            if ( state.backtracking==0 ) {
               after(grammarAccess.getJvmLowerBoundAndedAccess().getGroup()); 
            }

            }


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {

            	restoreStackSize(stackSize);

        }
        return ;
    }