Bug 4640: Change semantic-version to openconfig-version
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / ModuleStatementSupport.java
index a1a76db263182dfa12166eeb4fc1a55fa3edac1c..643fead841d64a8f9710ac2d7164b2e4dcf7c390 100644 (file)
@@ -77,7 +77,7 @@ public class ModuleStatementSupport extends
             .addAny(YangStmtMapping.TYPEDEF)
             .addAny(YangStmtMapping.USES)
             .addOptional(YangStmtMapping.YANG_VERSION)
-            .addOptional(SupportedExtensionsMapping.SEMANTIC_VERSION)
+            .addOptional(SupportedExtensionsMapping.OPENCONFIG_VERSION)
             .build();
 
     public ModuleStatementSupport() {
@@ -142,6 +142,14 @@ public class ModuleStatementSupport extends
         }
 
         final QNameModule qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orElse(null)).intern();
+
+        final StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>> possibleDuplicateModule =
+                stmt.getFromNamespace(NamespaceToModule.class, qNameModule);
+        if (possibleDuplicateModule != null && possibleDuplicateModule != stmt) {
+            throw new SourceException(stmt.getStatementSourceReference(), "Module namespace collision: %s. At %s",
+                    qNameModule.getNamespace(), possibleDuplicateModule.getStatementSourceReference());
+        }
+
         final ModuleIdentifier moduleIdentifier = ModuleIdentifierImpl.create(stmt.getStatementArgument(),
                 Optional.empty(), revisionDate);