Search in sources :

Example 56 with TMember

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

the class N4JSMemberRedefinitionValidator method checkMemberRedefinitions.

/**
 * Checks constraints defined in chapter 5.4. Redefinition of Members.
 */
@Check
public void checkMemberRedefinitions(N4ClassifierDefinition n4ClassifierDefinition) {
    if (!(n4ClassifierDefinition.getDefinedType() instanceof TClassifier)) {
        // wrongly parsed
        return;
    }
    TClassifier tClassifier = (TClassifier) n4ClassifierDefinition.getDefinedType();
    getContext().put(TClassifier.class, tClassifier);
    RuleEnvironment g = RuleEnvironmentExtensions.newRuleEnvironment(tClassifier);
    getContext().put(RuleEnvironment.class, g);
    // the context for type variables
    ParameterizedTypeRef classTypeRef = TypeUtils.createTypeRef(tClassifier);
    getContext().put(TYPE_VAR_CONTEXT, classTypeRef);
    MemberCube memberCube = createMemberValidationList();
    final boolean isClass = tClassifier instanceof TClass;
    final Map<ParameterizedTypeRef, MemberList<TMember>> nonAccessibleAbstractMembersBySuperTypeRef = new HashMap<>();
    for (Entry<NameStaticPair, MemberMatrix> entry : memberCube.entrySet()) {
        MemberMatrix mm = entry.getValue();
        // Set to collect all owned members that are lacking an override annotation.
        Collection<TMember> membersMissingOverrideAnnotation = new HashSet<>();
        if (isClass) {
            constraints_67_MemberOverride_checkEntry(mm, membersMissingOverrideAnnotation);
        }
        if (mm.hasImplemented()) {
            // first mix in
            if (holdConstraints_68_Consumption(mm)) {
                // then check if everything is implemented
                constraints_69_Implementation(mm, membersMissingOverrideAnnotation);
            }
        }
        constraints_60_InheritedConsumedCovariantSpecConstructor(tClassifier, mm);
        constraints_66_NonOverride(mm);
        constraints_42_45_46_AbstractMember(mm, nonAccessibleAbstractMembersBySuperTypeRef);
        unusedGenericTypeVariable(mm);
        checkUnpairedAccessorConsumption(mm, n4ClassifierDefinition);
        checkUnpairedAccessorFilling(mm, n4ClassifierDefinition);
        messageMissingOverrideAnnotation(mm, membersMissingOverrideAnnotation);
    }
    final boolean foundImpossibleExtendsImplements = !nonAccessibleAbstractMembersBySuperTypeRef.isEmpty();
    if (foundImpossibleExtendsImplements) {
        messageImpossibleExtendsImplements(n4ClassifierDefinition, nonAccessibleAbstractMembersBySuperTypeRef);
    }
    if (!foundImpossibleExtendsImplements) {
        // avoid consequential errors
        constraints_41_AbstractClass(tClassifier, memberCube);
    }
}
Also used : TClassifier(org.eclipse.n4js.ts.types.TClassifier) NameStaticPair(org.eclipse.n4js.ts.types.util.NameStaticPair) MemberList(org.eclipse.n4js.ts.types.util.MemberList) HashMap(java.util.HashMap) MemberMatrix(org.eclipse.n4js.validation.validators.utils.MemberMatrix) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) MemberCube(org.eclipse.n4js.validation.validators.utils.MemberCube) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) TMember(org.eclipse.n4js.ts.types.TMember) TClass(org.eclipse.n4js.ts.types.TClass) HashSet(java.util.HashSet) Check(org.eclipse.xtext.validation.Check)

Example 57 with TMember

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

the class N4JSMemberRedefinitionValidator method holdConstraints_68_Consumption.

/**
 * Constraints 68: Consumption of Interface Members
 *
 * Returns false if an error occurred which is not solvable in current classifier (i.e., incompatible meta types).
 */
private boolean holdConstraints_68_Consumption(MemberMatrix mm) {
    TClassifier currentType = getCurrentClassifier();
    MemberList<TMember> consumedMembers = new MemberList<>(2);
    for (TMember m : mm.implemented()) {
        boolean consume = true;
        for (SourceAwareIterator iter = mm.allMembers(); iter.hasNext(); ) {
            TMember m_ = iter.next();
            if (m_ == m && iter.isInterfaceMember()) {
                // again. Thus, we only consume if both members stem from interfaces
                continue;
            }
            // 1. meta type
            if ((m.isMethod() && !m_.isMethod()) || (!m.isMethod() && !(m_.isAccessor() || m_.isField()))) {
                if (iter.isInterfaceMember()) {
                    messageIncompatibleMembersToImplement(mm.implemented());
                    return false;
                } else if (iter.isInheritedMember()) {
                    messageIncompatibleInheritedMembersToImplement(m_, mm.implemented());
                    return false;
                } else {
                    return true;
                }
            }
            // 2 (abstract/owned), 3 (visibility) and 4 (type):
            boolean accessorPair = TypeUtils.isAccessorPair(m, m_);
            if (!accessorPair) {
                // 2. not abstract or owned
                if ((!m_.isAbstract() || m_.getContainingType() == currentType)) {
                    consume = false;
                    break;
                }
                // 3. access modifier
                if (AccessModifiers.less(m, m_)) {
                    consume = false;
                    break;
                }
                // 4. type
                if (!m_.isSetter()) {
                    if (!isSubType(m, m_)) {
                        consume = false;
                        break;
                    }
                }
                if (m_.isSetter() || m_.isField()) {
                    if (!isSubType(m_, m)) {
                        consume = false;
                        break;
                    }
                }
            }
        }
        if (consume) {
            if (!consumedMembers.contains(m)) {
                // in case an interface is (indirectly) redundantly implemented
                consumedMembers.add(m);
            }
        }
    }
    mm.markConsumed(consumedMembers);
    return true;
}
Also used : TClassifier(org.eclipse.n4js.ts.types.TClassifier) MemberList(org.eclipse.n4js.ts.types.util.MemberList) SourceAwareIterator(org.eclipse.n4js.validation.validators.utils.MemberMatrix.SourceAwareIterator) TMember(org.eclipse.n4js.ts.types.TMember)

Example 58 with TMember

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

the class InternalTypeSystem method applyRuleTypeIndexedAccessExpression.

protected Result<TypeRef> applyRuleTypeIndexedAccessExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final IndexedAccessExpression expr) throws RuleFailedException {
    // output parameter
    TypeRef T = null;
    /* { expr.target === null || expr.index === null; T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } or { expr.target instanceof SuperLiteral T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } or { G |- expr.target : var TypeRef targetTypeRef targetTypeRef = typeSystemHelper.resolveType(G, targetTypeRef); G |- expr.index : var TypeRef indexTypeRef; val targetDeclType = targetTypeRef.declaredType; val targetIsLiteralOfStringBasedEnum = targetDeclType instanceof TEnum && AnnotationDefinition.STRING_BASED.hasAnnotation(targetDeclType); val indexIsNumeric = { G |- indexTypeRef <: G.numberTypeRef }; val indexValue = ASTMetaInfoUtils.getCompileTimeValue(expr.index); val memberName = N4JSLanguageUtils.derivePropertyNameFromCompileTimeValue(indexValue); if (indexIsNumeric && (targetTypeRef.isArrayLike || targetIsLiteralOfStringBasedEnum)) { if (targetDeclType.generic && targetTypeRef.typeArgs.isEmpty) { T = G.anyTypeRef } else { val G2 = G.wrap typeSystemHelper.addSubstitutions(G2, targetTypeRef) G2.addThisType(targetTypeRef) val elementTypeRef = if(targetIsLiteralOfStringBasedEnum) { G.stringType.elementType } else { targetDeclType.elementType }; G2 |- elementTypeRef ~> T } } else if (memberName!==null) { val staticAccess = (targetTypeRef instanceof TypeTypeRef) val checkVisibility = false val scope = memberScopingHelper.createMemberScope(targetTypeRef, expr, checkVisibility, staticAccess) val memberDesc = if(memberName!==null && !memberName.isEmpty()) { scope.getSingleElement(qualifiedNameConverter.toQualifiedName(memberName)) }; val member = if(memberDesc!==null && !IEObjectDescriptionWithError.isErrorDescription(memberDesc)) { memberDesc.getEObjectOrProxy() }; if(member instanceof TMember && !member.eIsProxy) { G |- (member as TMember) : var TypeRef memberTypeRef val G2 = G.wrap typeSystemHelper.addSubstitutions(G2,targetTypeRef) G2.addThisType(targetTypeRef) G2 |- memberTypeRef ~> T } else if (targetTypeRef.dynamic) { T = G.anyTypeRefDynamic } else { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } } else if (targetTypeRef.dynamic) { T = G.anyTypeRefDynamic } else { T = G.anyTypeRef } } */
    {
        RuleFailedException previousFailure = null;
        try {
            /* expr.target === null || expr.index === null */
            if (!((expr.getTarget() == null) || (expr.getIndex() == null))) {
                sneakyThrowRuleFailedException("expr.target === null || expr.index === null");
            }
            T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
        } catch (Exception e) {
            previousFailure = extractRuleFailedException(e);
            /* { expr.target instanceof SuperLiteral T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } or { G |- expr.target : var TypeRef targetTypeRef targetTypeRef = typeSystemHelper.resolveType(G, targetTypeRef); G |- expr.index : var TypeRef indexTypeRef; val targetDeclType = targetTypeRef.declaredType; val targetIsLiteralOfStringBasedEnum = targetDeclType instanceof TEnum && AnnotationDefinition.STRING_BASED.hasAnnotation(targetDeclType); val indexIsNumeric = { G |- indexTypeRef <: G.numberTypeRef }; val indexValue = ASTMetaInfoUtils.getCompileTimeValue(expr.index); val memberName = N4JSLanguageUtils.derivePropertyNameFromCompileTimeValue(indexValue); if (indexIsNumeric && (targetTypeRef.isArrayLike || targetIsLiteralOfStringBasedEnum)) { if (targetDeclType.generic && targetTypeRef.typeArgs.isEmpty) { T = G.anyTypeRef } else { val G2 = G.wrap typeSystemHelper.addSubstitutions(G2, targetTypeRef) G2.addThisType(targetTypeRef) val elementTypeRef = if(targetIsLiteralOfStringBasedEnum) { G.stringType.elementType } else { targetDeclType.elementType }; G2 |- elementTypeRef ~> T } } else if (memberName!==null) { val staticAccess = (targetTypeRef instanceof TypeTypeRef) val checkVisibility = false val scope = memberScopingHelper.createMemberScope(targetTypeRef, expr, checkVisibility, staticAccess) val memberDesc = if(memberName!==null && !memberName.isEmpty()) { scope.getSingleElement(qualifiedNameConverter.toQualifiedName(memberName)) }; val member = if(memberDesc!==null && !IEObjectDescriptionWithError.isErrorDescription(memberDesc)) { memberDesc.getEObjectOrProxy() }; if(member instanceof TMember && !member.eIsProxy) { G |- (member as TMember) : var TypeRef memberTypeRef val G2 = G.wrap typeSystemHelper.addSubstitutions(G2,targetTypeRef) G2.addThisType(targetTypeRef) G2 |- memberTypeRef ~> T } else if (targetTypeRef.dynamic) { T = G.anyTypeRefDynamic } else { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } } else if (targetTypeRef.dynamic) { T = G.anyTypeRefDynamic } else { T = G.anyTypeRef } } */
            {
                try {
                    Expression _target = expr.getTarget();
                    /* expr.target instanceof SuperLiteral */
                    if (!(_target instanceof SuperLiteral)) {
                        sneakyThrowRuleFailedException("expr.target instanceof SuperLiteral");
                    }
                    T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
                } catch (Exception e_1) {
                    previousFailure = extractRuleFailedException(e_1);
                    /* G |- expr.target : var TypeRef targetTypeRef */
                    Expression _target_1 = expr.getTarget();
                    TypeRef targetTypeRef = null;
                    Result<TypeRef> result = typeInternal(G, _trace_, _target_1);
                    checkAssignableTo(result.getFirst(), TypeRef.class);
                    targetTypeRef = (TypeRef) result.getFirst();
                    targetTypeRef = this.typeSystemHelper.resolveType(G, targetTypeRef);
                    /* G |- expr.index : var TypeRef indexTypeRef */
                    Expression _index = expr.getIndex();
                    TypeRef indexTypeRef = null;
                    Result<TypeRef> result_1 = typeInternal(G, _trace_, _index);
                    checkAssignableTo(result_1.getFirst(), TypeRef.class);
                    indexTypeRef = (TypeRef) result_1.getFirst();
                    final Type targetDeclType = targetTypeRef.getDeclaredType();
                    final boolean targetIsLiteralOfStringBasedEnum = ((targetDeclType instanceof TEnum) && AnnotationDefinition.STRING_BASED.hasAnnotation(targetDeclType));
                    /* G |- indexTypeRef <: G.numberTypeRef */
                    ParameterizedTypeRef _numberTypeRef = RuleEnvironmentExtensions.numberTypeRef(G);
                    boolean _ruleinvocation = subtypeSucceeded(G, _trace_, indexTypeRef, _numberTypeRef);
                    final boolean indexIsNumeric = _ruleinvocation;
                    final CompileTimeValue indexValue = ASTMetaInfoUtils.getCompileTimeValue(expr.getIndex());
                    final String memberName = N4JSLanguageUtils.derivePropertyNameFromCompileTimeValue(indexValue);
                    if ((indexIsNumeric && (targetTypeRef.isArrayLike() || targetIsLiteralOfStringBasedEnum))) {
                        if ((targetDeclType.isGeneric() && targetTypeRef.getTypeArgs().isEmpty())) {
                            T = RuleEnvironmentExtensions.anyTypeRef(G);
                        } else {
                            final RuleEnvironment G2 = RuleEnvironmentExtensions.wrap(G);
                            this.typeSystemHelper.addSubstitutions(G2, targetTypeRef);
                            RuleEnvironmentExtensions.addThisType(G2, targetTypeRef);
                            TypeRef _xifexpression = null;
                            if (targetIsLiteralOfStringBasedEnum) {
                                _xifexpression = RuleEnvironmentExtensions.stringType(G).getElementType();
                            } else {
                                _xifexpression = targetDeclType.getElementType();
                            }
                            final TypeRef elementTypeRef = _xifexpression;
                            /* G2 |- elementTypeRef ~> T */
                            Result<TypeArgument> result_2 = substTypeVariablesInternal(G2, _trace_, elementTypeRef);
                            checkAssignableTo(result_2.getFirst(), TypeRef.class);
                            T = (TypeRef) result_2.getFirst();
                        }
                    } else {
                        if ((memberName != null)) {
                            final boolean staticAccess = (targetTypeRef instanceof TypeTypeRef);
                            final boolean checkVisibility = false;
                            final IScope scope = this.memberScopingHelper.createMemberScope(targetTypeRef, expr, checkVisibility, staticAccess);
                            IEObjectDescription _xifexpression_1 = null;
                            if (((memberName != null) && (!memberName.isEmpty()))) {
                                _xifexpression_1 = scope.getSingleElement(this.qualifiedNameConverter.toQualifiedName(memberName));
                            }
                            final IEObjectDescription memberDesc = _xifexpression_1;
                            EObject _xifexpression_2 = null;
                            if (((memberDesc != null) && (!IEObjectDescriptionWithError.isErrorDescription(memberDesc)))) {
                                _xifexpression_2 = memberDesc.getEObjectOrProxy();
                            }
                            final EObject member = _xifexpression_2;
                            if (((member instanceof TMember) && (!member.eIsProxy()))) {
                                /* G |- (member as TMember) : var TypeRef memberTypeRef */
                                TypeRef memberTypeRef = null;
                                Result<TypeRef> result_3 = typeInternal(G, _trace_, ((TMember) member));
                                checkAssignableTo(result_3.getFirst(), TypeRef.class);
                                memberTypeRef = (TypeRef) result_3.getFirst();
                                final RuleEnvironment G2_1 = RuleEnvironmentExtensions.wrap(G);
                                this.typeSystemHelper.addSubstitutions(G2_1, targetTypeRef);
                                RuleEnvironmentExtensions.addThisType(G2_1, targetTypeRef);
                                /* G2 |- memberTypeRef ~> T */
                                Result<TypeArgument> result_4 = substTypeVariablesInternal(G2_1, _trace_, memberTypeRef);
                                checkAssignableTo(result_4.getFirst(), TypeRef.class);
                                T = (TypeRef) result_4.getFirst();
                            } else {
                                boolean _isDynamic = targetTypeRef.isDynamic();
                                if (_isDynamic) {
                                    T = RuleEnvironmentExtensions.anyTypeRefDynamic(G);
                                } else {
                                    T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
                                }
                            }
                        } else {
                            boolean _isDynamic_1 = targetTypeRef.isDynamic();
                            if (_isDynamic_1) {
                                T = RuleEnvironmentExtensions.anyTypeRefDynamic(G);
                            } else {
                                T = RuleEnvironmentExtensions.anyTypeRef(G);
                            }
                        }
                    }
                }
            }
        }
    }
    return new Result<TypeRef>(T);
}
Also used : 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) SuperLiteral(org.eclipse.n4js.n4JS.SuperLiteral) TypeArgument(org.eclipse.n4js.ts.typeRefs.TypeArgument) TaggedTemplateString(org.eclipse.n4js.n4JS.TaggedTemplateString) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException) CompileTimeValue(org.eclipse.n4js.compileTime.CompileTimeValue) RuleFailedException(org.eclipse.xsemantics.runtime.RuleFailedException) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Result(org.eclipse.xsemantics.runtime.Result) StructuralTypingResult(org.eclipse.n4js.typesystem.StructuralTypingResult) ParameterizedTypeRef(org.eclipse.n4js.ts.typeRefs.ParameterizedTypeRef) 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) BinaryBitwiseExpression(org.eclipse.n4js.n4JS.BinaryBitwiseExpression) AssignmentExpression(org.eclipse.n4js.n4JS.AssignmentExpression) IndexedAccessExpression(org.eclipse.n4js.n4JS.IndexedAccessExpression) UnionTypeExpression(org.eclipse.n4js.ts.typeRefs.UnionTypeExpression) FunctionExpression(org.eclipse.n4js.n4JS.FunctionExpression) PromisifyExpression(org.eclipse.n4js.n4JS.PromisifyExpression) UnaryExpression(org.eclipse.n4js.n4JS.UnaryExpression) ParenExpression(org.eclipse.n4js.n4JS.ParenExpression) ParameterizedCallExpression(org.eclipse.n4js.n4JS.ParameterizedCallExpression) AdditiveExpression(org.eclipse.n4js.n4JS.AdditiveExpression) PostfixExpression(org.eclipse.n4js.n4JS.PostfixExpression) YieldExpression(org.eclipse.n4js.n4JS.YieldExpression) ConditionalExpression(org.eclipse.n4js.n4JS.ConditionalExpression) FunctionTypeExpression(org.eclipse.n4js.ts.typeRefs.FunctionTypeExpression) RelationalExpression(org.eclipse.n4js.n4JS.RelationalExpression) NewExpression(org.eclipse.n4js.n4JS.NewExpression) IntersectionTypeExpression(org.eclipse.n4js.ts.typeRefs.IntersectionTypeExpression) AwaitExpression(org.eclipse.n4js.n4JS.AwaitExpression) CommaExpression(org.eclipse.n4js.n4JS.CommaExpression) Expression(org.eclipse.n4js.n4JS.Expression) CastExpression(org.eclipse.n4js.n4JS.CastExpression) BinaryLogicalExpression(org.eclipse.n4js.n4JS.BinaryLogicalExpression) EqualityExpression(org.eclipse.n4js.n4JS.EqualityExpression) ShiftExpression(org.eclipse.n4js.n4JS.ShiftExpression) ParameterizedPropertyAccessExpression(org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression) MultiplicativeExpression(org.eclipse.n4js.n4JS.MultiplicativeExpression) N4ClassExpression(org.eclipse.n4js.n4JS.N4ClassExpression) TEnum(org.eclipse.n4js.ts.types.TEnum) EObject(org.eclipse.emf.ecore.EObject) TypeTypeRef(org.eclipse.n4js.ts.typeRefs.TypeTypeRef) IScope(org.eclipse.xtext.scoping.IScope) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) TMember(org.eclipse.n4js.ts.types.TMember)

Example 59 with TMember

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

the class Reducer method reduceStructuralTypeRef.

private boolean reduceStructuralTypeRef(TypeRef left, TypeRef right, Variance variance) {
    if (variance == CONTRA) {
        return reduceStructuralTypeRef(right, left, CO);
    }
    // now, variance is either CO or INV
    final StructuralTypingComputer stc = tsh.getStructuralTypingComputer();
    final RuleEnvironment G2 = RuleEnvironmentExtensions.wrap(G);
    final StructTypingInfo infoFaked = new // <- G2 will be changed!
    StructTypingInfo(// <- G2 will be changed!
    G2, // <- G2 will be changed!
    left, // <- G2 will be changed!
    right, left.getTypingStrategy(), right.getTypingStrategy());
    boolean wasAdded = false;
    final StructuralTypesHelper structTypesHelper = tsh.getStructuralTypesHelper();
    final StructuralMembersTripleIterator iter = structTypesHelper.getMembersTripleIterator(G2, left, right, false);
    while (iter.hasNext()) {
        final StructuralMembersTriple next = iter.next();
        final TMember l = next.getLeft();
        final TMember r = next.getRight();
        if (l == null || r == null) {
            // commencing with type inference here produces better error messages.)
            continue;
        }
        final TypeConstraint constraint = stc.reduceMembers(left, l, r, variance, infoFaked);
        if (containsReopenedExistentialType(G2, constraint)) {
            // TODO reconsider handling of re-opened ExistentialTypeRefs in InferenceContext, IDE-1653
            continue;
        }
        wasAdded |= reduce(constraint);
    }
    return wasAdded;
}
Also used : StructuralTypesHelper(org.eclipse.n4js.utils.StructuralTypesHelper) StructuralMembersTriple(org.eclipse.n4js.utils.StructuralMembersTriple) StructuralTypingComputer(org.eclipse.n4js.typesystem.StructuralTypingComputer) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) TMember(org.eclipse.n4js.ts.types.TMember) StructTypingInfo(org.eclipse.n4js.typesystem.StructuralTypingComputer.StructTypingInfo) StructuralMembersTripleIterator(org.eclipse.n4js.utils.StructuralMembersTripleIterator)

Example 60 with TMember

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

the class FindReferenceHelper method getTargets.

private TargetURIs getTargets(EObject declaration) {
    // Special handling for composed members
    List<EObject> realTargets = new ArrayList<>();
    if ((declaration instanceof TMember) && ((TMember) declaration).isComposed()) {
        // In case of composed member, add the constituent members instead.
        List<TMember> constituentMembers = ((TMember) declaration).getConstituentMembers();
        for (TMember constituentMember : constituentMembers) {
            realTargets.add(constituentMember);
        }
    } else {
        // Standard case
        realTargets.add(declaration);
    }
    TargetURIs targets = targetURISetProvider.get();
    for (EObject realTarget : realTargets) {
        collector.add(realTarget, targets);
    }
    return targets;
}
Also used : EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) TargetURIs(org.eclipse.xtext.findReferences.TargetURIs) TMember(org.eclipse.n4js.ts.types.TMember)

Aggregations

TMember (org.eclipse.n4js.ts.types.TMember)65 EObject (org.eclipse.emf.ecore.EObject)19 TClassifier (org.eclipse.n4js.ts.types.TClassifier)13 Type (org.eclipse.n4js.ts.types.Type)13 ContainerType (org.eclipse.n4js.ts.types.ContainerType)11 ArrayList (java.util.ArrayList)10 TClass (org.eclipse.n4js.ts.types.TClass)10 TField (org.eclipse.n4js.ts.types.TField)10 TMethod (org.eclipse.n4js.ts.types.TMethod)9 TModule (org.eclipse.n4js.ts.types.TModule)9 MemberList (org.eclipse.n4js.ts.types.util.MemberList)9 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)9 HashSet (java.util.HashSet)8 HashMap (java.util.HashMap)7 NameStaticPair (org.eclipse.n4js.ts.types.util.NameStaticPair)7 MemberCollector (org.eclipse.n4js.utils.ContainerTypesHelper.MemberCollector)7 Optional (java.util.Optional)6 ParameterizedPropertyAccessExpression (org.eclipse.n4js.n4JS.ParameterizedPropertyAccessExpression)6 EcoreUtil2 (org.eclipse.xtext.EcoreUtil2)6 Inject (com.google.inject.Inject)5