Fixed bug in parser in augment resolving process. 63/463/2
authorMartin Vitez <mvitez@cisco.com>
Wed, 12 Jun 2013 14:37:50 +0000 (16:37 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 12 Jun 2013 15:42:06 +0000 (15:42 +0000)
Signed-off-by: Martin Vitez <mvitez@cisco.com>
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/ParserUtils.java

index e95a162..7d11db2 100644 (file)
@@ -36,6 +36,7 @@ import org.opendaylight.controller.yang.model.util.BooleanType;
 import org.opendaylight.controller.yang.model.util.Decimal64;
 import org.opendaylight.controller.yang.model.util.EmptyType;
 import org.opendaylight.controller.yang.model.util.EnumerationType;
+import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.IdentityrefType;
 import org.opendaylight.controller.yang.model.util.InstanceIdentifier;
 import org.opendaylight.controller.yang.model.util.Int16;
@@ -253,11 +254,32 @@ public final class ParserUtils {
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
                         nodeQName, unionType.getQName());
                 return new UnionType(newSchemaPath, unionType.getTypes());
+            } else if(nodeType instanceof ExtendedType) {
+                ExtendedType extType = (ExtendedType)nodeType;
+                newSchemaPath = createNewSchemaPath(parentSchemaPath,
+                        nodeQName, extType.getQName());
+                result = createNewExtendedType(newSchemaPath, extType);
             }
         }
         return result;
     }
 
+    private static TypeDefinition<?> createNewExtendedType(
+            SchemaPath newSchemaPath, ExtendedType oldExtendedType) {
+        QName qname = oldExtendedType.getQName();
+        TypeDefinition<?> baseType = oldExtendedType.getBaseType();
+        String desc = oldExtendedType.getDescription();
+        String ref = oldExtendedType.getReference();
+        ExtendedType.Builder builder = new ExtendedType.Builder(qname, baseType, desc, ref, newSchemaPath);
+        builder.status(oldExtendedType.getStatus());
+        builder.lengths(oldExtendedType.getLengths());
+        builder.patterns(oldExtendedType.getPatterns());
+        builder.ranges(oldExtendedType.getRanges());
+        builder.fractionDigits(oldExtendedType.getFractionDigits());
+        builder.unknownSchemaNodes(oldExtendedType.getUnknownSchemaNodes());
+        return builder.build();
+    }
+
     private static TypeDefinition<?> createNewStringType(SchemaPath schemaPath,
             QName nodeQName, StringTypeDefinition nodeType) {
         List<QName> path = schemaPath.getPath();