import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YinDomSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YinTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParser;
import org.opendaylight.yangtools.yang.parser.api.YangParserException;
import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YinTextToDomTransformer;
final class DefaultYangParser implements YangParser {
static final @NonNull Collection<Class<? extends SchemaSourceRepresentation>> REPRESENTATIONS =
- ImmutableList.of(IRSchemaSource.class, YangTextSchemaSource.class, YinDomSchemaSource.class,
+ ImmutableList.of(YangIRSchemaSource.class, YangTextSchemaSource.class, YinDomSchemaSource.class,
YinXmlSchemaSource.class, YinTextSchemaSource.class);
private final BuildAction buildAction;
static StatementStreamSource sourceToStatementStream(final SchemaSourceRepresentation source)
throws IOException, YangSyntaxErrorException {
requireNonNull(source);
- if (source instanceof IRSchemaSource) {
- return YangStatementStreamSource.create((IRSchemaSource) source);
+ if (source instanceof YangIRSchemaSource) {
+ return YangStatementStreamSource.create((YangIRSchemaSource) source);
} else if (source instanceof YangTextSchemaSource) {
return YangStatementStreamSource.create((YangTextSchemaSource) source);
} else if (source instanceof YinDomSchemaSource) {
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParser;
import org.opendaylight.yangtools.yang.parser.api.YangParserException;
import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.YangModelDependencyInfo;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-final class AssembleSources implements AsyncFunction<List<IRSchemaSource>, EffectiveModelContext> {
+final class AssembleSources implements AsyncFunction<List<YangIRSchemaSource>, EffectiveModelContext> {
private static final Logger LOG = LoggerFactory.getLogger(AssembleSources.class);
- private final @NonNull Function<IRSchemaSource, SourceIdentifier> getIdentifier;
+ private final @NonNull Function<YangIRSchemaSource, SourceIdentifier> getIdentifier;
private final @NonNull SchemaContextFactoryConfiguration config;
private final @NonNull YangParserFactory parserFactory;
this.parserFactory = parserFactory;
this.config = config;
getIdentifier = switch (config.getStatementParserMode()) {
- case DEFAULT_MODE -> IRSchemaSource::getIdentifier;
+ case DEFAULT_MODE -> YangIRSchemaSource::getIdentifier;
};
}
@Override
- public FluentFuture<EffectiveModelContext> apply(final List<IRSchemaSource> sources)
+ public FluentFuture<EffectiveModelContext> apply(final List<YangIRSchemaSource> sources)
throws SchemaResolutionException, ReactorException {
- final Map<SourceIdentifier, IRSchemaSource> srcs = Maps.uniqueIndex(sources, getIdentifier);
+ final Map<SourceIdentifier, YangIRSchemaSource> srcs = Maps.uniqueIndex(sources, getIdentifier);
final Map<SourceIdentifier, YangModelDependencyInfo> deps =
Maps.transformValues(srcs, YangModelDependencyInfo::forIR);
config.getSupportedFeatures().ifPresent(parser::setSupportedFeatures);
config.getModulesDeviatedByModules().ifPresent(parser::setModulesWithSupportedDeviations);
- for (final Entry<SourceIdentifier, IRSchemaSource> entry : srcs.entrySet()) {
+ for (final Entry<SourceIdentifier, YangIRSchemaSource> entry : srcs.entrySet()) {
try {
parser.addSource(entry.getValue());
} catch (YangSyntaxErrorException | IOException e) {
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final Stopwatch sw = Stopwatch.createStarted();
// Request all sources be loaded
- ListenableFuture<List<IRSchemaSource>> sf = Futures.allAsList(Collections2.transform(sources,
- identifier -> repository.getSchemaSource(identifier, IRSchemaSource.class)));
+ ListenableFuture<List<YangIRSchemaSource>> sf = Futures.allAsList(Collections2.transform(sources,
+ identifier -> repository.getSchemaSource(identifier, YangIRSchemaSource.class)));
// Detect mismatch between requested Source IDs and IDs that are extracted from parsed source
// Also remove duplicates if present
import java.util.Set;
import org.gaul.modernizer_maven_annotations.SuppressModernizer;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressModernizer
-final class SourceIdMismatchDetector implements Function<List<IRSchemaSource>, List<IRSchemaSource>> {
+final class SourceIdMismatchDetector implements Function<List<YangIRSchemaSource>, List<YangIRSchemaSource>> {
private static final Logger LOG = LoggerFactory.getLogger(SourceIdMismatchDetector.class);
private final Set<SourceIdentifier> sourceIdentifiers;
}
@Override
- public List<IRSchemaSource> apply(final List<IRSchemaSource> input) {
+ public List<YangIRSchemaSource> apply(final List<YangIRSchemaSource> input) {
final Iterator<SourceIdentifier> srcIt = sourceIdentifiers.iterator();
- final Iterator<IRSchemaSource> it = input.iterator();
-
- final Map<SourceIdentifier, IRSchemaSource> filtered = new LinkedHashMap<>();
- while (it.hasNext()) {
- final IRSchemaSource irSchemaSource = it.next();
+ final Map<SourceIdentifier, YangIRSchemaSource> filtered = new LinkedHashMap<>();
+ for (YangIRSchemaSource irSchemaSource : input) {
final SourceIdentifier realSId = irSchemaSource.getIdentifier();
if (srcIt.hasNext()) {
final SourceIdentifier expectedSId = srcIt.next();
}
}
- final IRSchemaSource prev = filtered.put(realSId, irSchemaSource);
+ final YangIRSchemaSource prev = filtered.put(realSId, irSchemaSource);
if (prev != null) {
LOG.warn("Duplicate source for module {} detected in reactor", realSId);
}
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.GuavaSchemaSourceCache;
import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private final Multimap<SourceIdentifier, YangTextSchemaSource> texts = ArrayListMultimap.create();
private final AtomicReference<Optional<EffectiveModelContext>> currentSchemaContext =
new AtomicReference<>(Optional.empty());
- private final GuavaSchemaSourceCache<IRSchemaSource> cache;
+ private final GuavaSchemaSourceCache<YangIRSchemaSource> cache;
private final SchemaListenerRegistration transReg;
private final SchemaSourceRegistry registry;
private final SchemaRepository repository;
final TextToIRTransformer t = TextToIRTransformer.create(repository, registry);
transReg = registry.registerSchemaSourceListener(t);
- cache = GuavaSchemaSourceCache.createSoftCache(registry, IRSchemaSource.class, SOURCE_LIFETIME);
+ cache = GuavaSchemaSourceCache.createSoftCache(registry, YangIRSchemaSource.class, SOURCE_LIFETIME);
}
public static @NonNull YangTextSchemaContextResolver create(final String name) {
throws SchemaSourceException, IOException, YangSyntaxErrorException {
checkArgument(source != null);
- final IRSchemaSource ast = TextToIRTransformer.transformText(source);
+ final YangIRSchemaSource ast = TextToIRTransformer.transformText(source);
LOG.trace("Resolved source {} to source {}", source, ast);
// AST carries an accurate identifier, check if it matches the one supplied by the source. If it
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
public abstract class AbstractSchemaRepositoryTest {
.createEffectiveModelContext(requiredSources);
}
- private static SettableSchemaProvider<IRSchemaSource> assertYangTextResource(final String resourceName) {
- final IRSchemaSource yangSource;
+ private static SettableSchemaProvider<YangIRSchemaSource> assertYangTextResource(final String resourceName) {
+ final YangIRSchemaSource yangSource;
try {
yangSource = TextToIRTransformer.transformText(YangTextSchemaSource.forResource(resourceName));
} catch (YangSyntaxErrorException | IOException e) {
throw new AssertionError("Failed to parse " + resourceName, e);
}
- return SettableSchemaProvider.createImmediate(yangSource, IRSchemaSource.class);
+ return SettableSchemaProvider.createImmediate(yangSource, YangIRSchemaSource.class);
}
}
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
public class MultipleRevImportBug6875Test {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-multiple-rev-import-test");
- final SettableSchemaProvider<IRSchemaSource> foo = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> foo = getSourceProvider(
"/rfc7950/bug6875/yang1-1/foo.yang");
- final SettableSchemaProvider<IRSchemaSource> bar1 = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> bar1 = getSourceProvider(
"/rfc7950/bug6875/yang1-1/bar@1999-01-01.yang");
- final SettableSchemaProvider<IRSchemaSource> bar2 = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> bar2 = getSourceProvider(
"/rfc7950/bug6875/yang1-1/bar@2017-02-06.yang");
- final SettableSchemaProvider<IRSchemaSource> bar3 = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> bar3 = getSourceProvider(
"/rfc7950/bug6875/yang1-1/bar@1970-01-01.yang");
setAndRegister(sharedSchemaRepository, foo);
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-multiple-rev-import-test");
- final SettableSchemaProvider<IRSchemaSource> foo = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> foo = getSourceProvider(
"/rfc7950/bug6875/yang1-0/foo.yang");
- final SettableSchemaProvider<IRSchemaSource> bar1 = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> bar1 = getSourceProvider(
"/rfc7950/bug6875/yang1-0/bar@1999-01-01.yang");
- final SettableSchemaProvider<IRSchemaSource> bar2 = getSourceProvider(
+ final SettableSchemaProvider<YangIRSchemaSource> bar2 = getSourceProvider(
"/rfc7950/bug6875/yang1-0/bar@2017-02-06.yang");
setAndRegister(sharedSchemaRepository, foo);
}
private static void setAndRegister(final SharedSchemaRepository sharedSchemaRepository,
- final SettableSchemaProvider<IRSchemaSource> source) {
+ final SettableSchemaProvider<YangIRSchemaSource> source) {
source.register(sharedSchemaRepository);
source.setResult();
}
- private static SettableSchemaProvider<IRSchemaSource> getSourceProvider(final String resourceName)
+ private static SettableSchemaProvider<YangIRSchemaSource> getSourceProvider(final String resourceName)
throws Exception {
final YangTextSchemaSource yangSource = YangTextSchemaSource.forResource(resourceName);
return SettableSchemaProvider.createImmediate(TextToIRTransformer.transformText(yangSource),
- IRSchemaSource.class);
+ YangIRSchemaSource.class);
}
private static QName foo(final String localName) {
import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
public class OpenconfigVerSharedSchemaRepositoryTest {
public void testSharedSchemaRepository() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("shared-schema-repo-test");
- final SettableSchemaProvider<IRSchemaSource> bar = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> bar = getImmediateYangSourceProviderFromResource(
"/openconfig-version/shared-schema-repository/bar@2016-01-01.yang");
bar.register(sharedSchemaRepository);
bar.setResult();
- final SettableSchemaProvider<IRSchemaSource> foo = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> foo = getImmediateYangSourceProviderFromResource(
"/openconfig-version/shared-schema-repository/foo.yang");
foo.register(sharedSchemaRepository);
foo.setResult();
- final SettableSchemaProvider<IRSchemaSource> semVer = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> semVer = getImmediateYangSourceProviderFromResource(
"/openconfig-version/shared-schema-repository/openconfig-extensions.yang");
semVer.register(sharedSchemaRepository);
semVer.setResult();
assertEquals(moduleSize, schemaContext.getModules().size());
}
- static SettableSchemaProvider<IRSchemaSource> getImmediateYangSourceProviderFromResource(final String resourceName)
- throws Exception {
+ static SettableSchemaProvider<YangIRSchemaSource> getImmediateYangSourceProviderFromResource(
+ final String resourceName) throws Exception {
final YangTextSchemaSource yangSource = YangTextSchemaSource.forResource(resourceName);
return SettableSchemaProvider.createImmediate(TextToIRTransformer.transformText(yangSource),
- IRSchemaSource.class);
+ YangIRSchemaSource.class);
}
}
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
s1 = source1.getIdentifier();
s2 = source2.getIdentifier();
- final SettableSchemaProvider<IRSchemaSource> provider =
+ final SettableSchemaProvider<YangIRSchemaSource> provider =
SharedSchemaRepositoryTest.getImmediateYangSourceProviderFromResource(
"/no-revision/imported@2012-12-12.yang");
provider.setResult();
// Register the same provider under source id without revision
final SourceIdentifier sIdWithoutRevision = new SourceIdentifier(provider.getId().name());
repository.registerSchemaSource(provider, PotentialSchemaSource.create(
- sIdWithoutRevision, IRSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
+ sIdWithoutRevision, YangIRSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
final SharedEffectiveModelContextFactory sharedSchemaContextFactory =
new SharedEffectiveModelContextFactory(repository, config);
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
public class SharedSchemaRepositoryTest {
-
@Test
public void testSourceWithAndWithoutRevision() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
final SourceIdentifier id2 = loadAndRegisterSource(sharedSchemaRepository,
"/no-revision/imported@2012-12-12.yang");
- ListenableFuture<IRSchemaSource> source = sharedSchemaRepository.getSchemaSource(idNoRevision,
- IRSchemaSource.class);
+ ListenableFuture<YangIRSchemaSource> source = sharedSchemaRepository.getSchemaSource(idNoRevision,
+ YangIRSchemaSource.class);
assertEquals(idNoRevision, source.get().getIdentifier());
- source = sharedSchemaRepository.getSchemaSource(id2, IRSchemaSource.class);
+ source = sharedSchemaRepository.getSchemaSource(id2, YangIRSchemaSource.class);
assertEquals(id2, source.get().getIdentifier());
}
private static SourceIdentifier loadAndRegisterSource(final SharedSchemaRepository sharedSchemaRepository,
final String resourceName) throws Exception {
- final SettableSchemaProvider<IRSchemaSource> sourceProvider = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> sourceProvider = getImmediateYangSourceProviderFromResource(
resourceName);
sourceProvider.setResult();
final SourceIdentifier idNoRevision = sourceProvider.getId();
public void testSimpleSchemaContext() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
- final SettableSchemaProvider<IRSchemaSource> remoteInetTypesYang = getImmediateYangSourceProviderFromResource(
- "/ietf/ietf-inet-types@2010-09-24.yang");
+ final SettableSchemaProvider<YangIRSchemaSource> remoteInetTypesYang =
+ getImmediateYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang");
remoteInetTypesYang.register(sharedSchemaRepository);
- final ListenableFuture<IRSchemaSource> registeredSourceFuture = sharedSchemaRepository.getSchemaSource(
- remoteInetTypesYang.getId(), IRSchemaSource.class);
+ final ListenableFuture<YangIRSchemaSource> registeredSourceFuture = sharedSchemaRepository.getSchemaSource(
+ remoteInetTypesYang.getId(), YangIRSchemaSource.class);
assertFalse(registeredSourceFuture.isDone());
final EffectiveModelContextFactory fact = sharedSchemaRepository.createEffectiveModelContextFactory();
public void testTwoSchemaContextsSharingSource() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
- final SettableSchemaProvider<IRSchemaSource> remoteInetTypesYang = getImmediateYangSourceProviderFromResource(
- "/ietf/ietf-inet-types@2010-09-24.yang");
+ final SettableSchemaProvider<YangIRSchemaSource> remoteInetTypesYang =
+ getImmediateYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang");
remoteInetTypesYang.register(sharedSchemaRepository);
remoteInetTypesYang.setResult();
- final SettableSchemaProvider<IRSchemaSource> remoteTopologyYang = getImmediateYangSourceProviderFromResource(
- "/ietf/network-topology@2013-10-21.yang");
+ final SettableSchemaProvider<YangIRSchemaSource> remoteTopologyYang =
+ getImmediateYangSourceProviderFromResource("/ietf/network-topology@2013-10-21.yang");
remoteTopologyYang.register(sharedSchemaRepository);
remoteTopologyYang.setResult();
- final SettableSchemaProvider<IRSchemaSource> remoteModuleNoRevYang =
+ final SettableSchemaProvider<YangIRSchemaSource> remoteModuleNoRevYang =
getImmediateYangSourceProviderFromResource("/no-revision/module-without-revision.yang");
remoteModuleNoRevYang.register(sharedSchemaRepository);
public void testFailedSchemaContext() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
- final SettableSchemaProvider<IRSchemaSource> remoteInetTypesYang = getImmediateYangSourceProviderFromResource(
- "/ietf/ietf-inet-types@2010-09-24.yang");
+ final SettableSchemaProvider<YangIRSchemaSource> remoteInetTypesYang =
+ getImmediateYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang");
remoteInetTypesYang.register(sharedSchemaRepository);
final EffectiveModelContextFactory fact = sharedSchemaRepository.createEffectiveModelContextFactory();
public void testDifferentCosts() throws Exception {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository("netconf-mounts");
- final SettableSchemaProvider<IRSchemaSource> immediateInetTypesYang = spy(
+ final SettableSchemaProvider<YangIRSchemaSource> immediateInetTypesYang = spy(
getImmediateYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang"));
immediateInetTypesYang.register(sharedSchemaRepository);
immediateInetTypesYang.setResult();
- final SettableSchemaProvider<IRSchemaSource> remoteInetTypesYang = spy(
+ final SettableSchemaProvider<YangIRSchemaSource> remoteInetTypesYang = spy(
getRemoteYangSourceProviderFromResource("/ietf/ietf-inet-types@2010-09-24.yang"));
remoteInetTypesYang.register(sharedSchemaRepository);
remoteInetTypesYang.setResult();
assertEquals(moduleSize, schemaContext.getModules().size());
}
- static SettableSchemaProvider<IRSchemaSource> getRemoteYangSourceProviderFromResource(final String resourceName)
+ static SettableSchemaProvider<YangIRSchemaSource> getRemoteYangSourceProviderFromResource(final String resourceName)
throws Exception {
final YangTextSchemaSource yangSource = YangTextSchemaSource.forResource(resourceName);
return SettableSchemaProvider.createRemote(TextToIRTransformer.transformText(yangSource),
- IRSchemaSource.class);
+ YangIRSchemaSource.class);
}
- static SettableSchemaProvider<IRSchemaSource> getImmediateYangSourceProviderFromResource(final String resourceName)
- throws Exception {
+ static SettableSchemaProvider<YangIRSchemaSource> getImmediateYangSourceProviderFromResource(
+ final String resourceName) throws Exception {
final YangTextSchemaSource yangSource = YangTextSchemaSource.forResource(resourceName);
return SettableSchemaProvider.createImmediate(TextToIRTransformer.transformText(yangSource),
- IRSchemaSource.class);
+ YangIRSchemaSource.class);
}
}
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
public class SharedSchemaRepositoryWithFeaturesTest {
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
- final SettableSchemaProvider<IRSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
"/if-feature-resolution-test/shared-schema-repository/foobar.yang");
foobar.register(sharedSchemaRepository);
foobar.setResult();
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
- final SettableSchemaProvider<IRSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
"/if-feature-resolution-test/shared-schema-repository/foobar.yang");
foobar.register(sharedSchemaRepository);
foobar.setResult();
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
- final SettableSchemaProvider<IRSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
+ final SettableSchemaProvider<YangIRSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
"/if-feature-resolution-test/shared-schema-repository/foobar.yang");
foobar.register(sharedSchemaRepository);
foobar.setResult();
QName.create(module.getQNameModule(), "test-leaf-c"));
}
- private static SettableSchemaProvider<IRSchemaSource> getImmediateYangSourceProviderFromResource(
+ private static SettableSchemaProvider<YangIRSchemaSource> getImmediateYangSourceProviderFromResource(
final String resourceName) throws Exception {
final YangTextSchemaSource yangSource = YangTextSchemaSource.forResource(resourceName);
return SettableSchemaProvider.createImmediate(TextToIRTransformer.transformText(yangSource),
- IRSchemaSource.class);
+ YangIRSchemaSource.class);
}
private static void assertSchemaContext(final SchemaContext schemaContext, final int moduleSize) {
import org.opendaylight.yangtools.yang.ir.IRStatement;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceTransformer;
import org.opendaylight.yangtools.yang.parser.rfc7950.antlr.IRSupport;
@Beta
-public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextSchemaSource, IRSchemaSource> {
+public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextSchemaSource, YangIRSchemaSource> {
private TextToIRTransformer(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
- super(provider, YangTextSchemaSource.class, consumer, IRSchemaSource.class,
+ super(provider, YangTextSchemaSource.class, consumer, YangIRSchemaSource.class,
input -> Futures.immediateFuture(transformText(input)));
}
return new TextToIRTransformer(provider, consumer);
}
- public static @NonNull IRSchemaSource transformText(final YangTextSchemaSource text)
+ public static @NonNull YangIRSchemaSource transformText(final YangTextSchemaSource text)
throws YangSyntaxErrorException, IOException {
final IRStatement rootStatement = IRSupport.createStatement(YangStatementStreamSource.parseYangSource(text));
final String name = YangModelDependencyInfo.safeStringArgument(text.getIdentifier(), rootStatement, "name");
final String latestRevision = YangModelDependencyInfo.getLatestRevision(rootStatement, text.getIdentifier());
final SourceIdentifier sourceId = new SourceIdentifier(name, latestRevision);
- return new IRSchemaSource(sourceId, rootStatement, text.getSymbolicName().orElse(null));
+ return new YangIRSchemaSource(sourceId, rootStatement, text.getSymbolicName().orElse(null));
}
}
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.spi.source.ExplicitStatement;
* @return {@link YangModelDependencyInfo}
* @throws IllegalArgumentException If the root statement is not a valid YANG module/submodule
*/
- public static @NonNull YangModelDependencyInfo forIR(final IRSchemaSource source) {
+ public static @NonNull YangModelDependencyInfo forIR(final YangIRSchemaSource source) {
return forIR(source.getRootStatement(), source.getIdentifier());
}
import org.opendaylight.yangtools.yang.ir.IRStatement;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.antlr.YangStatementLexer;
import org.opendaylight.yangtools.yang.parser.antlr.YangStatementParser;
}
/**
- * Create a {@link YangStatementStreamSource} for a {@link IRSchemaSource}.
+ * Create a {@link YangStatementStreamSource} for a {@link YangIRSchemaSource}.
*
* @param source YangTextSchemaSource, must not be null
* @return A new {@link YangStatementStreamSource}
* @throws NullPointerException if {@code source} is null
*/
- public static YangStatementStreamSource create(final IRSchemaSource source) {
+ public static YangStatementStreamSource create(final YangIRSchemaSource source) {
return create(source.getIdentifier(), source.getRootStatement(), source.getSymbolicName().orElse(null));
}
import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorException;
import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorFactory;
import org.opendaylight.yangtools.yang.common.YangConstants;
+import org.opendaylight.yangtools.yang.model.repo.api.YangIRSchemaSource;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.api.YangParser;
import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.parser.api.YangParserException;
import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.rfc7950.repo.IRSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
final Stopwatch watch = Stopwatch.createStarted();
- final List<Entry<YangTextSchemaSource, IRSchemaSource>> parsed = yangFilesInProject.parallelStream()
+ final List<Entry<YangTextSchemaSource, YangIRSchemaSource>> parsed = yangFilesInProject.parallelStream()
.map(file -> {
final YangTextSchemaSource textSource = YangTextSchemaSource.forPath(file.toPath());
try {
@SuppressWarnings("checkstyle:illegalCatch")
private Optional<ProcessorModuleReactor> createReactor(final List<File> yangFilesInProject,
final YangParserConfiguration parserConfig, final Collection<ScannedDependency> dependencies,
- final List<Entry<YangTextSchemaSource, IRSchemaSource>> parsed) throws MojoExecutionException {
+ final List<Entry<YangTextSchemaSource, YangIRSchemaSource>> parsed) throws MojoExecutionException {
try {
final List<YangTextSchemaSource> sourcesInProject = new ArrayList<>(yangFilesInProject.size());
final YangParser parser = parserFactory.createParser(parserConfig);
- for (final Entry<YangTextSchemaSource, IRSchemaSource> entry : parsed) {
+ for (final Entry<YangTextSchemaSource, YangIRSchemaSource> entry : parsed) {
final YangTextSchemaSource textSource = entry.getKey();
- final IRSchemaSource astSource = entry.getValue();
+ final YangIRSchemaSource astSource = entry.getValue();
parser.addSource(astSource);
if (!astSource.getIdentifier().equals(textSource.getIdentifier())) {
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-ir</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-model-api</artifactId>
requires transitive com.google.common;
requires transitive org.opendaylight.yangtools.concepts;
requires transitive org.opendaylight.yangtools.yang.common;
+ requires transitive org.opendaylight.yangtools.yang.ir;
requires transitive org.opendaylight.yangtools.yang.model.api;
requires org.opendaylight.yangtools.util;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.yangtools.yang.parser.rfc7950.repo;
+package org.opendaylight.yangtools.yang.model.repo.api;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import org.opendaylight.yangtools.yang.ir.IRKeyword;
import org.opendaylight.yangtools.yang.ir.IRKeyword.Unqualified;
import org.opendaylight.yangtools.yang.ir.IRStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangSchemaSourceRepresentation;
@Beta
-public final class IRSchemaSource extends AbstractSimpleIdentifiable<SourceIdentifier>
+public final class YangIRSchemaSource extends AbstractSimpleIdentifiable<SourceIdentifier>
implements YangSchemaSourceRepresentation {
private final @NonNull IRStatement rootStatement;
private final @Nullable String symbolicName;
- public IRSchemaSource(final @NonNull SourceIdentifier identifier, final @NonNull IRStatement rootStatement,
+ public YangIRSchemaSource(final @NonNull SourceIdentifier identifier, final @NonNull IRStatement rootStatement,
final @Nullable String symbolicName) {
super(identifier);
this.rootStatement = requireNonNull(rootStatement);
}
@Override
- public Class<IRSchemaSource> getType() {
- return IRSchemaSource.class;
+ public Class<YangIRSchemaSource> getType() {
+ return YangIRSchemaSource.class;
}
/**