X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fstmt%2Freactor%2FSubstatementContext.java;h=d0c35df46e38dea87e18d0f14a2d3b79d67df411;hb=481a692d463636bbcf75f023da71703913e1b605;hp=aafdfca824a378e1b94af00106b6ef354e5b001a;hpb=ac51243790943f9586e569028807abacd6c3e5c9;p=yangtools.git
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
index aafdfca824..d0c35df46e 100644
--- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
+++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
@@ -7,6 +7,11 @@
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.GroupingUtils;
+
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.common.QName;
import com.google.common.base.Preconditions;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -18,10 +23,59 @@ class SubstatementContext, E extends EffectiveS
extends StatementContextBase {
private final StatementContextBase,?,?> parent;
+ private final A argument;
SubstatementContext(StatementContextBase,?,?> parent,ContextBuilder builder) throws SourceException {
+ //super(builder, builder.getDefinition().parseArgumentValue(parent, builder.getRawArgument()));
super(builder);
this.parent = Preconditions.checkNotNull(parent, "Parent must not be null");
+ this.argument = builder.getDefinition().parseArgumentValue(this, builder.getRawArgument());
+ }
+
+ SubstatementContext(SubstatementContext original, QNameModule newQNameModule, StatementContextBase, ?, ?> newParent) throws SourceException {
+ super(original);
+ this.parent = newParent;
+
+ if(newQNameModule != null && original.argument instanceof QName) {
+ QName originalQName = (QName) original.argument;
+ this.argument = (A) QName.create(newQNameModule,originalQName.getLocalName());
+ } else {
+ this.argument = original.argument;
+ }
+
+ copyDeclaredStmts(original, newQNameModule);
+
+ copyEffectiveStmts(original, newQNameModule);
+ }
+
+ private void copyDeclaredStmts(SubstatementContext original,
+ QNameModule newQNameModule) throws SourceException {
+ Collection extends StatementContextBase, ?, ?>> originalDeclaredSubstatements = original
+ .declaredSubstatements();
+ for (StatementContextBase, ?, ?> stmtContext : originalDeclaredSubstatements) {
+ if (GroupingUtils.needToCopyByUses(stmtContext)) {
+ StatementContextBase, ?, ?> copy = stmtContext
+ .createCopy(newQNameModule,this);
+ this.addEffectiveSubstatement(copy);
+ } else if (GroupingUtils.isReusedByUses(stmtContext)) {
+ this.addEffectiveSubstatement(stmtContext);
+ }
+ }
+ }
+
+ private void copyEffectiveStmts(SubstatementContext original,
+ QNameModule newQNameModule) throws SourceException {
+ Collection extends StatementContextBase, ?, ?>> originalEffectiveSubstatements = original
+ .effectiveSubstatements();
+ for (StatementContextBase, ?, ?> stmtContext : originalEffectiveSubstatements) {
+ if (GroupingUtils.needToCopyByUses(stmtContext)) {
+ StatementContextBase, ?, ?> copy = stmtContext
+ .createCopy(newQNameModule,this);
+ this.addEffectiveSubstatement(copy);
+ } else if (GroupingUtils.isReusedByUses(stmtContext)) {
+ this.addEffectiveSubstatement(stmtContext);
+ }
+ }
}
@Override
@@ -44,4 +98,15 @@ class SubstatementContext, E extends EffectiveS
return parent.getRoot();
}
+
+ @Override
+ public A getStatementArgument() {
+ return argument;
+ }
+
+ @Override
+ public StatementContextBase createCopy(QNameModule newQNameModule, StatementContextBase, ?, ?> newParent) throws SourceException {
+ StatementContextBase copy = new SubstatementContext(this,newQNameModule, newParent);
+ return copy;
+ }
}