Consider AugmentationNodes when direct descendant is not found
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / leafref / LeafRefValidation.java
index 5de4f032ba03ab0ea1c9439d51fe1d45232f2297..bf1433203f84f0e8eda2b92ae5778dc851d07bba 100644 (file)
@@ -390,9 +390,13 @@ public final class LeafRefValidation {
             final YangInstanceIdentifier current) {
         final Optional<DataContainerChild<?, ?>> child = parent.getChild(arg);
         if (!child.isPresent()) {
-            for (final DataContainerChild<?, ?> choice : parent.getValue()) {
-                if (choice instanceof ChoiceNode) {
-                    addValues(values, choice, nodePredicates, path, current);
+            // FIXME: YANGTOOLS-901. We have SchemaContext nearby, hence we should be able to cache how to get
+            //        to the leaf with with specified QName, without having to iterate through Choices/Augmentations.
+            //        That perhaps means we should not have QNameWithPredicates, but NodeIdentifierWithPredicates as
+            //        the path specification.
+            for (final DataContainerChild<?, ?> mixin : parent.getValue()) {
+                if (mixin instanceof AugmentationNode || mixin instanceof ChoiceNode) {
+                    addValues(values, mixin, nodePredicates, path, current);
                 }
             }
         } else {