import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StmtOrderingNamespace;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
return;
}
- final ModelActionBuilder augmentAction = augmentNode.newInferenceAction(
- ModelProcessingPhase.EFFECTIVE_MODEL);
- final Prerequisite<StmtContext<SchemaNodeIdentifier, AugmentStatement,
- AugmentEffectiveStatement>> sourceCtxPrereq =
- augmentAction.requiresCtx(augmentNode, ModelProcessingPhase.EFFECTIVE_MODEL);
- final Prerequisite<Mutable<?, ?, EffectiveStatement<?, ?>>> target =
- augmentAction.mutatesEffectiveCtxPath(getSearchRoot(augmentNode),
- ChildSchemaNodeNamespace.class, augmentNode.coerceStatementArgument().getPathFromRoot());
+ final ModelActionBuilder augmentAction = augmentNode.newInferenceAction(ModelProcessingPhase.EFFECTIVE_MODEL);
+ augmentAction.requiresCtx(augmentNode, ModelProcessingPhase.EFFECTIVE_MODEL);
+ final Prerequisite<Mutable<?, ?, EffectiveStatement<?, ?>>> target = augmentAction.mutatesEffectiveCtxPath(
+ getSearchRoot(augmentNode), ChildSchemaNodeNamespace.class,
+ augmentNode.coerceStatementArgument().getNodeIdentifiers());
augmentAction.apply(new InferenceAction() {
@Override
try {
copyFromSourceToTarget(augmentSourceCtx, augmentTargetCtx);
augmentTargetCtx.addEffectiveSubstatement(augmentSourceCtx);
- updateAugmentOrder(augmentSourceCtx);
} catch (final SourceException e) {
LOG.warn("Failed to add augmentation {} defined at {}",
augmentTargetCtx.getStatementSourceReference(),
}
}
- private void updateAugmentOrder(final StatementContextBase<?, ?, ?> augmentSourceCtx) {
- Integer currentOrder = augmentSourceCtx.getFromNamespace(StmtOrderingNamespace.class,
- YangStmtMapping.AUGMENT);
- if (currentOrder == null) {
- currentOrder = 1;
- } else {
- currentOrder++;
- }
-
- augmentSourceCtx.addToNs(StmtOrderingNamespace.class, YangStmtMapping.AUGMENT, currentOrder);
- }
-
@Override
public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
/*
.setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
.toFlags();
- return new AugmentEffectiveStatementImpl(declared, flags, StmtContextUtils.getRootModuleQName(ctx),
- substatements, ctx.getStatementSourceReference(),
+ return new AugmentEffectiveStatementImpl(declared, ctx.coerceStatementArgument(), flags,
+ StmtContextUtils.getRootModuleQName(ctx), substatements, ctx.getStatementSourceReference(),
(AugmentationSchemaNode) ctx.getOriginalCtx().map(StmtContext::buildEffective).orElse(null));
}
static void copyFromSourceToTarget(final StatementContextBase<?, ?, ?> sourceCtx,
final StatementContextBase<?, ?, ?> targetCtx) {
- final CopyType typeOfCopy = UsesStatement.class.equals(sourceCtx.coerceParentContext().getPublicDefinition()
- .getDeclaredRepresentationClass()) ? CopyType.ADDED_BY_USES_AUGMENTATION
- : CopyType.ADDED_BY_AUGMENTATION;
+ final CopyType typeOfCopy = sourceCtx.coerceParentContext().producesDeclared(UsesStatement.class)
+ ? CopyType.ADDED_BY_USES_AUGMENTATION : CopyType.ADDED_BY_AUGMENTATION;
/*
* Since Yang 1.1, if an augmentation is made conditional with a
* "when" statement, it is allowed to add mandatory nodes.
final StatementContextBase<?, ?, ?> targetCtx, final CopyType typeOfCopy,
final boolean skipCheckOfMandatoryNodes) {
- if (WhenStatement.class.equals(sourceCtx.getPublicDefinition().getDeclaredRepresentationClass())) {
+ if (sourceCtx.producesDeclared(WhenStatement.class)) {
return;
}
}
// Data definition statements must not collide on their namespace
- if (DataDefinitionStatement.class.isAssignableFrom(
- sourceCtx.getPublicDefinition().getDeclaredRepresentationClass())) {
+ if (sourceCtx.producesDeclared(DataDefinitionStatement.class)) {
for (final StmtContext<?, ?, ?> subStatement : targetCtx.allSubstatements()) {
- if (DataDefinitionStatement.class.isAssignableFrom(
- subStatement.getPublicDefinition().getDeclaredRepresentationClass())) {
-
+ if (subStatement.producesDeclared(DataDefinitionStatement.class)) {
InferenceException.throwIf(
Objects.equals(sourceCtx.getStatementArgument(), subStatement.getStatementArgument()),
sourceCtx.getStatementSourceReference(),