Cleanup unrecognized statement wrapping
[yangtools.git] / yang / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / InferredStatementContext.java
index dc019f1e2e2a3510040b845677ac9630b607c666..8c2c3db91512708aa24a7e826d16bd12718c1fc1 100644 (file)
@@ -34,9 +34,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
 import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.CopyHistory;
 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
-import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementStateAware;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.OnDemandSchemaTreeStorageNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
@@ -89,6 +87,7 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
     private final @NonNull StatementContextBase<A, D, E> prototype;
     private final @NonNull StatementContextBase<?, ?, ?> parent;
     private final @NonNull StmtContext<A, D, E> originalCtx;
+    // TODO: consider encoding this in StatementContextBase fields, there should be plenty of room
     private final @NonNull CopyType childCopyType;
     private final QNameModule targetModule;
     private final A argument;
@@ -119,7 +118,7 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
 
     InferredStatementContext(final StatementContextBase<?, ?, ?> parent, final StatementContextBase<A, D, E> prototype,
             final CopyType myCopyType, final CopyType childCopyType, final QNameModule targetModule) {
-        super(prototype.definition(), CopyHistory.of(myCopyType, prototype.history()));
+        super(prototype, myCopyType);
         this.parent = requireNonNull(parent);
         this.prototype = requireNonNull(prototype);
         this.argument = targetModule == null ? prototype.argument()
@@ -225,7 +224,8 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
 
         // First check if we can reuse the entire prototype
         if (!factory.canReuseCurrent(this, prototype, origSubstatements)) {
-            return deduplicate(tryToReuseSubstatements(factory, origEffective));
+            // FIXME: YANGTOOLS-1214: deduplicate this return
+            return tryToReuseSubstatements(factory, origEffective);
         }
 
         // We can reuse this statement let's see if all statements agree...
@@ -277,7 +277,8 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
         prototype.decRef();
 
         // Values are the effective copies, hence this efficiently deals with recursion.
-        return deduplicate(factory.createEffective(this, declared.stream(), effective.stream()));
+        // FIXME: YANGTOOLS-1214: deduplicate this return
+        return factory.createEffective(this, declared.stream(), effective.stream());
     }
 
     private @NonNull E tryToReuseSubstatements(final StatementFactory<A, D, E> factory, final @NonNull E original) {
@@ -301,17 +302,6 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
         return effective;
     }
 
-    private @NonNull E deduplicate(final @NonNull E effective) {
-        if (effective instanceof EffectiveStatementStateAware) {
-            final ReactorStmtCtx<A, D, E> source = unmodifiedEffectiveSource();
-            if (source != this) {
-                return source.attachCopy(((EffectiveStatementStateAware) effective).toEffectiveStatementState(),
-                    effective);
-            }
-        }
-        return effective;
-    }
-
     private List<ReactorStmtCtx<?, ?, ?>> reusePrototypeReplicas() {
         return reusePrototypeReplicas(Streams.concat(prototype.streamDeclared(), prototype.streamEffective()));
     }