Search in sources :

Example 11 with TFormalParameter

use of org.eclipse.n4js.ts.types.TFormalParameter 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 12 with TFormalParameter

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

the class TSetterImpl method getMemberAsString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getMemberAsString() {
    String _name = this.getName();
    String _plus = ("set " + _name);
    String _xifexpression = null;
    boolean _isOptional = this.isOptional();
    if (_isOptional) {
        _xifexpression = "?";
    } else {
        _xifexpression = "";
    }
    String _plus_1 = (_plus + _xifexpression);
    String _plus_2 = (_plus_1 + "(");
    TFormalParameter _fpar = this.getFpar();
    String _formalParameterAsString = null;
    if (_fpar != null) {
        _formalParameterAsString = _fpar.getFormalParameterAsString();
    }
    String _plus_3 = (_plus_2 + _formalParameterAsString);
    return (_plus_3 + ")");
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter)

Example 13 with TFormalParameter

use of org.eclipse.n4js.ts.types.TFormalParameter 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 14 with TFormalParameter

use of org.eclipse.n4js.ts.types.TFormalParameter 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)

Example 15 with TFormalParameter

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

the class VersionedFunctionTypeRefImpl method getTypeRefAsString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getTypeRefAsString() {
    String _xifexpression = null;
    TypeRef _declaredThisType = this.getDeclaredThisType();
    boolean _tripleNotEquals = (_declaredThisType != null);
    if (_tripleNotEquals) {
        String _typeRefAsString = this.getDeclaredThisType().getTypeRefAsString();
        String _plus = ("@This(" + _typeRefAsString);
        _xifexpression = (_plus + ") ");
    } else {
        _xifexpression = "";
    }
    String _plus_1 = ("{" + _xifexpression);
    String _plus_2 = (_plus_1 + "function");
    String _xifexpression_1 = null;
    boolean _isGeneric = this.isGeneric();
    if (_isGeneric) {
        final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {

            public String apply(final TypeVariable it) {
                return it.getTypeVariableAsString(VersionedFunctionTypeRefImpl.this.getTypeVarUpperBound(it));
            }
        };
        String _join = IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",");
        String _plus_3 = ("<" + _join);
        _xifexpression_1 = (_plus_3 + ">");
    } else {
        _xifexpression_1 = "";
    }
    String _plus_4 = (_plus_2 + _xifexpression_1);
    String _plus_5 = (_plus_4 + "(");
    final Function1<TFormalParameter, String> _function_1 = new Function1<TFormalParameter, String>() {

        public String apply(final TFormalParameter it) {
            return it.getFormalParameterAsTypesString();
        }
    };
    String _join_1 = IterableExtensions.join(XcoreEListExtensions.<TFormalParameter, String>map(this.getFpars(), _function_1), ",");
    String _plus_6 = (_plus_5 + _join_1);
    String _plus_7 = (_plus_6 + ")");
    String _xifexpression_2 = null;
    TypeRef _returnTypeRef = this.getReturnTypeRef();
    boolean _tripleNotEquals_1 = (_returnTypeRef != null);
    if (_tripleNotEquals_1) {
        String _typeRefAsString_1 = this.getReturnTypeRef().getTypeRefAsString();
        _xifexpression_2 = (":" + _typeRefAsString_1);
    } else {
        _xifexpression_2 = "";
    }
    String _plus_8 = (_plus_7 + _xifexpression_2);
    String _xifexpression_3 = null;
    boolean _isReturnValueOptional = this.isReturnValueOptional();
    if (_isReturnValueOptional) {
        _xifexpression_3 = "?";
    } else {
        _xifexpression_3 = "";
    }
    String _plus_9 = (_plus_8 + _xifexpression_3);
    String _plus_10 = (_plus_9 + "}");
    String _modifiersAsString = this.getModifiersAsString();
    return (_plus_10 + _modifiersAsString);
}
Also used : TFormalParameter(org.eclipse.n4js.ts.types.TFormalParameter) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) VersionedFunctionTypeRef(org.eclipse.n4js.ts.typeRefs.VersionedFunctionTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1)

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