Search in sources :

Example 11 with TypeVariable

use of org.eclipse.n4js.ts.types.TypeVariable in project n4js by eclipse.

the class FunctionTypeExpressionImpl method getTypeVars.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public EList<TypeVariable> getTypeVars() {
    EList<TypeVariable> _xifexpression = null;
    boolean _isBinding = this.isBinding();
    if (_isBinding) {
        _xifexpression = this.getUnboundTypeVars();
    } else {
        EList<TypeVariable> _xifexpression_1 = null;
        TFunction _declaredType = this.getDeclaredType();
        boolean _tripleNotEquals = (_declaredType != null);
        if (_tripleNotEquals) {
            _xifexpression_1 = this.getDeclaredType().getTypeVars();
        } else {
            _xifexpression_1 = this.getOwnedTypeVars();
        }
        _xifexpression = _xifexpression_1;
    }
    return _xifexpression;
}
Also used : TFunction(org.eclipse.n4js.ts.types.TFunction) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable)

Example 12 with TypeVariable

use of org.eclipse.n4js.ts.types.TypeVariable in project n4js by eclipse.

the class WildcardImpl method getDeclaredOrImplicitUpperBound.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public TypeRef getDeclaredOrImplicitUpperBound() {
    final TypeRef declUB = this.getDeclaredUpperBound();
    if ((declUB != null)) {
        return declUB;
    }
    TypeRef _declaredLowerBound = this.getDeclaredLowerBound();
    boolean _tripleNotEquals = (_declaredLowerBound != null);
    if (_tripleNotEquals) {
        return null;
    }
    final EObject parent = this.eContainer();
    if ((parent instanceof ParameterizedTypeRef)) {
        final int typeArgIndex = ((ParameterizedTypeRef) parent).getTypeArgs().indexOf(this);
        if ((typeArgIndex >= 0)) {
            final Object declType = ((ParameterizedTypeRef) parent).eGet(TypeRefsPackage.eINSTANCE.getParameterizedTypeRef_DeclaredType(), false);
            if ((declType instanceof ContainerType<?>)) {
                boolean _eIsProxy = ((ContainerType<?>) declType).eIsProxy();
                boolean _not = (!_eIsProxy);
                if (_not) {
                    final EList<TypeVariable> typeVars = ((ContainerType<?>) declType).getTypeVars();
                    TypeVariable _xifexpression = null;
                    int _size = typeVars.size();
                    boolean _lessThan = (typeArgIndex < _size);
                    if (_lessThan) {
                        _xifexpression = typeVars.get(typeArgIndex);
                    } else {
                        _xifexpression = null;
                    }
                    final TypeVariable typeVar = _xifexpression;
                    if ((typeVar != null)) {
                        final TypeRef implicitUB = typeVar.getDeclaredUpperBound();
                        return implicitUB;
                    }
                }
            }
        }
    }
    return null;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) ContainerType(org.eclipse.n4js.ts.types.ContainerType) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 13 with TypeVariable

use of org.eclipse.n4js.ts.types.TypeVariable in project n4js by eclipse.

the class TypeVariableMappingImpl method setTypeVar.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setTypeVar(TypeVariable newTypeVar) {
    TypeVariable oldTypeVar = typeVar;
    typeVar = newTypeVar;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, TypeRefsPackage.TYPE_VARIABLE_MAPPING__TYPE_VAR, oldTypeVar, typeVar));
}
Also used : TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 14 with TypeVariable

use of org.eclipse.n4js.ts.types.TypeVariable in project n4js by eclipse.

the class TMethodImpl method getFunctionAsString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getFunctionAsString() {
    final StringBuilder strb = new StringBuilder();
    boolean _isGeneric = this.isGeneric();
    if (_isGeneric) {
        final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {

            public String apply(final TypeVariable it) {
                return it.getTypeAsString();
            }
        };
        strb.append("<").append(IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",")).append("> ");
    }
    boolean _isDeclaredAsync = this.isDeclaredAsync();
    if (_isDeclaredAsync) {
        strb.append("async ");
    }
    final Function1<TFormalParameter, String> _function_1 = new Function1<TFormalParameter, String>() {

        public String apply(final TFormalParameter it) {
            return it.getFormalParameterAsString();
        }
    };
    strb.append(this.getName()).append("(").append(IterableExtensions.join(XcoreEListExtensions.<TFormalParameter, String>map(this.getFpars(), _function_1), ", ")).append(")");
    TypeRef _returnTypeRef = this.getReturnTypeRef();
    boolean _tripleNotEquals = (_returnTypeRef != null);
    if (_tripleNotEquals) {
        strb.append(": ").append(this.getReturnTypeRef().getTypeRefAsString());
    }
    boolean _isReturnValueOptional = this.isReturnValueOptional();
    if (_isReturnValueOptional) {
        strb.append("?");
    }
    return strb.toString();
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1)

Example 15 with TypeVariable

use of org.eclipse.n4js.ts.types.TypeVariable in project n4js by eclipse.

the class TFunctionImpl method getFunctionAsString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getFunctionAsString() {
    final StringBuilder strb = new StringBuilder();
    boolean _isGeneric = this.isGeneric();
    if (_isGeneric) {
        final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {

            public String apply(final TypeVariable it) {
                return it.getTypeAsString();
            }
        };
        strb.append("<").append(IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",")).append("> ");
    }
    boolean _isDeclaredAsync = this.isDeclaredAsync();
    if (_isDeclaredAsync) {
        strb.append("async ");
    }
    strb.append("function ");
    boolean _isDeclaredGenerator = this.isDeclaredGenerator();
    if (_isDeclaredGenerator) {
        strb.append("* ");
    }
    final Function1<TFormalParameter, String> _function_1 = new Function1<TFormalParameter, String>() {

        public String apply(final TFormalParameter it) {
            return it.getFormalParameterAsString();
        }
    };
    strb.append(this.getName()).append("(").append(IterableExtensions.join(XcoreEListExtensions.<TFormalParameter, String>map(this.getFpars(), _function_1), ", ")).append(")");
    TypeRef _returnTypeRef = this.getReturnTypeRef();
    boolean _tripleNotEquals = (_returnTypeRef != null);
    if (_tripleNotEquals) {
        strb.append(": ").append(this.getReturnTypeRef().getTypeRefAsString());
    }
    boolean _isReturnValueOptional = this.isReturnValueOptional();
    if (_isReturnValueOptional) {
        strb.append("?");
    }
    return strb.toString();
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1)

Aggregations

TypeVariable (org.eclipse.n4js.ts.types.TypeVariable)24 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)16 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)14 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)10 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)9 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)8 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)8 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)8 ContainerType (org.eclipse.n4js.ts.types.ContainerType)8 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)7 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)7 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)7 TypeArgument (org.eclipse.n4js.ts.typeRefs.TypeArgument)7 PrimitiveType (org.eclipse.n4js.ts.types.PrimitiveType)7 TFormalParameter (org.eclipse.n4js.ts.types.TFormalParameter)7 Type (org.eclipse.n4js.ts.types.Type)7 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)7 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)5 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)4 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)4