Bug 3670 (part 1/5): Use of new statement parser in yang-maven-plugin
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / RootStatementContext.java
index 6b876c71f607d7f215d0aef2cbad582b2f521aec..8108cd810e6339ac946c7a534cc47538997dc6c6 100644 (file)
@@ -137,8 +137,16 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
     public StatementContextBase<A, D, E> createCopy(QNameModule newQNameModule,
             StatementContextBase<?, ?, ?> newParent, TypeOfCopy typeOfCopy) throws SourceException {
         RootStatementContext<A, D, E> copy = new RootStatementContext<>(this, newQNameModule, typeOfCopy);
-        copy.setTypeOfCopy(typeOfCopy);
-        copy.setOriginalCtx(this);
+
+        copy.addAllToCopyHistory(this.getCopyHistory());
+        copy.addToCopyHistory(typeOfCopy);
+
+        if(this.getOriginalCtx() != null) {
+            copy.setOriginalCtx(this.getOriginalCtx());
+        } else {
+            copy.setOriginalCtx(this);
+        }
+
         return copy;
     }