X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-rfc7950%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Frfc7950%2Fstmt%2Faugment%2FAugmentInferenceAction.java;h=f00172ffbc0b550aca1114024307426e8c9a92ef;hb=4c38a878a8771aca71d50a9dd5cf7f89420850e5;hp=d5213f94c25d26c7faa7b3dccbf51aa32bcb614c;hpb=a5fcc148270656a26d8222dece00f8940edfbc96;p=yangtools.git diff --git a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentInferenceAction.java b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentInferenceAction.java index d5213f94c2..f00172ffbc 100644 --- a/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentInferenceAction.java +++ b/yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AugmentInferenceAction.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Objects; import java.util.Optional; +import org.opendaylight.yangtools.yang.common.Empty; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; @@ -72,7 +73,7 @@ final class AugmentInferenceAction implements InferenceAction { // We are targeting a context which is creating implicit nodes. In order to keep things consistent, // we will need to circle back when creating effective statements. if (augmentTargetCtx.hasImplicitParentSupport()) { - augmentNode.addToNs(AugmentImplicitHandlingNamespace.class, augmentNode, augmentTargetCtx); + augmentNode.addToNs(AugmentImplicitHandlingNamespace.class, Empty.getInstance(), augmentTargetCtx); } // FIXME: this is a workaround for models which augment a node which is added via an extension @@ -103,8 +104,7 @@ final class AugmentInferenceAction implements InferenceAction { } } - throw new InferenceException(augmentNode.sourceReference(), "Augment target '%s' not found", - augmentNode.argument()); + throw new InferenceException(augmentNode, "Augment target '%s' not found", augmentNode.argument()); } private void copyFromSourceToTarget(final StatementContextBase sourceCtx, @@ -138,7 +138,7 @@ final class AugmentInferenceAction implements InferenceAction { final boolean skipCheckOfMandatoryNodes, final boolean unsupported) { // We always copy statements, but if either the source statement or the augmentation which causes it are not // supported to build we also mark the target as such. - if (needToCopyByAugment(original)) { + if (!NOCOPY_DEF_SET.contains(original.publicDefinition())) { validateNodeCanBeCopiedByAugment(original, target, typeOfCopy, skipCheckOfMandatoryNodes); final Mutable copy = target.childCopyOf(original, typeOfCopy); @@ -163,8 +163,7 @@ final class AugmentInferenceAction implements InferenceAction { if (sourceCtx.producesDeclared(DataDefinitionStatement.class)) { for (final StmtContext subStatement : targetCtx.allSubstatements()) { if (subStatement.producesDeclared(DataDefinitionStatement.class)) { - InferenceException.throwIf(Objects.equals(sourceCtx.argument(), subStatement.argument()), - sourceCtx.sourceReference(), + InferenceException.throwIf(Objects.equals(sourceCtx.argument(), subStatement.argument()), sourceCtx, "An augment cannot add node named '%s' because this name is already used in target", sourceCtx.rawArgument()); } @@ -184,7 +183,7 @@ final class AugmentInferenceAction implements InferenceAction { sourceCtx.allSubstatementsStream().forEach(AugmentInferenceAction::checkForMandatoryNodes); } - InferenceException.throwIf(StmtContextUtils.isMandatoryNode(sourceCtx), sourceCtx.sourceReference(), + InferenceException.throwIf(StmtContextUtils.isMandatoryNode(sourceCtx), sourceCtx, "An augment cannot add node '%s' because it is mandatory and in module different than target", sourceCtx.rawArgument()); } @@ -230,7 +229,7 @@ final class AugmentInferenceAction implements InferenceAction { // This could be an augmentation stacked on top of a previous augmentation from the same module, which is // conditional -- in which case we do not run further checks - if (targetCtx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) { + if (targetCtx.history().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) { final Optional> optPrevCopy = targetCtx.getPreviousCopyCtx(); if (optPrevCopy.isPresent()) { final StmtContext original = optPrevCopy.get(); @@ -260,10 +259,6 @@ final class AugmentInferenceAction implements InferenceAction { return parent; } - private static boolean needToCopyByAugment(final StmtContext stmtContext) { - return !NOCOPY_DEF_SET.contains(stmtContext.publicDefinition()); - } - private static boolean isSupportedAugmentTarget(final StmtContext substatementCtx) { /* * :TODO Substatement must be allowed augment target type e.g.