Bug 4969: Unable to find base type of leafref for old yang parser types.
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / SchemaContextUtil.java
index 25e4cab4ffbc069ac5e87c5a97e36cd7f3f331cc..accaec0da69abdff42b09263762728a3e8f8673d 100644 (file)
@@ -678,7 +678,15 @@ public final class SchemaContextUtil {
             nodeType = ((LeafListSchemaNode) schemaNode).getType();
         }
 
-        if (nodeType.getBaseType() != null) {
+        if (nodeType instanceof ExtendedType) {
+            while (nodeType.getBaseType() instanceof ExtendedType) {
+                nodeType = nodeType.getBaseType();
+            }
+
+            QNameModule typeDefModuleQname = nodeType.getQName().getModule();
+            return schemaContext.findModuleByNamespaceAndRevision(typeDefModuleQname.getNamespace(),
+                    typeDefModuleQname.getRevision());
+        } else if (nodeType.getBaseType() != null) {
             while (nodeType.getBaseType() != null) {
                 nodeType = nodeType.getBaseType();
             }