Bug 8307: Add the option for activating deviation statements
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / YangInferencePipeline.java
index 2e8585bf116d2635a5d0b2468dbd029ae2bdb20e..7b283fcb61bb7fc0f773005099184456315ccd10 100644 (file)
@@ -53,6 +53,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules;
 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
 import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
 import org.opendaylight.yangtools.yang.parser.spi.source.StmtOrderingNamespace;
@@ -67,12 +68,14 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.BitStatementRfc7950Su
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.CaseStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ChoiceStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ContainerStatementRfc7950Support;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.DeviateStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.EnumStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.GroupingStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.IdentityStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ImportStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.IncludeStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.InputStatementRfc7950Support;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.LeafListStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ListStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ModifierStatementImpl;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.ModuleStatementRfc7950Support;
@@ -80,7 +83,9 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.NotificationStatement
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.OutputStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.PatternStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.RefineStatementRfc7950Support;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.RpcStatementRfc7950Support;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.SubmoduleStatementRfc7950Support;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc7950.TypeStatementRfc7950Support;
 
 public final class YangInferencePipeline {
     public static final Set<YangVersion> SUPPORTED_VERSIONS = Sets.immutableEnumSet(VERSION_1, VERSION_1_1);
@@ -88,6 +93,7 @@ public final class YangInferencePipeline {
     public static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle
             .builder(SUPPORTED_VERSIONS).addSupport(global(ValidationBundlesNamespace.class))
             .addSupport(global(SupportedFeaturesNamespace.class))
+            .addSupport(global(ModulesDeviatedByModules.class))
             .build();
 
     public static final StatementSupportBundle PRE_LINKAGE_BUNDLE = StatementSupportBundle
@@ -104,6 +110,7 @@ public final class YangInferencePipeline {
             .addSupport(new PrefixStatementImpl.Definition())
             .addSupport(new YangVersionStatementImpl.Definition())
             .addSupport(new RevisionStatementImpl.Definition())
+            .addSupport(new RevisionDateStatementImpl.Definition())
             .addSupport(global(ModuleNameToNamespace.class))
             .addSupport(global(PreLinkageModuleNamespace.class))
             .addSupport(sourceLocal(ImpPrefixToNamespace.class))
@@ -113,7 +120,6 @@ public final class YangInferencePipeline {
     public static final StatementSupportBundle LINKAGE_BUNDLE = StatementSupportBundle
             .derivedFrom(PRE_LINKAGE_BUNDLE)
             .addSupport(new DescriptionStatementImpl.Definition())
-            .addSupport(new RevisionDateStatementImpl.Definition())
             .addSupport(new ReferenceStatementImpl.Definition())
             .addSupport(new ContactStatementImpl.Definition())
             .addSupport(new OrganizationStatementImpl.Definition())
@@ -158,7 +164,8 @@ public final class YangInferencePipeline {
             .addSupport(global(IdentityNamespace.class))
             .addSupport(new DefaultStatementImpl.Definition())
             .addSupport(new StatusStatementImpl.Definition())
-            .addSupport(new TypeStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1, new TypeStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1_1, new TypeStatementRfc7950Support())
             .addSupport(new UnitsStatementImpl.Definition())
             .addSupport(new RequireInstanceStatementImpl.Definition())
             .addVersionSpecificSupport(VERSION_1, new BitStatementImpl.Definition())
@@ -171,6 +178,7 @@ public final class YangInferencePipeline {
             .addVersionSpecificSupport(VERSION_1_1, new PatternStatementRfc7950Support())
             .addVersionSpecificSupport(VERSION_1_1, new ModifierStatementImpl.Definition())
             .addSupport(new RangeStatementImpl.Definition())
+            .addSupport(new KeyStatementImpl.Definition())
             .addVersionSpecificSupport(VERSION_1, new ContainerStatementImpl.Definition())
             .addVersionSpecificSupport(VERSION_1_1, new ContainerStatementRfc7950Support())
             .addVersionSpecificSupport(VERSION_1, new GroupingStatementImpl.Definition())
@@ -179,7 +187,8 @@ public final class YangInferencePipeline {
             .addVersionSpecificSupport(VERSION_1_1, new ListStatementRfc7950Support())
             .addSupport(new UniqueStatementImpl.Definition())
             .addVersionSpecificSupport(VERSION_1_1, new ActionStatementImpl.Definition())
-            .addSupport(new RpcStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1, new RpcStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1_1, new RpcStatementRfc7950Support())
             .addVersionSpecificSupport(VERSION_1, new InputStatementImpl.Definition())
             .addVersionSpecificSupport(VERSION_1_1, new InputStatementRfc7950Support())
             .addVersionSpecificSupport(VERSION_1, new OutputStatementImpl.Definition())
@@ -197,7 +206,8 @@ public final class YangInferencePipeline {
             .addSupport(new LeafStatementImpl.Definition())
             .addSupport(new ConfigStatementImpl.Definition())
             .addSupport(new DeviationStatementImpl.Definition())
-            .addSupport(new DeviateStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1, new DeviateStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1_1, new DeviateStatementRfc7950Support())
             .addVersionSpecificSupport(VERSION_1, new ChoiceStatementImpl.Definition())
             .addVersionSpecificSupport(VERSION_1_1, new ChoiceStatementRfc7950Support())
             .addVersionSpecificSupport(VERSION_1, new CaseStatementImpl.Definition())
@@ -211,9 +221,9 @@ public final class YangInferencePipeline {
             .addSupport(treeScoped(GroupingNamespace.class)) //treeScoped
             .addSupport(new ErrorMessageStatementImpl.Definition())
             .addSupport(new ErrorAppTagStatementImpl.Definition())
-            .addSupport(new LeafListStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1, new LeafListStatementImpl.Definition())
+            .addVersionSpecificSupport(VERSION_1_1, new LeafListStatementRfc7950Support())
             .addSupport(new PresenceStatementImpl.Definition())
-            .addSupport(new KeyStatementImpl.Definition())
             .addSupport(new MaxElementsStatementImpl.Definition())
             .addSupport(new MinElementsStatementImpl.Definition())
             .addSupport(new OrderedByStatementImpl.Definition())