private static boolean isSupportedRefineSubstatement(final StmtContext<?, ?, ?> refineSubstatementCtx) { final Collection<?> supportedRefineSubstatements = refineSubstatementCtx.getFromNamespace( ValidationBundlesNamespace.class, ValidationBundleType.SUPPORTED_REFINE_SUBSTATEMENTS); return supportedRefineSubstatements == null || supportedRefineSubstatements.isEmpty() || supportedRefineSubstatements.contains(refineSubstatementCtx.getPublicDefinition()) || StmtContextUtils.isUnknownStatement(refineSubstatementCtx); }
public static boolean isInExtensionBody(final StmtContext<?, ?, ?> stmtCtx) { StmtContext<?, ?, ?> current = stmtCtx; while (current.coerceParentContext().getParentContext() != null) { current = current.getParentContext(); if (isUnknownStatement(current)) { return true; } } return false; }
private static void copyStatement(final Mutable<?, ?, ?> stmtCtxToBeCopied, final StatementContextBase<?, ?, ?> targetCtx) { // 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); } else { targetCtx.addEffectiveSubstatement(targetCtx.childCopyOf(stmtCtxToBeCopied, CopyType.ORIGINAL)); } }
@Override public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) { /* * Do not fail, if it is an uses-augment to an unknown node. */ if (YangStmtMapping.USES == augmentNode.coerceParentContext().getPublicDefinition()) { final SchemaNodeIdentifier augmentArg = augmentNode.coerceStatementArgument(); final Optional<StmtContext<?, ?, ?>> targetNode = ChildSchemaNodeNamespace.findNode( getSearchRoot(augmentNode), augmentArg); if (targetNode.isPresent() && StmtContextUtils.isUnknownStatement(targetNode.get())) { augmentNode.setIsSupportedToBuildEffective(false); LOG.warn("Uses-augment to unknown node {}. Augmentation has not been performed. At line: {}", augmentArg, augmentNode.getStatementSourceReference()); return; } } throw new InferenceException(augmentNode.getStatementSourceReference(), "Augment target '%s' not found", augmentNode.getStatementArgument()); } });
private static void addStatement(final Mutable<?, ?, ?> stmtCtxToBeAdded, final StatementContextBase<?, ?, ?> targetCtx) { if (!StmtContextUtils.isUnknownStatement(stmtCtxToBeAdded)) { final StatementDefinition stmtToBeAdded = stmtCtxToBeAdded.getPublicDefinition(); if (SINGLETON_STATEMENTS.contains(stmtToBeAdded) || YangStmtMapping.DEFAULT.equals(stmtToBeAdded) && YangStmtMapping.LEAF.equals(targetCtx.getPublicDefinition())) { for (final StmtContext<?, ?, ?> targetCtxSubstatement : targetCtx.allSubstatements()) { InferenceException.throwIf(stmtToBeAdded.equals(targetCtxSubstatement.getPublicDefinition()), stmtCtxToBeAdded.getStatementSourceReference(), "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()); } } } copyStatement(stmtCtxToBeAdded, targetCtx); }
qnameModule = StmtContextUtils.getModuleQNameByPrefix(ctx, prefix); if (qnameModule == null && isUnknownStatement(ctx)) { localName = value; qnameModule = StmtContextUtils.getRootModuleQName(ctx);
final SchemaPath parentPath = maybeParentPath.get(); if (StmtContextUtils.isUnknownStatement(this)) { return parentPath.createChild(getPublicDefinition().getStatementName());
private static void performRefine(final Mutable<?, ?, ?> subStmtCtx, final StmtContext<?, ?, ?> usesParentCtx) { final Object refineArgument = subStmtCtx.getStatementArgument(); InferenceException.throwIf(!(refineArgument instanceof SchemaNodeIdentifier), subStmtCtx.getStatementSourceReference(), "Invalid refine argument %s. It must be instance of SchemaNodeIdentifier.", refineArgument); final Optional<StmtContext<?, ?, ?>> optRefineTargetCtx = ChildSchemaNodeNamespace.findNode( usesParentCtx, (SchemaNodeIdentifier) refineArgument); InferenceException.throwIf(!optRefineTargetCtx.isPresent(), subStmtCtx.getStatementSourceReference(), "Refine target node %s not found.", refineArgument); final StmtContext<?, ?, ?> refineTargetNodeCtx = optRefineTargetCtx.get(); if (StmtContextUtils.isUnknownStatement(refineTargetNodeCtx)) { LOG.trace("Refine node '{}' in uses '{}' has target node unknown statement '{}'. " + "Refine has been skipped. At line: {}", subStmtCtx.getStatementArgument(), subStmtCtx.coerceParentContext().getStatementArgument(), refineTargetNodeCtx.getStatementArgument(), subStmtCtx.getStatementSourceReference()); subStmtCtx.addAsEffectOfStatement(refineTargetNodeCtx); return; } Verify.verify(refineTargetNodeCtx instanceof StatementContextBase); addOrReplaceNodes(subStmtCtx, (StatementContextBase<?, ?, ?>) refineTargetNodeCtx); subStmtCtx.addAsEffectOfStatement(refineTargetNodeCtx); }