Rework BindingRuntimeTypes
[mdsal.git] / binding / mdsal-binding-generator / src / main / java / org / opendaylight / mdsal / binding / generator / impl / reactor / ModuleAugmentGenerator.java
index 25658cf294ec1420f765340dabb64dcb55aaaef3..a04587e005be386c26d4c68c222becfe5dc87ff4 100644 (file)
@@ -7,35 +7,23 @@
  */
 package org.opendaylight.mdsal.binding.generator.impl.reactor;
 
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.util.SchemaInferenceStack;
 
 /**
  * Generator corresponding to a {@code augment} statement used as a child of a {@code module} statement.
  */
 final class ModuleAugmentGenerator extends AbstractAugmentGenerator {
-    ModuleAugmentGenerator(final AugmentEffectiveStatement statement, final AbstractCompositeGenerator<?> parent) {
+    ModuleAugmentGenerator(final AugmentEffectiveStatement statement, final AbstractCompositeGenerator<?, ?> parent) {
         super(statement, parent);
     }
 
-    @Override
-    void loadTargetGenerator() {
-        throw new UnsupportedOperationException();
-    }
-
-    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());
-        //          }
-        //      }
+    @NonNull AugmentRequirement startLinkage(final GeneratorContext context) {
+        setTargetStatement(SchemaInferenceStack.of(context.getEffectiveModelContext())
+            .enterSchemaTree(statement().argument()));
 
-        setTargetGenerator(context.resolveSchemaNode(statement().argument()));
+        return new AugmentRequirement(this,
+            context.resolveModule(statement().argument().firstNodeIdentifier().getModule()));
     }
 }