@Override public void apply(final InferenceContext ctx) { // FIXME once BUG-7760 gets fixed, there will be no need for these dirty casts final StatementContextBase<?, ?, ?> sourceNodeStmtCtx = (StatementContextBase<?, ?, ?>) sourceCtxPrerequisite.resolve(ctx); final StatementContextBase<?, ?, ?> targetNodeStmtCtx = (StatementContextBase<?, ?, ?>) targetCtxPrerequisite.resolve(ctx); switch (deviateKind) { case NOT_SUPPORTED: targetNodeStmtCtx.setIsSupportedToBuildEffective(false); break; case ADD: performDeviateAdd(sourceNodeStmtCtx, targetNodeStmtCtx); break; case REPLACE: performDeviateReplace(sourceNodeStmtCtx, targetNodeStmtCtx); break; case DELETE: performDeviateDelete(sourceNodeStmtCtx, targetNodeStmtCtx); break; default: throw new IllegalStateException("Unsupported deviate " + deviateKind); } }
@Override public void apply(final InferenceContext ctx) { final StmtContext<?, ?, ?> importedModuleContext = imported.resolve(ctx); Verify.verify(moduleName.equals(importedModuleContext.getStatementArgument())); final URI importedModuleNamespace = importedModuleContext.getFromNamespace(ModuleNameToNamespace.class, moduleName); Verify.verifyNotNull(importedModuleNamespace); final String impPrefix = SourceException.throwIfNull( firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class), stmt.getStatementSourceReference(), "Missing prefix statement"); stmt.addToNs(ImpPrefixToNamespace.class, impPrefix, importedModuleNamespace); }
@Override public void apply(final InferenceContext ctx) { final StmtContext<?, ?, ?> importedModule = imported.resolve(ctx); linkageTarget.resolve(ctx).addToNs(ImportedModuleContext.class, stmt.getFromNamespace(ModuleCtxToSourceIdentifier.class, importedModule), importedModule); final String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class); final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(), NamespaceStatement.class); stmt.addToNs(ImportPrefixToModuleCtx.class, impPrefix, importedModule); stmt.addToNs(URIStringToImportPrefix.class, modNs.toString(), impPrefix); }
@Override public void apply(final InferenceContext ctx) { final StatementContextBase<?, ?, ?> augmentTargetCtx = (StatementContextBase<?, ?, ?>) target.resolve(ctx); if (!isSupportedAugmentTarget(augmentTargetCtx) || StmtContextUtils.isInExtensionBody(augmentTargetCtx)) { augmentNode.setIsSupportedToBuildEffective(false); return; } /** * Marks case short hand in augment */ if (augmentTargetCtx.getPublicDefinition() == YangStmtMapping.CHOICE) { augmentNode.addToNs(AugmentToChoiceNamespace.class, augmentNode, Boolean.TRUE); } // FIXME: this is a workaround for models which augment a node which is added via an extension // which we do not handle. This needs to be reworked in terms of unknown schema nodes. final StatementContextBase<?, ?, ?> augmentSourceCtx = (StatementContextBase<?, ?, ?>) augmentNode; try { copyFromSourceToTarget(augmentSourceCtx, augmentTargetCtx); augmentTargetCtx.addEffectiveSubstatement(augmentSourceCtx); updateAugmentOrder(augmentSourceCtx); } catch (final SourceException e) { LOG.warn("Failed to add augmentation {} defined at {}", augmentTargetCtx.getStatementSourceReference(), augmentSourceCtx.getStatementSourceReference(), e); } }
@Override public void apply(final InferenceContext ctx) { final StmtContext<?, ?, ?> importedModule = imported.resolve(ctx); final SemVer importedVersion = stmt.getFromNamespace(SemanticVersionNamespace.class, stmt); final SourceIdentifier importedModuleIdentifier = importedModule.getFromNamespace( ModuleCtxToSourceIdentifier.class, importedModule); final SemVerSourceIdentifier semVerModuleIdentifier = createSemVerModuleIdentifier( importedModuleIdentifier, importedVersion); linkageTarget.resolve(ctx).addToNs(ImportedModuleContext.class, importedModuleIdentifier, importedModule); final String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class); stmt.addToNs(ImportPrefixToModuleCtx.class, impPrefix, importedModule); stmt.addToNs(ImportPrefixToSemVerSourceIdentifier.class, impPrefix, semVerModuleIdentifier); final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(), NamespaceStatement.class); stmt.addToNs(URIStringToImportPrefix.class, modNs.toString(), impPrefix); }
@Override public void apply(final InferenceContext ctx) { StmtContext<?, ?, ?> belongsToModuleCtx = belongsToPrereq.resolve(ctx); belongsToCtx.addToNs(BelongsToModuleContext.class, belongsToSourceIdentifier, belongsToModuleCtx); belongsToCtx.addToNs(BelongsToPrefixToModuleCtx.class, findFirstDeclaredSubstatement(belongsToCtx, PrefixStatement.class).coerceStatementArgument(), belongsToModuleCtx); }
@Override public void apply(final InferenceContext ctx) { final StatementContextBase<?, ?, ?> targetNodeStmtCtx = (StatementContextBase<?, ?, ?>) targetNodePre.resolve(ctx); final StatementContextBase<?, ?, ?> sourceGrpStmtCtx = (StatementContextBase<?, ?, ?>) sourceGroupingPre.resolve(ctx); UsesStatementImpl.copyFromSourceToTarget(sourceGrpStmtCtx, targetNodeStmtCtx, usesNode); UsesStatementImpl.resolveUsesNode(usesNode, targetNodeStmtCtx); StmtContextUtils.validateIfFeatureAndWhenOnListKeys(usesNode); }
@Override public void apply(final InferenceContext ctx) { final StmtContext<?, ?, ?> includedSubModuleContext = requiresCtxPrerequisite.resolve(ctx); stmt.addToNs(IncludedModuleContext.class, revision != null ? RevisionSourceIdentifier.create(submoduleName, revision.getStatementArgument()) : RevisionSourceIdentifier.create(submoduleName), includedSubModuleContext); stmt.addToNs(IncludedSubmoduleNameToModuleCtx.class, stmt.getStatementArgument(), includedSubModuleContext); }