Search in sources :

Example 16 with TypeArgument

use of org.eclipse.n4js.ts.typeRefs.TypeArgument in project n4js by eclipse.

the class TypeUtils method createClassifierBoundThisTypeRef.

/**
 * from type{S} to type{this[S]}, as Part of IDE-785
 *
 * @param actualThisTypeRef
 *            must not be null, must not contain a this unbound-this-type-ref.
 */
public static TypeTypeRef createClassifierBoundThisTypeRef(TypeTypeRef actualThisTypeRef) {
    if (actualThisTypeRef == null) {
        throw new NullPointerException("Actual this type must not be null!");
    }
    TypeArgument typeArg = actualThisTypeRef.getTypeArg();
    final BoundThisTypeRef boundThisTypeRef;
    if (typeArg instanceof ParameterizedTypeRef) {
        boundThisTypeRef = createBoundThisTypeRef((ParameterizedTypeRef) typeArg);
    } else if (typeArg instanceof BoundThisTypeRef) {
        boundThisTypeRef = (BoundThisTypeRef) typeArg;
    } else {
        // invalid use
        throw new IllegalArgumentException("Cannot turn unbound type{this} into type{this[X]}, must be called with type{X}!");
    }
    TypeTypeRef classifierBoundThisTypeRef = createTypeTypeRef(boundThisTypeRef, false);
    // TODO is there anything else to copy ?
    return classifierBoundThisTypeRef;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 17 with TypeArgument

use of org.eclipse.n4js.ts.typeRefs.TypeArgument in project n4js by eclipse.

the class ParameterizedTypeRefStructuralImpl method getTypeRefAsString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getTypeRefAsString() {
    TypingStrategy _typingStrategy = this.getTypingStrategy();
    Type _declaredType = this.getDeclaredType();
    String _rawTypeAsString = null;
    if (_declaredType != null) {
        _rawTypeAsString = _declaredType.getRawTypeAsString();
    }
    String _plus = (_typingStrategy + _rawTypeAsString);
    String _xifexpression = null;
    boolean _isEmpty = this.getTypeArgs().isEmpty();
    if (_isEmpty) {
        _xifexpression = "";
    } else {
        final Function1<TypeArgument, String> _function = new Function1<TypeArgument, String>() {

            public String apply(final TypeArgument it) {
                return it.getTypeRefAsString();
            }
        };
        String _join = IterableExtensions.join(XcoreEListExtensions.<TypeArgument, String>map(this.getTypeArgs(), _function), ",");
        String _plus_1 = ("<" + _join);
        _xifexpression = (_plus_1 + ">");
    }
    String _plus_2 = (_plus + _xifexpression);
    String _xifexpression_1 = null;
    boolean _isEmpty_1 = this.getStructuralMembers().isEmpty();
    if (_isEmpty_1) {
        _xifexpression_1 = "";
    } else {
        final Function1<TStructMember, String> _function_1 = new Function1<TStructMember, String>() {

            public String apply(final TStructMember it) {
                return it.getMemberAsString();
            }
        };
        String _join_1 = IterableExtensions.join(XcoreEListExtensions.<TStructMember, String>map(this.getStructuralMembers(), _function_1), "; ");
        String _plus_3 = (" with { " + _join_1);
        String _plus_4 = (_plus_3 + " }");
        String _xifexpression_2 = null;
        boolean _isEmpty_2 = this.getPostponedSubstitutions().isEmpty();
        if (_isEmpty_2) {
            _xifexpression_2 = "";
        } else {
            final Function1<TypeVariableMapping, String> _function_2 = new Function1<TypeVariableMapping, String>() {

                public String apply(final TypeVariableMapping it) {
                    String _typeAsString = it.getTypeVar().getTypeAsString();
                    String _plus = (_typeAsString + "->");
                    String _typeRefAsString = it.getTypeArg().getTypeRefAsString();
                    return (_plus + _typeRefAsString);
                }
            };
            String _join_2 = IterableExtensions.join(XcoreEListExtensions.<TypeVariableMapping, String>map(this.getPostponedSubstitutions(), _function_2), ", ");
            String _plus_5 = (" [[" + _join_2);
            _xifexpression_2 = (_plus_5 + "]]");
        }
        _xifexpression_1 = (_plus_4 + _xifexpression_2);
    }
    return (_plus_2 + _xifexpression_1);
}
Also used : TypingStrategy(org.eclipse.n4js.ts.types.TypingStrategy) Type(org.eclipse.n4js.ts.types.Type) TStructuralType(org.eclipse.n4js.ts.types.TStructuralType) TStructMember(org.eclipse.n4js.ts.types.TStructMember) TypeVariableMapping(org.eclipse.n4js.ts.typeRefs.TypeVariableMapping) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 18 with TypeArgument

use of org.eclipse.n4js.ts.typeRefs.TypeArgument in project n4js by eclipse.

the class TypeVariableMappingImpl method basicSetTypeArg.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTypeArg(TypeArgument newTypeArg, NotificationChain msgs) {
    TypeArgument oldTypeArg = typeArg;
    typeArg = newTypeArg;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypeRefsPackage.TYPE_VARIABLE_MAPPING__TYPE_ARG, oldTypeArg, newTypeArg);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 19 with TypeArgument

use of org.eclipse.n4js.ts.typeRefs.TypeArgument in project n4js by eclipse.

the class TypeTypeRefImpl method basicSetTypeArg.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetTypeArg(TypeArgument newTypeArg, NotificationChain msgs) {
    TypeArgument oldTypeArg = typeArg;
    typeArg = newTypeArg;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypeRefsPackage.TYPE_TYPE_REF__TYPE_ARG, oldTypeArg, newTypeArg);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 20 with TypeArgument

use of org.eclipse.n4js.ts.typeRefs.TypeArgument in project n4js by eclipse.

the class TypeTypeRefImpl method getTypeRefAsString.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getTypeRefAsString() {
    String _xifexpression = null;
    boolean _isConstructorRef = this.isConstructorRef();
    if (_isConstructorRef) {
        _xifexpression = "constructor";
    } else {
        _xifexpression = "type";
    }
    final String kwd = _xifexpression;
    String _xifexpression_1 = null;
    TypeArgument _typeArg = this.getTypeArg();
    boolean _tripleEquals = (null == _typeArg);
    if (_tripleEquals) {
        _xifexpression_1 = "";
    } else {
        _xifexpression_1 = this.getTypeArg().getTypeRefAsString();
    }
    final String refName = _xifexpression_1;
    String _modifiersAsString = this.getModifiersAsString();
    return ((((kwd + "{") + refName) + "}") + _modifiersAsString);
}
Also used : TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Aggregations

TypeArgument (org.eclipse.n4js.ts.typeRefs.TypeArgument)44 ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)22 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)21 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)19 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)19 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)19 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)18 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)17 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)17 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)17 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)17 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)16 Result (org.eclipse.xsemantics.runtime.Result)16 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)15 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)15 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)15 EObject (org.eclipse.emf.ecore.EObject)14 Type (org.eclipse.n4js.ts.types.Type)14 TStructuralType (org.eclipse.n4js.ts.types.TStructuralType)13 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)12