- // Our parent here is *not* the uses statement, but rather the statement which contains uses -- and its
- // getSchemaTreeGenerator() is well equipped to deal with the namespace hopping needed to perform the lookups
- setTargetGenerator(getParent().resolveSchemaNode(statement().argument()));
+ // Our parent here is *not* the 'uses' statement, but rather the statement which contains it.
+ return new AugmentRequirement(this, verifyNotNull(grouping, "Unresolved grouping in %s", this));
+ }
+
+ @Override
+ boolean matchesInstantiated(final AugmentEffectiveStatement statement) {
+ return super.matchesInstantiated(statement) || declared(statement()).equals(declared(statement));
+ }
+
+ private static AugmentStatement declared(final AugmentEffectiveStatement statement) {
+ // We are generating Augmentation interfaces on declared model, hence this is accurate
+ return verifyNotNull(statement.getDeclared(), " %s does not have a declared view", statement);
+ }
+
+ @Override
+ TargetAugmentEffectiveStatement effectiveIn(final SchemaTreeAwareEffectiveStatement<?, ?> target) {
+ verify(target instanceof SchemaTreeEffectiveStatement, "Unexpected statement %s", target);
+ // 'uses'/'augment': our children are binding to target's namespace
+
+ final var targetNamespace = ((SchemaTreeEffectiveStatement<?>) target).argument().getModule();
+ return effectiveIn(target, qname -> qname.bindTo(targetNamespace));