Search in sources :

Example 1 with FieldAccessor

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

the class N4JSMemberRedefinitionValidator method checkUnpairedAccessorFilling.

private void checkUnpairedAccessorFilling(MemberMatrix mm, N4ClassifierDefinition definition) {
    if (definition.getDefinedType().isStaticPolyfill() && mm.hasMixedAccessorPair()) {
        FieldAccessor ownedAccessor = (FieldAccessor) Iterables.getFirst(mm.owned(), null);
        if (null == ownedAccessor) {
            // Should not happen, a mixed accessor pair implies at least one owned member
            return;
        }
        if (!(definition instanceof N4ClassDefinition)) {
            // Non-class static polyfills aren't allowed. Validated somewhere else.
            return;
        }
        TClass filledClass = MemberRedefinitionUtils.getFilledClass((N4ClassDefinition) definition);
        if (null == filledClass) {
            // Invalid static polyfill class. Validated somewhere else.
            return;
        }
        // Iterate over all inherited members
        SourceAwareIterator memberIterator = mm.actuallyInheritedAndMixedMembers();
        while (memberIterator.hasNext()) {
            TMember next = memberIterator.next();
            ContainerType<?> containingType = next.getContainingType();
            // Issue an error if the member isn't owned by the filled class
            if (containingType != filledClass) {
                messageMissingOwnedAccessor(ownedAccessor);
            }
        }
    }
}
Also used : SourceAwareIterator(org.eclipse.n4js.validation.validators.utils.MemberMatrix.SourceAwareIterator) TMember(org.eclipse.n4js.ts.types.TMember) FieldAccessor(org.eclipse.n4js.ts.types.FieldAccessor) TClass(org.eclipse.n4js.ts.types.TClass) N4ClassDefinition(org.eclipse.n4js.n4JS.N4ClassDefinition)

Aggregations

N4ClassDefinition (org.eclipse.n4js.n4JS.N4ClassDefinition)1 FieldAccessor (org.eclipse.n4js.ts.types.FieldAccessor)1 TClass (org.eclipse.n4js.ts.types.TClass)1 TMember (org.eclipse.n4js.ts.types.TMember)1 SourceAwareIterator (org.eclipse.n4js.validation.validators.utils.MemberMatrix.SourceAwareIterator)1