Fixed bug in searching augment target node. 54/1254/1
authorMartin Vitez <mvitez@cisco.com>
Wed, 18 Sep 2013 09:17:50 +0000 (11:17 +0200)
committerMartin Vitez <mvitez@cisco.com>
Wed, 18 Sep 2013 09:17:50 +0000 (11:17 +0200)
Signed-off-by: Martin Vitez <mvitez@cisco.com>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserUtils.xtend

index 1d03e8a44fffc02852517bcbfdf96d998e351f2f..59613b9ce1df837eeea9ddf0c2d2ae5fbbe4f4c4 100644 (file)
@@ -289,8 +289,12 @@ public final class ParserUtils {
             currentName = qname.getLocalName();
             if (currentParent instanceof DataNodeContainerBuilder) {
                 var dataNodeContainerParent = currentParent as DataNodeContainerBuilder;
-                var nodeFound = dataNodeContainerParent.getDataChildByName(currentName);
-                // if not found as regular child, search in uses
+                var SchemaNodeBuilder nodeFound = dataNodeContainerParent.getDataChildByName(currentName);
+                // if not found, search in notifications
+                if (nodeFound == null && currentParent instanceof ModuleBuilder) {
+                       nodeFound = searchNotifications(currentParent as ModuleBuilder, currentName);
+                }
+                // if not found, search in uses
                 if (nodeFound == null) {
                     var found = searchUses(dataNodeContainerParent, currentName);
                     if(found == null) {
@@ -317,7 +321,16 @@ public final class ParserUtils {
         }
         return currentParent;
     }
-    
+
+    private static def searchNotifications(ModuleBuilder parent, String name) {
+        for(notification : parent.notifications) {
+            if(notification.getQName().localName.equals(name)) {
+                return notification;
+            }
+        }
+        return null;
+    }
+
     private static def searchUses(DataNodeContainerBuilder dataNodeContainerParent, String name) {
         var currentName = name;
         for (unb : dataNodeContainerParent.usesNodes) {