use of org.eclipse.n4js.ts.types.util.NameStaticPair 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);
}
}
Aggregations