use of org.opendaylight.yangtools.yang.model.api.Submodule in project yangtools by opendaylight.
the class AbstractYinExportTest method exportYinModules.
final void exportYinModules(final String yangDir, final String yinDir) throws IOException, SAXException, XMLStreamException {
final EffectiveModelContext schemaContext = YangParserTestUtils.parseYangResourceDirectory(yangDir);
final Collection<? extends Module> modules = schemaContext.getModules();
assertNotEquals(0, modules.size());
for (Module module : modules) {
readAndValidateModule(schemaContext, module, yinDir);
for (Submodule submodule : module.getSubmodules()) {
readAndValidateSubmodule(schemaContext, module, submodule, yinDir);
}
}
}
use of org.opendaylight.yangtools.yang.model.api.Submodule in project yangtools by opendaylight.
the class Bug9005Test method test.
@Test
public void test() throws Exception {
final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug9005");
assertNotNull(context);
final Module foo = context.findModule("foo", Revision.of("2017-07-07")).get();
final Collection<? extends ModuleImport> imports = foo.getImports();
assertEquals(1, imports.size());
final ModuleImport imp1 = imports.iterator().next();
assertEquals("bar-2", imp1.getModuleName());
assertEquals("bar", imp1.getPrefix());
assertEquals(Revision.ofNullable("2000-01-02"), imp1.getRevision());
final Collection<? extends Submodule> submodules = foo.getSubmodules();
assertEquals(1, submodules.size());
final Submodule submodule = submodules.iterator().next();
final Collection<? extends ModuleImport> subImports = submodule.getImports();
assertEquals(1, subImports.size());
final ModuleImport subImp1 = subImports.iterator().next();
assertEquals("bar-1", subImp1.getModuleName());
assertEquals("bar", subImp1.getPrefix());
assertEquals(Revision.ofNullable("2000-01-01"), subImp1.getRevision());
}
use of org.opendaylight.yangtools.yang.model.api.Submodule in project yangtools by opendaylight.
the class ProcessorModuleReactor method toContext.
ContextHolder toContext() throws IOException, YangParserException {
checkState(parser != null, "Context has already been assembled");
for (YangTextSchemaSource source : toUniqueSources(dependencies)) {
// This source is coming from a dependency:
// - its identifier should be accurate, as it should have been processed into a file with accurate name
// - it is not required to be parsed, hence we add it just as a library source
parser.addLibSource(source);
}
final EffectiveModelContext schemaContext = verifyNotNull(parser.buildEffectiveModel());
parser = null;
final Set<Module> modules = new HashSet<>();
for (Module module : schemaContext.getModules()) {
final SourceIdentifier modId = Util.moduleToIdentifier(module);
LOG.debug("Looking for source {}", modId);
if (modelsInProject.containsKey(modId)) {
LOG.debug("Module {} belongs to current project", module);
modules.add(module);
for (Submodule sub : module.getSubmodules()) {
final SourceIdentifier subId = Util.moduleToIdentifier(sub);
if (!modelsInProject.containsKey(subId)) {
LOG.warn("Submodule {} not found in input files", sub);
}
}
}
}
return new ContextHolder(schemaContext, modules, modelsInProject.keySet());
}
use of org.opendaylight.yangtools.yang.model.api.Submodule in project yangtools by opendaylight.
the class ModuleStatementSupport method createEffective.
@Override
protected ModuleEffectiveStatement createEffective(final Current<Unqualified, ModuleStatement> stmt, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
if (substatements.isEmpty()) {
throw noNamespace(stmt);
}
final List<Submodule> submodules = new ArrayList<>();
for (StmtContext<?, ?, ?> submoduleCtx : submoduleContexts(stmt)) {
final EffectiveStatement<?, ?> submodule = submoduleCtx.buildEffective();
verify(submodule instanceof Submodule, "Submodule statement %s is not a Submodule", submodule);
submodules.add((Submodule) submodule);
}
final QNameModule qnameModule = verifyNotNull(stmt.namespaceItem(QNameModuleNamespace.class, Empty.value()));
try {
return new ModuleEffectiveStatementImpl(stmt, substatements, submodules, qnameModule);
} catch (SubstatementIndexingException e) {
throw new SourceException(e.getMessage(), stmt, e);
}
}
Aggregations