CopyHistory and yangVersion merge
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / deviate / AbstractDeviateStatementSupport.java
index 1c880d8ca3fc3e7e824c40120e738c9d562e8ce4..b16661d6b3d4193ea9ebddd84c7aae03e9364040 100644 (file)
@@ -112,11 +112,11 @@ abstract class AbstractDeviateStatementSupport
     @Override
     public final void onFullDefinitionDeclared(
             final Mutable<DeviateKind, DeviateStatement, DeviateEffectiveStatement> deviateStmtCtx) {
-        final DeviateKind deviateKind = deviateStmtCtx.getStatementArgument();
+        final DeviateKind deviateKind = deviateStmtCtx.argument();
         getSubstatementValidatorForDeviate(deviateKind).validate(deviateStmtCtx);
 
         final SchemaNodeIdentifier deviationTarget =
-                (SchemaNodeIdentifier) deviateStmtCtx.coerceParentContext().getStatementArgument();
+                (SchemaNodeIdentifier) deviateStmtCtx.coerceParentContext().argument();
 
         if (!isDeviationSupported(deviateStmtCtx, deviationTarget)) {
             return;
@@ -191,7 +191,7 @@ abstract class AbstractDeviateStatementSupport
     @Override
     protected final DeviateStatement createDeclared(final StmtContext<DeviateKind, DeviateStatement, ?> ctx,
             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
-        return new DeviateStatementImpl(ctx.getRawArgument(), ctx.coerceStatementArgument(), substatements);
+        return new DeviateStatementImpl(ctx.getRawArgument(), ctx.getArgument(), substatements);
     }
 
     @Override
@@ -264,7 +264,7 @@ abstract class AbstractDeviateStatementSupport
                         stmtCtxToBeAdded.sourceReference(),
                         "Deviation cannot add substatement %s to target node %s because it is already defined "
                         + "in target and can appear only once.",
-                        stmtToBeAdded.getStatementName(), targetCtx.getStatementArgument());
+                        stmtToBeAdded.getStatementName(), targetCtx.argument());
                 }
             }
         }
@@ -290,7 +290,7 @@ abstract class AbstractDeviateStatementSupport
                 && YangStmtMapping.LEAF_LIST.equals(targetCtx.publicDefinition())) {
             LOG.error("Deviation cannot replace substatement {} in target leaf-list {} because a leaf-list can "
                     + "have multiple default statements. At line: {}", stmtToBeReplaced.getStatementName(),
-                    targetCtx.getStatementArgument(), stmtCtxToBeReplaced.sourceReference());
+                    targetCtx.argument(), stmtCtxToBeReplaced.sourceReference());
             return;
         }
 
@@ -320,7 +320,7 @@ abstract class AbstractDeviateStatementSupport
 
         throw new InferenceException(stmtCtxToBeReplaced.sourceReference(), "Deviation cannot replace "
                 + "substatement %s in target node %s because it does not exist in target node.",
-                stmtToBeReplaced.getStatementName(), targetCtx.getStatementArgument());
+                stmtToBeReplaced.getStatementName(), targetCtx.argument());
     }
 
     @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
@@ -356,7 +356,7 @@ abstract class AbstractDeviateStatementSupport
 
         LOG.error("Deviation cannot delete substatement {} with argument '{}' in target node {} because it does "
                 + "not exist in the target node. At line: {}", stmtToBeDeleted.getStatementName(), stmtArgument,
-                targetCtx.getStatementArgument(), stmtCtxToBeDeleted.sourceReference());
+                targetCtx.argument(), stmtCtxToBeDeleted.sourceReference());
     }
 
     private static void copyStatement(final Mutable<?, ?, ?> stmtCtxToBeCopied,
@@ -364,7 +364,7 @@ abstract class AbstractDeviateStatementSupport
         // we need to make a copy of the statement context only if it is an unknown statement, otherwise
         // we can reuse the original statement context
         if (!StmtContextUtils.isUnknownStatement(stmtCtxToBeCopied)) {
-            targetCtx.addEffectiveSubstatement(stmtCtxToBeCopied);
+            targetCtx.addEffectiveSubstatement(stmtCtxToBeCopied.replicaAsChildOf(targetCtx));
         } else {
             targetCtx.addEffectiveSubstatement(targetCtx.childCopyOf(stmtCtxToBeCopied, CopyType.ORIGINAL));
         }
@@ -378,7 +378,7 @@ abstract class AbstractDeviateStatementSupport
     private static void validateDeviationTarget(final StmtContext<?, ?, ?> deviateSubStmtCtx,
             final StmtContext<?, ?, ?> targetCtx) {
         InferenceException.throwIf(!isSupportedDeviationTarget(deviateSubStmtCtx, targetCtx,
-            targetCtx.getRootVersion()), deviateSubStmtCtx.sourceReference(),
+            targetCtx.yangVersion()), deviateSubStmtCtx.sourceReference(),
             "%s is not a valid deviation target for substatement %s.", targetCtx.argument(),
             deviateSubStmtCtx.publicDefinition().getStatementName());
     }
@@ -386,7 +386,7 @@ abstract class AbstractDeviateStatementSupport
     private static boolean isSupportedDeviationTarget(final StmtContext<?, ?, ?> deviateSubstatementCtx,
             final StmtContext<?, ?, ?> deviateTargetCtx, final YangVersion yangVersion) {
         Set<StatementDefinition> supportedDeviationTargets =
-                YangValidationBundles.SUPPORTED_DEVIATION_TARGETS.get(deviateTargetCtx.getRootVersion(),
+                YangValidationBundles.SUPPORTED_DEVIATION_TARGETS.get(yangVersion,
                         deviateSubstatementCtx.publicDefinition());
 
         if (supportedDeviationTargets == null) {