Search in sources :

Example 1 with TFunction

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

the class InvisibleTypeOrVariableDescription method getMessage.

@Override
public String getMessage() {
    EObject objectOrProxy = getEObjectOrProxy();
    String name = getName().getLastSegment();
    if (objectOrProxy instanceof TFunction) {
        return IssueCodes.getMessageForVIS_ILLEGAL_FUN_ACCESS(name);
    } else if (objectOrProxy instanceof Type) {
        return IssueCodes.getMessageForVIS_ILLEGAL_TYPE_ACCESS(name);
    }
    return IssueCodes.getMessageForVIS_ILLEGAL_VARIABLE_ACCESS(name);
}
Also used : TFunction(org.eclipse.n4js.ts.types.TFunction) Type(org.eclipse.n4js.ts.types.Type) EObject(org.eclipse.emf.ecore.EObject)

Example 2 with TFunction

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

the class FunctionDefinitionImpl 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 3 with TFunction

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

the class TypeUtils method createTypeRef.

/**
 * Same as {@link #createTypeRef(Type, TypingStrategy, TypeArgument...)}, but will create unbounded wildcards as
 * type arguments if fewer type arguments are provided than the number of type parameters of the given declared.
 */
public static ParameterizedTypeRef createTypeRef(Type declaredType, TypingStrategy typingStrategy, boolean autoCreateTypeArgs, TypeArgument... typeArgs) {
    if (declaredType == null) {
        // avoid creating a bogus ParameterizedTypeRef with a 'declaredType' property of 'null'
        return null;
    }
    final ParameterizedTypeRef ref;
    if (declaredType instanceof TFunction) {
        ref = TypeRefsFactory.eINSTANCE.createFunctionTypeRef();
    // } else if (declaredType instanceof TStructuralType) {
    // throw new IllegalArgumentException("a TStructuralType should not be used as declared type of a TypeRef");
    } else if (typingStrategy != TypingStrategy.DEFAULT && typingStrategy != TypingStrategy.NOMINAL) {
        ref = TypeRefsFactory.eINSTANCE.createParameterizedTypeRefStructural();
    } else {
        ref = TypeRefsFactory.eINSTANCE.createParameterizedTypeRef();
    }
    ref.setDefinedTypingStrategy(typingStrategy);
    ref.setDeclaredType(declaredType);
    final EList<TypeArgument> refTypeArgs = ref.getTypeArgs();
    for (TypeArgument typeArg : typeArgs) {
        refTypeArgs.add(TypeUtils.copyIfContained(typeArg));
    }
    if (autoCreateTypeArgs) {
        final int l = declaredType.getTypeVars().size();
        for (int i = refTypeArgs.size(); i < l; i++) {
            refTypeArgs.add(createWildcard());
        }
    }
    return ref;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TFunction(org.eclipse.n4js.ts.types.TFunction) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument)

Example 4 with TFunction

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

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

the class TypeStatesAnalyser method getDeclaredStates.

private Set<String> getDeclaredStates(ControlFlowElement container, String stateName) {
    Set<String> states = new HashSet<>();
    if (container instanceof ParameterizedCallExpression) {
        ParameterizedCallExpression pce = (ParameterizedCallExpression) container;
        TFunction tFunc = (TFunction) ts.tau(pce);
        for (TAnnotation ann : tFunc.getAnnotations()) {
            if (stateName.equals(ann.getName())) {
                for (TAnnotationArgument arg : ann.getArgs()) {
                    states.add(arg.getArgAsString());
                }
            }
        }
    }
    return states;
}
Also used : TFunction(org.eclipse.n4js.ts.types.TFunction) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) TAnnotationArgument(org.eclipse.n4js.ts.types.TAnnotationArgument) HashSet(java.util.HashSet) TAnnotation(org.eclipse.n4js.ts.types.TAnnotation)

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