@Override public void apply(final InferenceContext ctx) { List<StmtContext<?, ?, ?>> derivedIdentities = baseStmtCtx.getFromNamespace( DerivedIdentitiesNamespace.class, baseIdentityQName); if (derivedIdentities == null) { derivedIdentities = new ArrayList<>(1); baseStmtCtx.addToNs(DerivedIdentitiesNamespace.class, baseIdentityQName, derivedIdentities); } derivedIdentities.add(baseParentCtx); }
nextPath = iterator.next(); @SuppressWarnings("unchecked") final Mutable<?, ?, EffectiveStatement<?, ?>> nextNodeCtx = (Mutable)current.getFromNamespace( ChildSchemaNodeNamespace.class, nextPath); if (nextNodeCtx == null) {
private static boolean isDeviationSupported(final Mutable<DeviateKind, DeviateStatement, EffectiveStatement<DeviateKind, DeviateStatement>> deviateStmtCtx, final SchemaNodeIdentifier deviationTarget) { final SetMultimap<QNameModule, QNameModule> modulesDeviatedByModules = deviateStmtCtx.getFromNamespace( ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES); if (modulesDeviatedByModules == null) { return true; } final QNameModule currentModule = deviateStmtCtx.getFromNamespace(ModuleCtxToModuleQName.class, deviateStmtCtx.getRoot()); final QNameModule targetModule = deviationTarget.getLastComponent().getModule(); final Set<QNameModule> deviationModulesSupportedByTargetModule = modulesDeviatedByModules.get(targetModule); if (deviationModulesSupportedByTargetModule != null) { return deviationModulesSupportedByTargetModule.contains(currentModule); } return false; }
final ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE); final String moduleName = stmt.coerceStatementArgument(); final SemVer semanticVersion = stmt.getFromNamespace(SemanticVersionNamespace.class, stmt); final SemanticVersionImport.CompatibleCriterion criterion = semanticVersion == null ? new NoVerCompatibleCriterion(moduleName)
nextPath = iterator.next(); @SuppressWarnings("unchecked") final Mutable<?, ?, EffectiveStatement<?, ?>> nextNodeCtx = (Mutable)current.getFromNamespace( ChildSchemaNodeNamespace.class,nextPath); if (nextNodeCtx == null) {
final QNameModule qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orElse(null)).intern(); final StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>> possibleDuplicateModule = stmt.getFromNamespace(NamespaceToModule.class, qNameModule); if (possibleDuplicateModule != null && possibleDuplicateModule != stmt) { throw new SourceException(stmt.getStatementSourceReference(), "Module namespace collision: %s. At %s",
@Override public final void onLinkageDeclared( final Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt) { final SourceIdentifier submoduleIdentifier = RevisionSourceIdentifier.create(stmt.coerceStatementArgument(), StmtContextUtils.getLatestRevision(stmt.declaredSubstatements())); final StmtContext<?, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> possibleDuplicateSubmodule = stmt.getFromNamespace(SubmoduleNamespace.class, submoduleIdentifier); if (possibleDuplicateSubmodule != null && possibleDuplicateSubmodule != stmt) { throw new SourceException(stmt.getStatementSourceReference(), "Submodule name collision: %s. At %s", stmt.getStatementArgument(), possibleDuplicateSubmodule.getStatementSourceReference()); } stmt.addContext(SubmoduleNamespace.class, submoduleIdentifier, stmt); final String belongsToModuleName = firstAttributeOf(stmt.declaredSubstatements(), BelongsToStatement.class); final StmtContext<?, ?, ?> prefixSubStmtCtx = findFirstDeclaredSubstatement(stmt, 0, BelongsToStatement.class, PrefixStatement.class); SourceException.throwIfNull(prefixSubStmtCtx, stmt.getStatementSourceReference(), "Prefix of belongsTo statement is missing in submodule [%s]", stmt.getStatementArgument()); final String prefix = (String) prefixSubStmtCtx.getStatementArgument(); stmt.addToNs(BelongsToPrefixToModuleName.class, prefix, belongsToModuleName); } }
@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 final void onFullDefinitionDeclared(final Mutable<String, IdentityRefSpecification, EffectiveStatement<String, IdentityRefSpecification>> stmt) { super.onFullDefinitionDeclared(stmt); final Collection<StmtContext<QName, BaseStatement, ?>> baseStatements = StmtContextUtils.findAllDeclaredSubstatements(stmt, BaseStatement.class); for (StmtContext<QName, BaseStatement, ?> baseStmt : baseStatements) { final QName baseIdentity = baseStmt.coerceStatementArgument(); final StmtContext<?, ?, ?> stmtCtx = stmt.getFromNamespace(IdentityNamespace.class, baseIdentity); InferenceException.throwIfNull(stmtCtx, stmt.getStatementSourceReference(), "Referenced base identity '%s' doesn't exist in given scope (module, imported modules, submodules)", baseIdentity.getLocalName()); } } }
@Override public void onFullDefinitionDeclared(final StmtContext.Mutable<SchemaNodeIdentifier, DeviationStatement, EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> ctx) { final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx.getRoot()); final QNameModule targetModule = ctx.coerceStatementArgument().getLastComponent().getModule(); if (currentModule.equals(targetModule)) { throw new InferenceException(ctx.getStatementSourceReference(), "Deviation must not target the same module as the one it is defined in: %s", currentModule); } }
@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); }
private static void addToSemVerModuleNamespace( final Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt, final SourceIdentifier moduleIdentifier) { final String moduleName = stmt.coerceStatementArgument(); final SemVer moduleSemVer = stmt.getFromNamespace(SemanticVersionNamespace.class, stmt); final SemVerSourceIdentifier id = SemVerSourceIdentifier.create(moduleName, moduleSemVer); stmt.addToNs(SemanticVersionModuleNamespace.class, id, stmt); } }