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();
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations