Search in sources :

Example 1 with MemberType

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

the class MemberMatrix method toShortString.

/**
 * Returns a one-line description, only for debugging purposes
 */
String toShortString() {
    if (!allMembers().hasNext()) {
        return "MemberMatrix not initialized yet.";
    }
    StringBuilder strb = new StringBuilder("[");
    for (MemberType type : MemberType.values()) {
        for (int source = 0; source < SOURCE_COUNT_WITHOUT_CONSUMED; source++) {
            strb.append(members(source, type).stream().map(m -> m.getMemberType().getName().charAt(0) + " " + m.getContainingType().getName()).collect(Collectors.joining(",")));
        }
    }
    if (!consumed.isEmpty()) {
        strb.append(", consumed: ");
        strb.append(consumed.stream().map(m -> m != null ? m.getMemberType().getName().charAt(0) + " " + m.getContainingType().getName() : "null").collect(Collectors.joining(",")));
    }
    strb.append("]");
    return strb.toString();
}
Also used : MemberType(org.eclipse.n4js.ts.types.MemberType)

Example 2 with MemberType

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

the class ComposedMemberInfo method handleTypeRefLists.

private void handleTypeRefLists(TMember member, RuleEnvironment G) {
    TypeRef typeRef = TypeUtils.getMemberTypeRef(member);
    TypeRef typeRefSubst = ts.substTypeVariablesInTypeRef(G, typeRef);
    if (typeRefSubst != null && !(typeRefSubst instanceof UnknownTypeRef)) {
        TypeRef typeRefCopy = TypeUtils.copyIfContained(typeRefSubst);
        typeRefs.add(typeRefCopy);
        typeRef2G.put(typeRefCopy, G);
        if (member.getMemberType() == MemberType.METHOD) {
            if (TypeUtils.isVoid(typeRefCopy)) {
                methodTypeRefsVoid.add(typeRefCopy);
            } else {
                methodTypeRefsNonVoid.add(typeRefCopy);
            }
        }
        MemberType currMType = member.getMemberType();
        if (!typeRefsMap.containsKey(currMType)) {
            typeRefsMap.put(currMType, new LinkedList<>());
        }
        List<TypeRef> typeRefsOfMemberType = typeRefsMap.get(currMType);
        typeRefsOfMemberType.add(typeRefCopy);
    }
}
Also used : UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) MemberType(org.eclipse.n4js.ts.types.MemberType) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)

Example 3 with MemberType

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

the class ComposedMemberInfo method handleMemberTypes.

// ///////////////////////// Helper Init Methods ///////////////////////////
private MemberType handleMemberTypes(MemberType lastMType, TMember member) {
    MemberType currMType = member.getMemberType();
    lastMType = (lastMType == null) ? currMType : lastMType;
    hasMultipleMemberTypes |= currMType != lastMType;
    hasFieldMemberType |= currMType == MemberType.FIELD;
    hasGetterMemberType |= currMType == MemberType.GETTER;
    hasSetterMemberType |= currMType == MemberType.SETTER;
    hasMethodMemberType |= currMType == MemberType.METHOD;
    hasNonMethodMemberType |= currMType != MemberType.METHOD;
    onlyMethodMemberTypes &= currMType == MemberType.METHOD;
    onlyFieldMemberTypes &= currMType == MemberType.FIELD;
    onlyGetterMemberTypes &= currMType == MemberType.GETTER;
    onlySetterMemberTypes &= currMType == MemberType.SETTER;
    lastMType = currMType;
    return lastMType;
}
Also used : MemberType(org.eclipse.n4js.ts.types.MemberType)

Example 4 with MemberType

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

the class ComposedMemberInfo method getTypeRefsOfMemberType.

/**
 * Returns a list of all return {@link TypeRef}s of the given {@link MemberType}s. If no {@link MemberType} is
 * given, all {@link TypeRef}s are returned.
 */
public List<TypeRef> getTypeRefsOfMemberType(MemberType... memberTypes) {
    initMemberAggregate();
    List<TypeRef> resultTypeRefs = new LinkedList<>();
    if (memberTypes == null) {
        for (List<TypeRef> franzLiszt : typeRefsMap.values()) {
            resultTypeRefs.addAll(franzLiszt);
        }
        return resultTypeRefs;
    }
    for (MemberType memberType : memberTypes) {
        if (typeRefsMap.containsKey(memberType)) {
            resultTypeRefs.addAll(typeRefsMap.get(memberType));
        }
    }
    return resultTypeRefs;
}
Also used : MemberType(org.eclipse.n4js.ts.types.MemberType) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) LinkedList(java.util.LinkedList)

Example 5 with MemberType

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

the class ComposedMemberInfo method initMemberAggregate.

// ///////////////////////// Init Methods ///////////////////////////
private synchronized void initMemberAggregate() {
    if (isInitialized)
        return;
    this.isSiblingMissing = siblings.contains(null);
    MemberType lastMType = null;
    for (Pair<TMember, RuleEnvironment> pair : siblings) {
        if (pair == null)
            continue;
        this.isEmpty = false;
        TMember member = pair.getKey();
        RuleEnvironment G = pair.getValue();
        lastMType = handleMemberTypes(lastMType, member);
        handleReadOnlyField(member);
        handleAccessibility(member);
        handleTypeRefLists(member, G);
        handleFParameters(member, G);
    }
    // init: fParameters
    List<TypeRef> currVariadicAccumulated = new LinkedList<>();
    for (ComposedFParInfo fpAggr : fParameters) {
        initFParAggregate(fpAggr);
        // handle: typeRefsVariadicAccumulated
        currVariadicAccumulated.addAll(fpAggr.typeRefsVariadic);
        fpAggr.typeRefsVariadicAccumulated.addAll(currVariadicAccumulated);
    }
    handleIsVariadicButLastFParIsDifferent();
    handleValidationProblems();
    this.isInitialized = true;
}
Also used : MemberType(org.eclipse.n4js.ts.types.MemberType) TypeRef(org.eclipse.n4js.ts.typeRefs.TypeRef) UnknownTypeRef(org.eclipse.n4js.ts.typeRefs.UnknownTypeRef) RuleEnvironment(org.eclipse.xsemantics.runtime.RuleEnvironment) TMember(org.eclipse.n4js.ts.types.TMember) LinkedList(java.util.LinkedList)

Aggregations

MemberType (org.eclipse.n4js.ts.types.MemberType)6 TypeRef (org.eclipse.n4js.ts.typeRefs.TypeRef)3 UnknownTypeRef (org.eclipse.n4js.ts.typeRefs.UnknownTypeRef)3 LinkedList (java.util.LinkedList)2 TMember (org.eclipse.n4js.ts.types.TMember)2 RuleEnvironment (org.eclipse.xsemantics.runtime.RuleEnvironment)1