Search in sources :

Example 6 with TFormalParameter

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

the class ComposedMemberInfo method handleValidationProblems.

private void handleValidationProblems() {
    for (Pair<TMember, RuleEnvironment> pair : siblings) {
        if (pair == null)
            continue;
        TMember member = pair.getKey();
        if (member instanceof TMethod) {
            TMethod tMethod = (TMethod) member;
            for (int i = 0; i < tMethod.getFpars().size(); i++) {
                TFormalParameter currFP = tMethod.getFpars().get(i);
                if (currFP.isVariadic() && tMethod.getFpars().size() > i + 1) {
                    ComposedFParInfo currFPA = fParameters.get(i);
                    currFPA.hasValidationProblem = true;
                    return;
                }
            }
        }
    }
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TMethod(org.eclipse.n4js.ts.types.TMethod) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) TMember(org.eclipse.n4js.ts.types.TMember)

Example 7 with TFormalParameter

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

the class ComposedMemberInfo method initFParAggregate.

private void initFParAggregate(ComposedFParInfo fpAggr) {
    for (Pair<TFormalParameter, RuleEnvironment> fpPair : fpAggr.fpSiblings) {
        TFormalParameter tFpar = fpPair.getKey();
        RuleEnvironment G = fpPair.getValue();
        // handle: name
        final String nextName = tFpar.getName();
        if (nextName != null && !fpAggr.names.contains(nextName)) {
            fpAggr.names.add(nextName);
        }
        // handle: typeRef lists
        TypeRef typeRefSubst = ts.substTypeVariablesInTypeRef(G, tFpar.getTypeRef());
        if (typeRefSubst != null && !(typeRefSubst instanceof UnknownTypeRef)) {
            TypeRef typeRefCopy = TypeUtils.copyIfContained(typeRefSubst);
            fpAggr.typeRefs.add(typeRefCopy);
            if (tFpar.isVariadic()) {
                fpAggr.typeRefsVariadic.add(typeRefCopy);
            }
        }
        // handle: optional
        fpAggr.allOptional &= tFpar.isOptional();
        fpAggr.allNonOptional &= !tFpar.isOptional();
    }
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment)

Example 8 with TFormalParameter

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

the class ComposedMemberInfo method handleFParameters.

private void handleFParameters(TMember member, RuleEnvironment G) {
    EList<TFormalParameter> fpars = null;
    if (member instanceof TMethod) {
        TMethod method = (TMethod) member;
        fpars = method.getFpars();
    }
    if (member instanceof TSetter) {
        TSetter setter = (TSetter) member;
        fpars = new BasicEList<>();
        fpars.add(setter.getFpar());
    }
    if (fpars != null) {
        for (int i = 0; i < fpars.size(); i++) {
            TFormalParameter fpar = fpars.get(i);
            if (fParameters.size() <= i) {
                fParameters.add(new ComposedFParInfo());
            }
            ComposedFParInfo fpAggr = fParameters.get(i);
            Pair<TFormalParameter, RuleEnvironment> fpPair = new Pair<>(fpar, G);
            fpAggr.fpSiblings.add(fpPair);
        }
    }
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TSetter(org.eclipse.n4js.ts.types.TSetter) TMethod(org.eclipse.n4js.ts.types.TMethod) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) Pair(org.eclipse.xtext.xbase.lib.Pair)

Example 9 with TFormalParameter

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

the class TSetterImpl method getDeclaredTypeRef.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public TypeRef getDeclaredTypeRef() {
    TFormalParameter _fpar = this.getFpar();
    TypeRef _typeRef = null;
    if (_fpar != null) {
        _typeRef = _fpar.getTypeRef();
    }
    return _typeRef;
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef)

Example 10 with TFormalParameter

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

the class TSetterImpl method basicSetFpar.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetFpar(TFormalParameter newFpar, NotificationChain msgs) {
    TFormalParameter oldFpar = fpar;
    fpar = newFpar;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypesPackage.TSETTER__FPAR, oldFpar, newFpar);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

TFormalParameter (org.eclipse.n4js.ts.types.TFormalParameter)22 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)12 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)9 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)7 TypeVariable (org.eclipse.n4js.ts.types.TypeVariable)7 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)6 TMethod (org.eclipse.n4js.ts.types.TMethod)5 FunctionTypeExpression (org.eclipse.n4js.ts.typeRefs.FunctionTypeExpression)4 IntersectionTypeExpression (org.eclipse.n4js.ts.typeRefs.IntersectionTypeExpression)4 ThisTypeRefStructural (org.eclipse.n4js.ts.typeRefs.ThisTypeRefStructural)4 UnionTypeExpression (org.eclipse.n4js.ts.typeRefs.UnionTypeExpression)4 EPackage (org.eclipse.emf.ecore.EPackage)3 AdditiveExpression (org.eclipse.n4js.n4JS.AdditiveExpression)3 AssignmentExpression (org.eclipse.n4js.n4JS.AssignmentExpression)3 AwaitExpression (org.eclipse.n4js.n4JS.AwaitExpression)3 BinaryBitwiseExpression (org.eclipse.n4js.n4JS.BinaryBitwiseExpression)3 BinaryLogicalExpression (org.eclipse.n4js.n4JS.BinaryLogicalExpression)3 CastExpression (org.eclipse.n4js.n4JS.CastExpression)3 CommaExpression (org.eclipse.n4js.n4JS.CommaExpression)3 ConditionalExpression (org.eclipse.n4js.n4JS.ConditionalExpression)3