Search in sources :

Example 26 with ParameterizedTypeRef

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

the class InternalTypeSystem method applyRuleUpperBoundParameterizedTypeRef.

protected Result<TypeRef> applyRuleUpperBoundParameterizedTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ParameterizedTypeRef ptr) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    Type _declaredType = ptr.getDeclaredType();
    if ((_declaredType instanceof TypeVariable)) {
        T = ptr;
    } else {
        T = ptr;
    }
    return new Result<TypeRef>(T);
}
Also used : Type(org.eclipse.n4js.ts.types.Type) PrimitiveType(org.eclipse.n4js.ts.types.PrimitiveType) VoidType(org.eclipse.n4js.ts.types.VoidType) AnyType(org.eclipse.n4js.ts.types.AnyType) ModuleNamespaceVirtualType(org.eclipse.n4js.ts.types.ModuleNamespaceVirtualType) NullType(org.eclipse.n4js.ts.types.NullType) UndefinedType(org.eclipse.n4js.ts.types.UndefinedType) ContainerType(org.eclipse.n4js.ts.types.ContainerType) TStructuralType(org.eclipse.n4js.ts.types.TStructuralType) TypeVariable(org.eclipse.n4js.ts.types.TypeVariable) ThisTypeRef(org.eclipse.n4js.ts.typeRefs.ThisTypeRef) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) BaseTypeRef(org.eclipse.n4js.ts.typeRefs.BaseTypeRef) FunctionTypeRef(org.eclipse.n4js.ts.typeRefs.FunctionTypeRef) ExistentialTypeRef(org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef) BoundThisTypeRef(org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef) StructuralTypeRef(org.eclipse.n4js.ts.typeRefs.StructuralTypeRef) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) StaticBaseTypeRef(org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef) ComposedTypeRef(org.eclipse.n4js.ts.typeRefs.ComposedTypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult)

Example 27 with ParameterizedTypeRef

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

the class BoundThisTypeRefImpl method isDefSiteStructuralTyping.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public boolean isDefSiteStructuralTyping() {
    ParameterizedTypeRef _actualThisTypeRef = this.getActualThisTypeRef();
    if ((_actualThisTypeRef instanceof TN4Classifier)) {
        ParameterizedTypeRef _actualThisTypeRef_1 = this.getActualThisTypeRef();
        TypingStrategy _typingStrategy = ((TN4Classifier) _actualThisTypeRef_1).getTypingStrategy();
        return (_typingStrategy == TypingStrategy.STRUCTURAL);
    }
    ParameterizedTypeRef _actualThisTypeRef_2 = this.getActualThisTypeRef();
    if ((_actualThisTypeRef_2 instanceof TStructuralType)) {
        return true;
    }
    return false;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) TypingStrategy(org.eclipse.n4js.ts.types.TypingStrategy) TN4Classifier(org.eclipse.n4js.ts.types.TN4Classifier) TStructuralType(org.eclipse.n4js.ts.types.TStructuralType)

Example 28 with ParameterizedTypeRef

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

the class BoundThisTypeRefImpl method basicSetActualThisTypeRef.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetActualThisTypeRef(ParameterizedTypeRef newActualThisTypeRef, NotificationChain msgs) {
    ParameterizedTypeRef oldActualThisTypeRef = actualThisTypeRef;
    actualThisTypeRef = newActualThisTypeRef;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TypeRefsPackage.BOUND_THIS_TYPE_REF__ACTUAL_THIS_TYPE_REF, oldActualThisTypeRef, newActualThisTypeRef);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 29 with ParameterizedTypeRef

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

the class FindReferencesXpectMethod method findReferences.

/**
 * This Xpect methods compares all computed references at a given EObject to the expected references. The expected
 * references include the line number.
 */
@Xpect
@ParameterParser(syntax = "('at' arg1=OFFSET)?")
public void findReferences(@N4JSCommaSeparatedValuesExpectation IN4JSCommaSeparatedValuesExpectation expectation, IEObjectCoveringRegion offset) {
    // When you write Xpect test methods, ALWAYS retrieve eObject via IEObjectCoveringRegion to get the right
    // eObject!
    // Do NOT use EObject arg1!
    EObject context = offset.getEObject();
    EObject argEObj = offsetHelper.resolveElementAt((XtextResource) context.eResource(), offset.getOffset());
    // If not a cross-reference element, use context instead
    if (argEObj == null)
        argEObj = context;
    EObject eObj = argEObj;
    if (argEObj instanceof ParameterizedTypeRef)
        eObj = ((ParameterizedTypeRef) argEObj).getDeclaredType();
    List<EObject> refs = findReferenceHelper.findReferences(eObj);
    ArrayList<String> result = Lists.newArrayList();
    for (EObject ref : refs) {
        if (ref instanceof PropertyNameOwner)
            ref = ((PropertyNameOwner) ref).getDeclaredName();
        ICompositeNode srcNode = NodeModelUtils.getNode(ref);
        int line = srcNode.getStartLine();
        String moduleName;
        if (ref.eResource() instanceof N4JSResource) {
            N4JSResource n4jsResource = (N4JSResource) ref.eResource();
            moduleName = n4jsResource.getModule().getQualifiedName();
        } else {
            moduleName = "(unknown resource)";
        }
        String text = NodeModelUtils.getTokenText(srcNode);
        if (ref instanceof GenericDeclaration)
            text = ((GenericDeclaration) ref).getDefinedType().getName();
        String resultText = moduleName + " - " + text + " - " + line;
        result.add(resultText);
    }
    expectation.assertEquals(result);
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) PropertyNameOwner(org.eclipse.n4js.n4JS.PropertyNameOwner) EObject(org.eclipse.emf.ecore.EObject) N4JSResource(org.eclipse.n4js.resource.N4JSResource) ICompositeNode(org.eclipse.xtext.nodemodel.ICompositeNode) GenericDeclaration(org.eclipse.n4js.n4JS.GenericDeclaration) Xpect(org.eclipse.xpect.runner.Xpect) ParameterParser(org.eclipse.xpect.parameter.ParameterParser)

Example 30 with ParameterizedTypeRef

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

the class N4ClassDefinitionImpl method basicSetSuperClassRef.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetSuperClassRef(ParameterizedTypeRef newSuperClassRef, NotificationChain msgs) {
    ParameterizedTypeRef oldSuperClassRef = superClassRef;
    superClassRef = newSuperClassRef;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, N4JSPackage.N4_CLASS_DEFINITION__SUPER_CLASS_REF, oldSuperClassRef, newSuperClassRef);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Aggregations

ParameterizedTypeRef (org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef)80 TypeTypeRef (org.eclipse.n4js.ts.typeRefs.TypeTypeRef)48 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)47 BoundThisTypeRef (org.eclipse.n4js.ts.typeRefs.BoundThisTypeRef)45 ComposedTypeRef (org.eclipse.n4js.ts.typeRefs.ComposedTypeRef)44 ExistentialTypeRef (org.eclipse.n4js.ts.typeRefs.ExistentialTypeRef)44 StructuralTypeRef (org.eclipse.n4js.ts.typeRefs.StructuralTypeRef)44 BaseTypeRef (org.eclipse.n4js.ts.typeRefs.BaseTypeRef)42 FunctionTypeRef (org.eclipse.n4js.ts.typeRefs.FunctionTypeRef)42 ThisTypeRef (org.eclipse.n4js.ts.typeRefs.ThisTypeRef)42 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)42 StaticBaseTypeRef (org.eclipse.n4js.ts.typeRefs.StaticBaseTypeRef)41 RuleFailedException (org.eclipse.xsemantics.runtime.RuleFailedException)32 EObject (org.eclipse.emf.ecore.EObject)30 ErrorInformation (org.eclipse.xsemantics.runtime.ErrorInformation)23 Result (org.eclipse.xsemantics.runtime.Result)23 StructuralTypingResult (org.eclipse.n4js.typesystem.StructuralTypingResult)22 Type (org.eclipse.n4js.ts.types.Type)21 RuleApplicationTrace (org.eclipse.xsemantics.runtime.RuleApplicationTrace)21 ContainerType (org.eclipse.n4js.ts.types.ContainerType)17