Rename YangIRSchemaSource 67/109667/3
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 7 Jan 2024 18:13:13 +0000 (19:13 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 7 Jan 2024 18:20:43 +0000 (19:20 +0100)
YangIRSource is a more concise name. Also add a bit of documentation.

Change-Id: I259c41c2defd0418854e8766f730dda83e3cb4cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangIRSource.java [moved from model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangIRSchemaSource.java with 70% similarity]
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/DefaultYangParser.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/AssembleSources.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SharedEffectiveModelContextFactory.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/SourceIdMismatchDetector.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/YangTextSchemaContextResolver.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/AbstractSchemaRepositoryTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedEffectiveModelContextFactoryTest.java
parser/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryTest.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/TextToIRTransformer.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangIRSourceInfoExtractor.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangStatementStreamSource.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/antlr/IOSupportTest.java
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java

similarity index 70%
rename from model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangIRSchemaSource.java
rename to model/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/source/YangIRSource.java
index 641e72022616046cb134871877c31820f4e51ac1..e5e9a12358878b7554319476f12e84a72443077c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.model.spi.source;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.annotations.Beta;
-import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.yang.ir.IRKeyword.Unqualified;
 import org.opendaylight.yangtools.yang.ir.IRStatement;
@@ -20,16 +20,20 @@ import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.source.YangSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.spi.meta.StatementDeclarations;
 
-public final class YangIRSchemaSource implements YangSourceRepresentation {
-    private final @NonNull SourceIdentifier sourceId;
-    private final @NonNull IRStatement rootStatement;
+/**
+ * A {@link YangSourceRepresentation} backed by an {@link IRStatement}.
+ */
+@NonNullByDefault
+public final class YangIRSource implements YangSourceRepresentation {
+    private final SourceIdentifier sourceId;
+    private final IRStatement statement;
     private final @Nullable String symbolicName;
 
-    public YangIRSchemaSource(final @NonNull SourceIdentifier sourceId, final @NonNull IRStatement rootStatement,
+    public YangIRSource(final SourceIdentifier sourceId, final IRStatement statement,
             final @Nullable String symbolicName) {
-        final var rootKeyword = rootStatement.keyword();
+        final var rootKeyword = statement.keyword();
         if (!(rootKeyword instanceof Unqualified)) {
-            throw new StatementSourceException(refOf(sourceId, rootStatement),
+            throw new StatementSourceException(refOf(sourceId, statement),
                 "Root statement has invalid keyword " + rootKeyword);
         }
         final var rootName = rootKeyword.identifier();
@@ -38,15 +42,14 @@ public final class YangIRSchemaSource implements YangSourceRepresentation {
             case "submodule":
                 break;
             default:
-                throw new StatementSourceException(refOf(sourceId, rootStatement),
+                throw new StatementSourceException(refOf(sourceId, statement),
                     "Invalid root statement keyword " + rootName);
         }
-        if (rootStatement.argument() == null) {
-            throw new StatementSourceException(refOf(sourceId, rootStatement),
-                "Root statement does not have an argument");
+        if (statement.argument() == null) {
+            throw new StatementSourceException(refOf(sourceId, statement), "Root statement does not have an argument");
         }
         this.sourceId = requireNonNull(sourceId);
-        this.rootStatement = rootStatement;
+        this.statement = statement;
         this.symbolicName = symbolicName;
     }
 
@@ -56,13 +59,13 @@ public final class YangIRSchemaSource implements YangSourceRepresentation {
     }
 
     @Override
-    public String symbolicName() {
+    public @Nullable String symbolicName() {
         return symbolicName;
     }
 
     @Override
-    public Class<YangIRSchemaSource> getType() {
-        return YangIRSchemaSource.class;
+    public Class<YangIRSource> getType() {
+        return YangIRSource.class;
     }
 
     /**
@@ -70,8 +73,8 @@ public final class YangIRSchemaSource implements YangSourceRepresentation {
      *
      * @return Root statement.
      */
-    public @NonNull IRStatement rootStatement() {
-        return rootStatement;
+    public IRStatement statement() {
+        return statement;
     }
 
     // FIXME: hide this method
index b90eab781d628847b24f88d8b1355a40e65f5bfc..2a652ad2baf47afbec90a18a12e7625c81f28282 100644 (file)
@@ -22,7 +22,7 @@ import org.opendaylight.yangtools.yang.model.api.source.SourceRepresentation;
 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.api.source.YinTextSource;
 import org.opendaylight.yangtools.yang.model.api.stmt.FeatureSet;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.model.spi.source.YinDomSource;
 import org.opendaylight.yangtools.yang.model.spi.source.YinXmlSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParser;
@@ -39,7 +39,7 @@ import org.xml.sax.SAXException;
 final class DefaultYangParser implements YangParser {
     static final @NonNull ImmutableSet<Class<? extends SourceRepresentation>> REPRESENTATIONS = ImmutableSet.of(
         // In order of preference
-        YangIRSchemaSource.class,
+        YangIRSource.class,
         YangTextSource.class,
         YinDomSource.class,
         YinXmlSource.class,
@@ -107,7 +107,7 @@ final class DefaultYangParser implements YangParser {
     static StatementStreamSource sourceToStatementStream(final SourceRepresentation source)
             throws IOException, YangSyntaxErrorException {
         requireNonNull(source);
-        if (source instanceof YangIRSchemaSource irSource) {
+        if (source instanceof YangIRSource irSource) {
             return YangStatementStreamSource.create(irSource);
         } else if (source instanceof YangTextSource yangSource) {
             return YangStatementStreamSource.create(yangSource);
index c4eff5f1a2ed6c4036b866788b08ce24a5c31f24..18ab8a2ba75a1ffd82c5ca0e4d2dcf5639cecd00 100644 (file)
@@ -19,7 +19,7 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfiguration;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaResolutionException;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
@@ -28,10 +28,10 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class AssembleSources implements AsyncFunction<List<YangIRSchemaSource>, EffectiveModelContext> {
+final class AssembleSources implements AsyncFunction<List<YangIRSource>, EffectiveModelContext> {
     private static final Logger LOG = LoggerFactory.getLogger(AssembleSources.class);
 
-    private final @NonNull Function<YangIRSchemaSource, SourceIdentifier> getIdentifier;
+    private final @NonNull Function<YangIRSource, SourceIdentifier> getIdentifier;
     private final @NonNull SchemaContextFactoryConfiguration config;
     private final @NonNull YangParserFactory parserFactory;
 
@@ -40,12 +40,12 @@ final class AssembleSources implements AsyncFunction<List<YangIRSchemaSource>, E
         this.parserFactory = parserFactory;
         this.config = config;
         getIdentifier = switch (config.getStatementParserMode()) {
-            case DEFAULT_MODE -> YangIRSchemaSource::sourceId;
+            case DEFAULT_MODE -> YangIRSource::sourceId;
         };
     }
 
     @Override
-    public FluentFuture<EffectiveModelContext> apply(final List<YangIRSchemaSource> sources) {
+    public FluentFuture<EffectiveModelContext> apply(final List<YangIRSource> sources) {
         final var srcs = Maps.uniqueIndex(sources, getIdentifier);
         final var deps = Maps.transformValues(srcs, YangIRSourceInfoExtractor::forIR);
         LOG.debug("Resolving dependency reactor {}", deps);
index ac39917ba48dbadbf1a6ba5153cebae8bf66ab9a..52626d877a135200ca46b01e8404a407c99dc8be 100644 (file)
@@ -40,7 +40,7 @@ import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 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.SchemaRepository;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -182,8 +182,8 @@ final class SharedEffectiveModelContextFactory implements EffectiveModelContextF
         final Stopwatch sw = Stopwatch.createStarted();
 
         // Request all sources be loaded
-        ListenableFuture<List<YangIRSchemaSource>> sf = Futures.allAsList(Collections2.transform(sources,
-            identifier -> repository.getSchemaSource(identifier, YangIRSchemaSource.class)));
+        ListenableFuture<List<YangIRSource>> sf = Futures.allAsList(Collections2.transform(sources,
+            identifier -> repository.getSchemaSource(identifier, YangIRSource.class)));
 
         // Detect mismatch between requested Source IDs and IDs that are extracted from parsed source
         // Also remove duplicates if present
index 56be3949637968efa1307c7293339d8831cf4ed2..5da30bd26e2d7513d6858cce7a7dadf3c895054f 100644 (file)
@@ -11,19 +11,17 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Function;
 import com.google.common.collect.ImmutableList;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 import org.gaul.modernizer_maven_annotations.SuppressModernizer;
 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @SuppressModernizer
-final class SourceIdMismatchDetector implements Function<List<YangIRSchemaSource>, List<YangIRSchemaSource>> {
+final class SourceIdMismatchDetector implements Function<List<YangIRSource>, List<YangIRSource>> {
     private static final Logger LOG = LoggerFactory.getLogger(SourceIdMismatchDetector.class);
 
     private final Set<SourceIdentifier> sourceIdentifiers;
@@ -33,10 +31,10 @@ final class SourceIdMismatchDetector implements Function<List<YangIRSchemaSource
     }
 
     @Override
-    public List<YangIRSchemaSource> apply(final List<YangIRSchemaSource> input) {
-        final Iterator<SourceIdentifier> srcIt = sourceIdentifiers.iterator();
-        final Map<SourceIdentifier, YangIRSchemaSource> filtered = new LinkedHashMap<>();
-        for (YangIRSchemaSource irSchemaSource : input) {
+    public List<YangIRSource> apply(final List<YangIRSource> input) {
+        final var srcIt = sourceIdentifiers.iterator();
+        final var filtered = new LinkedHashMap<SourceIdentifier, YangIRSource>();
+        for (var irSchemaSource : input) {
             final SourceIdentifier realSId = irSchemaSource.sourceId();
             if (srcIt.hasNext()) {
                 final SourceIdentifier expectedSId = srcIt.next();
@@ -46,7 +44,7 @@ final class SourceIdMismatchDetector implements Function<List<YangIRSchemaSource
                 }
             }
 
-            final YangIRSchemaSource prev = filtered.put(realSId, irSchemaSource);
+            final var prev = filtered.put(realSId, irSchemaSource);
             if (prev != null) {
                 LOG.warn("Duplicate source for module {} detected in reactor", realSId);
             }
index d8e50bd385b0a9c5ce757d5274596a856b88cf17..d31c30a1a151dfa0587dbc01e526b17b9cd802b7 100644 (file)
@@ -53,7 +53,7 @@ import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
 import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
@@ -70,7 +70,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
     private final Map<QNameModule, List<ImmutableSet<String>>> registeredFeatures = new HashMap<>();
     private final AtomicReference<Optional<EffectiveModelContext>> currentSchemaContext =
             new AtomicReference<>(Optional.empty());
-    private final GuavaSchemaSourceCache<YangIRSchemaSource> cache;
+    private final GuavaSchemaSourceCache<YangIRSource> cache;
     private final SchemaSourceRegistry registry;
     private final SchemaRepository repository;
     private final Registration transReg;
@@ -85,7 +85,7 @@ public final class YangTextSchemaContextResolver implements AutoCloseable, Schem
         this.registry = requireNonNull(registry);
 
         transReg = registry.registerSchemaSourceListener(TextToIRTransformer.create(repository, registry));
-        cache = GuavaSchemaSourceCache.createSoftCache(registry, YangIRSchemaSource.class, SOURCE_LIFETIME);
+        cache = GuavaSchemaSourceCache.createSoftCache(registry, YangIRSource.class, SOURCE_LIFETIME);
     }
 
     public static @NonNull YangTextSchemaContextResolver create(final String name) {
index 8289b2da2b60987991e923fe16246fa23447c8bc..3ce7b9b63cb875ba3484ab6fd0b3e358438fd2d8 100644 (file)
@@ -23,7 +23,7 @@ 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.spi.source.URLYangTextSource;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
@@ -63,15 +63,15 @@ public abstract class AbstractSchemaRepositoryTest {
             .createEffectiveModelContext(requiredSources);
     }
 
-    static final SettableSchemaProvider<YangIRSchemaSource> assertYangTextResource(final String resourceName) {
-        final YangIRSchemaSource yangSource;
+    static final SettableSchemaProvider<YangIRSource> assertYangTextResource(final String resourceName) {
+        final YangIRSource yangSource;
         try {
             yangSource = TextToIRTransformer.transformText(
                 new URLYangTextSource(AbstractSchemaRepositoryTest.class.getResource(resourceName)));
         } catch (YangSyntaxErrorException | IOException e) {
             throw new AssertionError("Failed to parse " + resourceName, e);
         }
-        return SettableSchemaProvider.createImmediate(yangSource, YangIRSchemaSource.class);
+        return SettableSchemaProvider.createImmediate(yangSource, YangIRSource.class);
     }
 
     static final void assertSchemaContext(final EffectiveModelContext schemaContext, final int moduleSize) {
index df95c30ae07beb9c79aac47729d1fe3d075e7c96..d576ba4c30f4c3d21eed1c0d1180d55a5dba7bf7 100644 (file)
@@ -19,7 +19,7 @@ import java.util.concurrent.ExecutionException;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 
 class MultipleRevImportBug6875Test extends AbstractSchemaRepositoryTest {
     private static final String BAR_NS = "bar";
@@ -88,7 +88,7 @@ class MultipleRevImportBug6875Test extends AbstractSchemaRepositoryTest {
     }
 
     private static void setAndRegister(final SharedSchemaRepository sharedSchemaRepository,
-            final SettableSchemaProvider<YangIRSchemaSource> source) {
+            final SettableSchemaProvider<YangIRSource> source) {
         source.register(sharedSchemaRepository);
         source.setResult();
     }
index d5b1fcbe2f527959525f24d0e18f093075b57886..1e66e03f1f6dc29ca5b608b2ca2cfbf15dc95964 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.yangtools.yang.model.repo.api.SchemaContextFactoryConfig
 import org.opendaylight.yangtools.yang.model.repo.spi.PotentialSchemaSource;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 class SharedEffectiveModelContextFactoryTest {
@@ -74,7 +74,7 @@ class SharedEffectiveModelContextFactoryTest {
         // Register the same provider under source id without revision
         final var sIdWithoutRevision = new SourceIdentifier(provider.getId().name());
         repository.registerSchemaSource(provider, PotentialSchemaSource.create(sIdWithoutRevision,
-            YangIRSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
+            YangIRSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
 
         final var sharedSchemaContextFactory = new SharedEffectiveModelContextFactory(repository, config);
         final var schemaContext = sharedSchemaContextFactory.createEffectiveModelContext(
index de01a3e5d8aed89f86d9a8a4f2c3ff7144171702..c873245b04c99615a20379b09f92587fc143c721 100644 (file)
@@ -22,7 +22,7 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
 import org.opendaylight.yangtools.yang.model.spi.source.URLYangTextSource;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 
 class SharedSchemaRepositoryTest extends AbstractSchemaRepositoryTest {
@@ -33,9 +33,9 @@ class SharedSchemaRepositoryTest extends AbstractSchemaRepositoryTest {
         final var idNoRevision = loadAndRegisterSource(sharedSchemaRepository, "/no-revision/imported.yang");
         final var id2 = loadAndRegisterSource(sharedSchemaRepository, "/no-revision/imported@2012-12-12.yang");
 
-        var source = sharedSchemaRepository.getSchemaSource(idNoRevision, YangIRSchemaSource.class);
+        var source = sharedSchemaRepository.getSchemaSource(idNoRevision, YangIRSource.class);
         assertEquals(idNoRevision, source.get().sourceId());
-        source = sharedSchemaRepository.getSchemaSource(id2, YangIRSchemaSource.class);
+        source = sharedSchemaRepository.getSchemaSource(id2, YangIRSource.class);
         assertEquals(id2, source.get().sourceId());
     }
 
@@ -55,7 +55,7 @@ class SharedSchemaRepositoryTest extends AbstractSchemaRepositoryTest {
         final var remoteInetTypesYang = assertYangTextResource("/ietf/ietf-inet-types@2010-09-24.yang");
         remoteInetTypesYang.register(sharedSchemaRepository);
         final var registeredSourceFuture = sharedSchemaRepository.getSchemaSource(
-            remoteInetTypesYang.getId(), YangIRSchemaSource.class);
+            remoteInetTypesYang.getId(), YangIRSource.class);
         assertFalse(registeredSourceFuture.isDone());
 
         final var fact = sharedSchemaRepository.createEffectiveModelContextFactory();
@@ -151,10 +151,10 @@ class SharedSchemaRepositoryTest extends AbstractSchemaRepositoryTest {
         verify(immediateInetTypesYang).getSource(id);
     }
 
-    static SettableSchemaProvider<YangIRSchemaSource> getRemoteYangSourceProviderFromResource(final String resourceName)
+    static SettableSchemaProvider<YangIRSource> getRemoteYangSourceProviderFromResource(final String resourceName)
             throws Exception {
         return SettableSchemaProvider.createRemote(TextToIRTransformer.transformText(
             new URLYangTextSource(SharedSchemaRepositoryTest.class.getResource(resourceName))),
-            YangIRSchemaSource.class);
+            YangIRSource.class);
     }
 }
index 02049b03e8dad954dea2d3f68dc2abf8b5371177..cc2238fa94febd74e88f5966a138ddf3b2a4ce31 100644 (file)
@@ -15,14 +15,14 @@ import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceTransformer;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.antlr.IRSupport;
 
 @Beta
-public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextSource, YangIRSchemaSource> {
+public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextSource, YangIRSource> {
     private TextToIRTransformer(final SchemaRepository provider, final SchemaSourceRegistry consumer) {
-        super(provider, YangTextSource.class, consumer, YangIRSchemaSource.class,
+        super(provider, YangTextSource.class, consumer, YangIRSource.class,
             input -> Futures.immediateFuture(transformText(input)));
     }
 
@@ -31,10 +31,10 @@ public final class TextToIRTransformer extends SchemaSourceTransformer<YangTextS
         return new TextToIRTransformer(provider, consumer);
     }
 
-    public static @NonNull YangIRSchemaSource transformText(final YangTextSource text)
+    public static @NonNull YangIRSource transformText(final YangTextSource text)
             throws YangSyntaxErrorException, IOException {
         final var rootStatement = IRSupport.createStatement(YangStatementStreamSource.parseYangSource(text));
         final var info = YangIRSourceInfoExtractor.forIR(rootStatement, text.sourceId());
-        return new YangIRSchemaSource(info.sourceId(), rootStatement, text.symbolicName());
+        return new YangIRSource(info.sourceId(), rootStatement, text.symbolicName());
     }
 }
index 815f40e21c4f1f9b4d8117affcb93306202e6527..09b3161e5b7c0720eeed0ddbdd3b71111d628171 100644 (file)
@@ -25,11 +25,11 @@ import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.spi.meta.StatementDeclarations;
 import org.opendaylight.yangtools.yang.model.spi.source.SourceInfo;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.api.YangSyntaxErrorException;
 
 /**
- * Utility class for extract {@link SourceInfo} from a {@link YangIRSchemaSource}.
+ * Utility class for extract {@link SourceInfo} from a {@link YangIRSource}.
  */
 public final class YangIRSourceInfoExtractor {
     private static final String BELONGS_TO = YangStmtMapping.BELONGS_TO.getStatementName().getLocalName();
@@ -54,8 +54,8 @@ public final class YangIRSourceInfoExtractor {
      * @return {@link SourceInfo}
      * @throws IllegalArgumentException If the root statement is not a valid YANG module/submodule
      */
-    public static @NonNull SourceInfo forIR(final YangIRSchemaSource source) {
-        return forIR(source.rootStatement(), source.sourceId());
+    public static @NonNull SourceInfo forIR(final YangIRSource source) {
+        return forIR(source.statement(), source.sourceId());
     }
 
     /**
index a33af5692a0000c06760e90ecfd2fd3e19946d33..222ea5b67032c0ac2444ef4ec99f767b9d9b5873 100644 (file)
@@ -25,7 +25,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSourceReference;
 import org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.antlr.YangStatementLexer;
 import org.opendaylight.yangtools.yang.parser.antlr.YangStatementParser;
 import org.opendaylight.yangtools.yang.parser.antlr.YangStatementParser.FileContext;
@@ -42,8 +42,6 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
 /**
  * This class represents implementation of StatementStreamSource in order to emit YANG statements using supplied
  * StatementWriter.
- *
- * @author Robert Varga
  */
 @Beta
 public final class YangStatementStreamSource extends AbstractSimpleIdentifiable<SourceIdentifier>
@@ -73,14 +71,14 @@ public final class YangStatementStreamSource extends AbstractSimpleIdentifiable<
     }
 
     /**
-     * Create a {@link YangStatementStreamSource} for a {@link YangIRSchemaSource}.
+     * Create a {@link YangStatementStreamSource} for a {@link YangIRSource}.
      *
      * @param source YangTextSchemaSource, must not be null
      * @return A new {@link YangStatementStreamSource}
      * @throws NullPointerException if {@code source} is null
      */
-    public static YangStatementStreamSource create(final YangIRSchemaSource source) {
-        return create(source.sourceId(), source.rootStatement(), source.symbolicName());
+    public static YangStatementStreamSource create(final YangIRSource source) {
+        return create(source.sourceId(), source.statement(), source.symbolicName());
     }
 
     public static YangStatementStreamSource create(final SourceIdentifier identifier, final IRStatement rootStatement,
index fd74e9a273e81b5252796ba43d5760847d731481..6e835e43f897a120730767017da202aa7c479ae4 100644 (file)
@@ -18,12 +18,12 @@ import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 import org.opendaylight.yangtools.yang.ir.IOSupport;
 import org.opendaylight.yangtools.yang.ir.IRStatement;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.rfc7950.repo.TextToIRTransformer;
 import org.opendaylight.yangtools.yang.stmt.TestUtils;
 
 class IOSupportTest {
-    private static YangIRSchemaSource FOO;
+    private static YangIRSource FOO;
 
     @BeforeAll
     static void beforeClass() throws Exception {
@@ -32,13 +32,13 @@ class IOSupportTest {
 
     @Test
     void testSerializedSize() throws IOException {
-        final byte[] bytes = serialize(FOO.rootStatement());
+        final byte[] bytes = serialize(FOO.statement());
         assertEquals(485, bytes.length);
     }
 
     @Test
     void testSerdes() throws IOException {
-        final var orig = FOO.rootStatement();
+        final var orig = FOO.statement();
         assertEquals(orig, deserialize(serialize(orig)));
     }
 
index d6086b972ca6410fe1a5359711e01d65135ed8ec..29b71f11fc0474e251f6ecdc156a80c1f4d4d15d 100644 (file)
@@ -42,7 +42,7 @@ import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.source.YangTextSource;
 import org.opendaylight.yangtools.yang.model.spi.source.DelegatedYangTextSource;
 import org.opendaylight.yangtools.yang.model.spi.source.FileYangTextSource;
-import org.opendaylight.yangtools.yang.model.spi.source.YangIRSchemaSource;
+import org.opendaylight.yangtools.yang.model.spi.source.YangIRSource;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
 import org.opendaylight.yangtools.yang.parser.api.YangParserException;
 import org.opendaylight.yangtools.yang.parser.api.YangParserFactory;
@@ -390,7 +390,7 @@ class YangToSourcesProcessor {
     @SuppressWarnings("checkstyle:illegalCatch")
     private @NonNull ProcessorModuleReactor createReactor(final List<File> yangFilesInProject,
             final YangParserConfiguration parserConfig, final Collection<ScannedDependency> dependencies,
-            final List<Entry<FileYangTextSource, YangIRSchemaSource>> parsed) throws MojoExecutionException {
+            final List<Entry<FileYangTextSource, YangIRSource>> parsed) throws MojoExecutionException {
 
         try {
             final var sourcesInProject = new ArrayList<YangTextSource>(yangFilesInProject.size());