Fixed bug in searching augment target node. 53/1253/1
authorMartin Vitez <mvitez@cisco.com>
Wed, 18 Sep 2013 09:03:25 +0000 (11:03 +0200)
committerMartin Vitez <mvitez@cisco.com>
Wed, 18 Sep 2013 09:03:25 +0000 (11:03 +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..509ac236b76a88bb4891487b6aeeea259c0cfe3f 100644 (file)
@@ -280,7 +280,7 @@ public final class ParserUtils {
     private static def Builder findNode(Builder firstNodeParent, List<QName> path, String moduleName, int line) {
         var currentName = "";
         var currentParent = firstNodeParent;
-
+        
         val max = path.size();
         var i = 0;
         while(i < max) {
@@ -289,7 +289,10 @@ public final class ParserUtils {
             currentName = qname.getLocalName();
             if (currentParent instanceof DataNodeContainerBuilder) {
                 var dataNodeContainerParent = currentParent as DataNodeContainerBuilder;
-                var nodeFound = dataNodeContainerParent.getDataChildByName(currentName);
+                var SchemaNodeBuilder nodeFound = dataNodeContainerParent.getDataChildByName(currentName);
+                if (nodeFound == null && currentParent instanceof ModuleBuilder) {
+                       nodeFound = searchNotifications(currentParent as ModuleBuilder, currentName);
+                }
                 // if not found as regular child, search in uses
                 if (nodeFound == null) {
                     var found = searchUses(dataNodeContainerParent, currentName);
@@ -318,6 +321,15 @@ 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) {