Add a proper statement policy for 'mount-point' 84/94884/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 29 Jan 2021 13:34:01 +0000 (14:34 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 29 Jan 2021 13:39:16 +0000 (14:39 +0100)
A bit of the policy is dictated by UnknownSchemaNode, but otherwise
this is quite simple.

JIRA: YANGTOOLS-1208
Change-Id: I81f4bb5aac5f530e3fcc293b495e1bc76a6b3f8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/rfc8528-parser-support/src/main/java/org/opendaylight/yangtools/rfc8528/parser/MountPointStatementSupport.java

index a9fca043199c2814a3a4a3848d3e02e18816bec7..f74595e301de2dbfd76c4e213bd163d8f9aa1eb4 100644 (file)
@@ -43,7 +43,12 @@ public final class MountPointStatementSupport
     private final SubstatementValidator validator;
 
     MountPointStatementSupport(final StatementDefinition definition) {
-        super(definition, StatementPolicy.legacyDeclaredCopy());
+        super(definition, StatementPolicy.copyDeclared((copy, current, substatements) ->
+            copy.getArgument().equals(current.getArgument())
+            // Implied by UnknownSchemaNode
+            && copy.history().isAugmenting() == current.history().isAugmenting()
+            && copy.history().isAddedByUses() == current.history().isAddedByUses()
+            && copy.equalParentPath(current)));
         this.validator = SubstatementValidator.builder(definition)
                 .addOptional(YangStmtMapping.CONFIG)
                 .addOptional(YangStmtMapping.DESCRIPTION)
@@ -56,6 +61,12 @@ public final class MountPointStatementSupport
         return INSTANCE;
     }
 
+    // FIXME: these two methods are not quite right. RFC8528 states that:
+    //
+    //    If a mount point is defined within a grouping, its label is
+    //    bound to the module where the grouping is used.
+    //
+    // We are not doing exactly that, in that we can end up rebinding the argument through 'augment', I think.
     @Override
     public QName parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
         return StmtContextUtils.parseIdentifier(ctx, value);