Refactor augment generator linkage
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / ModuleAugmentGenerator.java
index 25658cf294ec1420f765340dabb64dcb55aaaef3..f4c01a3e7e0f38bab1a9135925e0eb0620033a9b 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.mdsal.binding.generator.impl.reactor;
 
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
 
 /**
  * Generator corresponding to a {@code augment} statement used as a child of a {@code module} statement.
@@ -23,19 +24,8 @@ final class ModuleAugmentGenerator extends AbstractAugmentGenerator {
     }
 
     void linkAugmentationTarget(final GeneratorContext context) {
-        // FIXME: do we need two-step resolution here? we probably have solved this somehow, or it's part of...
-        // FIXME: MDSAL-696: this looks like the sort of check which should be involved in replacing getOriginal()
-        //
-        //      if (targetSchemaNode instanceof DataSchemaNode && ((DataSchemaNode) targetSchemaNode).isAddedByUses()) {
-        //          if (targetSchemaNode instanceof DerivableSchemaNode) {
-        //              targetSchemaNode = ((DerivableSchemaNode) targetSchemaNode).getOriginal().orElse(null);
-        //          }
-        //          if (targetSchemaNode == null) {
-        //              throw new IllegalStateException("Failed to find target node from grouping in augmentation "
-        //                  + augSchema + " in module " + context.module().getName());
-        //          }
-        //      }
-
-        setTargetGenerator(context.resolveSchemaNode(statement().argument()));
+        final SchemaNodeIdentifier path = statement().argument();
+        final ModuleGenerator module = context.resolveModule(path.firstNodeIdentifier().getModule());
+        setTargetGenerator(module.resolveSchemaNode(path));
     }
 }