YANG uses Intra file linking
Change-Id: I45936bee910ba4c81805f59daf2702bea5e60d08
diff --git a/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java b/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
index 22b9700..7f9b4a3 100644
--- a/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
+++ b/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
@@ -19,6 +19,8 @@
import org.onosproject.yangutils.parser.Parsable;
import org.onosproject.yangutils.utils.YangConstructType;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
+
/*-
* Reference RFC 6020.
*
@@ -255,8 +257,33 @@
}
@Override
- public void resolve() {
- //TODO: implement the method.
+ public void resolve()
+ throws DataModelException {
+
+ YangGrouping referredGrouping = getRefGroup();
+
+ if (referredGrouping == null) {
+ throw new DataModelException("YANG uses linker error, cannot resolve uses");
+ }
+
+ YangNode usesParentNode = getParentNodeInGenCode(this);
+ if (!(usesParentNode instanceof YangLeavesHolder)) {
+ throw new DataModelException("YANG uses holder construct is wrong");
+ }
+
+ YangLeavesHolder usesParentLeavesHolder = (YangLeavesHolder) usesParentNode;
+ if (referredGrouping.getListOfLeaf() != null) {
+ for (YangLeaf leaf : referredGrouping.getListOfLeaf()) {
+ usesParentLeavesHolder.addLeaf(leaf);
+ }
+ }
+ if (referredGrouping.getListOfLeafList() != null) {
+ for (YangLeafList leafList : referredGrouping.getListOfLeafList()) {
+ usesParentLeavesHolder.addLeafList(leafList);
+ }
+ }
+
+ YangNode.cloneSubTree(getRefGroup(), usesParentNode);
}
@Override