Search in sources :

Example 6 with TFunction

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

the class FunctionDeclarationImpl method getDefinedFunction.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public TFunction getDefinedFunction() {
    final Type defType = this.getDefinedType();
    TFunction _xifexpression = null;
    if ((defType instanceof TFunction)) {
        _xifexpression = ((TFunction) defType);
    }
    return _xifexpression;
}
Also used : Type(org.eclipse.n4js.ts.types.Type) TFunction(org.eclipse.n4js.ts.types.TFunction)

Example 7 with TFunction

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

the class FunctionTypeExpressionImpl method setDeclaredType.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setDeclaredType(TFunction newDeclaredType) {
    TFunction oldDeclaredType = declaredType;
    declaredType = newDeclaredType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, TypeRefsPackage.FUNCTION_TYPE_EXPRESSION__DECLARED_TYPE, oldDeclaredType, declaredType));
}
Also used : TFunction(org.eclipse.n4js.ts.types.TFunction) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 8 with TFunction

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

the class TFormalParameterImpl method isOptional.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean isOptional() {
    EList<TFormalParameter> _switchResult = null;
    EObject _eContainer = this.eContainer();
    boolean _matched = false;
    if (_eContainer instanceof TFunction) {
        _matched = true;
        EObject _eContainer_1 = this.eContainer();
        _switchResult = ((TFunction) _eContainer_1).getFpars();
    }
    if (!_matched) {
        if (_eContainer instanceof FunctionTypeExprOrRef) {
            _matched = true;
            EObject _eContainer_1 = this.eContainer();
            _switchResult = ((FunctionTypeExprOrRef) _eContainer_1).getFpars();
        }
    }
    if (!_matched) {
        return false;
    }
    final EList<TFormalParameter> fpars = _switchResult;
    for (int i = fpars.indexOf(this); (i >= 0); i--) {
        {
            final TFormalParameter fpar = fpars.get(i);
            if ((fpar.isVariadic() || fpar.isHasInitializerAssignment())) {
                return true;
            }
        }
    }
    return false;
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TFunction(org.eclipse.n4js.ts.types.TFunction) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) FunctionTypeExprOrRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeExprOrRef)

Example 9 with TFunction

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

the class TypeUtils method createConstructorTypeRef.

/**
 * Creates new type reference for constructor. if the declared type is TFunction a FunctionTypeRef is created. If
 * declared type is TClassifier than TypeTypeRef is created (i.e. <code>constructor{A}</code> in N4JS code)
 */
public static TypeRef createConstructorTypeRef(Type declaredType, TypeArgument... typeArgs) {
    TypeRef typeRef = null;
    if (declaredType instanceof TFunction) {
        // TODO is this correct?
        FunctionTypeRef ref = TypeRefsFactory.eINSTANCE.createFunctionTypeRef();
        ref.setDeclaredType(declaredType);
        for (TypeArgument typeArg : typeArgs) {
            ref.getTypeArgs().add(TypeUtils.copyIfContained(typeArg));
        }
        typeRef = ref;
    } else if (declaredType instanceof TClassifier) {
        TClassifier tClassifier = (TClassifier) declaredType;
        typeRef = createTypeTypeRef(createTypeRef(tClassifier, typeArgs), true);
    } else if (declaredType instanceof TypeVariable) {
        TypeVariable tTypeVar = (TypeVariable) declaredType;
        typeRef = createTypeTypeRef(createTypeRef(tTypeVar), true);
    }
    return typeRef;
}
Also used : TClassifier(org.eclipse.n4js.ts.types.TClassifier) TFunction(org.eclipse.n4js.ts.types.TFunction) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) DeferredTypeRef(org.eclipse.n4js.ts.typeRefs.DeferredTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 10 with TFunction

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

the class PropertyMethodDeclarationImpl method getDefinedFunction.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public TFunction getDefinedFunction() {
    final Type defType = this.getDefinedType();
    TFunction _xifexpression = null;
    if ((defType instanceof TFunction)) {
        _xifexpression = ((TFunction) defType);
    }
    return _xifexpression;
}
Also used : Type(org.eclipse.n4js.ts.types.Type) TFunction(org.eclipse.n4js.ts.types.TFunction)

Aggregations

TFunction (org.eclipse.n4js.ts.types.TFunction)14 Type (org.eclipse.n4js.ts.types.Type)8 EObject (org.eclipse.emf.ecore.EObject)4 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)3 TypeArgument (org.eclipse.n4js.ts.typeRefs.TypeArgument)3 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)3 ParameterizedCallExpression (org.eclipse.n4js.n4JS.ParameterizedCallExpression)2 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)2 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)2 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)2 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)2 FunctionTypeExprOrRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeExprOrRef)2 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)2 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)2 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)2 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)2 ContainerType (org.eclipse.n4js.ts.types.ContainerType)2 TVariable (org.eclipse.n4js.ts.types.TVariable)2 HashSet (java.util.HashSet)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1