private static SourceSpecificContext getRequiredLibSource(final ModuleIdentifier requiredModule,
final TreeBasedTable<String, Date, SourceSpecificContext> libSourcesTable) {
- return requiredModule.getRevision() == SimpleDateFormatUtil.DEFAULT_DATE_IMP ? getLatestRevision(libSourcesTable
- .row(requiredModule.getName())) : libSourcesTable.get(requiredModule.getName(),
+ return requiredModule.getRevision() == SimpleDateFormatUtil.DEFAULT_DATE_IMP
+ || requiredModule.getRevision() == SimpleDateFormatUtil.DEFAULT_BELONGS_TO_DATE ? getLatestRevision(
+ libSourcesTable.row(requiredModule.getName())) : libSourcesTable.get(requiredModule.getName(),
requiredModule.getRevision());
}
return new BelongsToEffectiveStatementImpl(ctx);
}
+ @Override
+ public void onPreLinkageDeclared(final StmtContext.Mutable<String, BelongsToStatement,
+ EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
+ belongsToCtx.addRequiredModule(getModuleIdentifier(belongsToCtx));
+ }
+
@Override
public void onLinkageDeclared(
final StmtContext.Mutable<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
.addVersionSpecificSupport(VERSION_1_1, new ImportStatementRfc7950Support())
.addVersionSpecificSupport(VERSION_1, new IncludeStatementImpl.Definition())
.addVersionSpecificSupport(VERSION_1_1, new IncludeStatementRfc7950Support())
+ .addSupport(new BelongsToStatementImpl.Definition())
.addSupport(new PrefixStatementImpl.Definition())
.addSupport(new YangVersionStatementImpl.Definition())
.addSupport(new RevisionStatementImpl.Definition())
.addSupport(new ReferenceStatementImpl.Definition())
.addSupport(new ContactStatementImpl.Definition())
.addSupport(new OrganizationStatementImpl.Definition())
- .addSupport(new BelongsToStatementImpl.Definition())
.addSupport(global(ModuleNamespace.class))
.addSupport(global(ModuleNamespaceForBelongsTo.class))
.addSupport(global(SubmoduleNamespace.class))
assertNotNull(context);
final Set<Module> modules = context.getModules();
- assertEquals(7, modules.size());
+ assertEquals(8, modules.size());
assertNotNull(context.findModuleByNamespaceAndRevision(new URI("foo-imp"), SimpleDateFormatUtil
.getRevisionFormat().parse("2017-01-23")));
assertEquals(1, foo.size());
final Set<Module> subFoos = foo.iterator().next().getSubmodules();
assertEquals(1, subFoos.size());
+
+ final Module parentMod = context.findModuleByNamespaceAndRevision(new URI("parent-mod-ns"),
+ SimpleDateFormatUtil.getRevisionFormat().parse("2017-09-07"));
+ assertNotNull(parentMod);
+ assertEquals(1, parentMod.getSubmodules().size());
}
@Test
--- /dev/null
+submodule sub-mod {
+ belongs-to parent-mod {
+ prefix pm;
+ }
+
+ container my-container {
+ leaf my-leaf {
+ type string;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+module parent-mod {
+ namespace parent-mod-ns;
+ prefix pm;
+
+ include sub-mod;
+
+ revision 2017-09-07;
+
+ container my-parent-container {}
+}
\ No newline at end of file