import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementState;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
-import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Parent;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.ExecutionOrder;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StatementFactory;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
public abstract RootStatementContext<?, ?, ?> getRoot();
@Override
- public abstract Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements();
+ public abstract Collection<? extends @NonNull StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements();
@Override
- public final @NonNull Registry getBehaviourRegistry() {
+ public final Registry getBehaviourRegistry() {
return getRoot().getBehaviourRegistryImpl();
}
return QName.create(StmtContextUtils.getRootModuleQName(root), root.getRawArgument());
}
- @Override
- @Deprecated(since = "7.0.9", forRemoval = true)
- public final EffectiveStatement<?, ?> original() {
- return getOriginalCtx().map(StmtContext::buildEffective).orElse(null);
- }
-
//
// In the next two methods we are looking for an effective statement. If we already have an effective instance,
// defer to it's implementation of the equivalent search. Otherwise we search our substatement contexts.
abstract @NonNull E createEffective();
+ /**
+ * Routing of the request to build an effective statement from {@link InferredStatementContext} towards the original
+ * definition site. This is needed to pick the correct instantiation method: for declared statements we will
+ * eventually land in {@link AbstractResumedStatement}, for underclared statements that will be
+ * {@link UndeclaredStmtCtx}.
+ *
+ * @param factory Statement factory
+ * @param ctx Inferred statement context, i.e. where the effective statement is instantiated
+ * @return Built effective stateue
+ */
+ abstract @NonNull E createInferredEffective(@NonNull StatementFactory<A, D, E> factory,
+ @NonNull InferredStatementContext<A, D, E> ctx, Stream<? extends ReactorStmtCtx<?, ?, ?>> declared,
+ Stream<? extends ReactorStmtCtx<?, ?, ?>> effective);
+
/**
* Attach an effective copy of this statement. This essentially acts as a map, where we make a few assumptions:
* <ul>
//
//
+ // Non-final for ImplicitStmtCtx/InferredStatementContext
@Override
- public final boolean isSupportedToBuildEffective() {
+ public boolean isSupportedToBuildEffective() {
return isSupportedToBuildEffective;
}
private byte calculateParentRefcount() {
final ReactorStmtCtx<?, ?, ?> parent = getParentContext();
- if (parent == null) {
- return PARENTREF_ABSENT;
- }
+ return parent == null ? PARENTREF_ABSENT : parent.refcountForChild();
+ }
+ private byte refcountForChild() {
// A slight wrinkle here is that our machinery handles only PRESENT -> ABSENT invalidation and we can reach here
// while inference is still ongoing and hence we may not have a complete picture about existing references. We
// could therefore end up caching an ABSENT result and then that information becoming stale as a new reference
// is introduced.
- if (parent.executionOrder() < ExecutionOrder.EFFECTIVE_MODEL) {
+ if (executionOrder() < ExecutionOrder.EFFECTIVE_MODEL) {
return PARENTREF_UNKNOWN;
}
// - negative (< REFCOUNT_NONE), meaning parent is in some stage of sweeping, hence it does not have
// a reference to us
// - positive (> REFCOUNT_NONE), meaning parent has an explicit refcount which is holding us down
- final int refs = parent.refcount;
+ final int refs = refcount;
if (refs == REFCOUNT_NONE) {
- return parent.parentRefcount();
+ return parentRefcount();
}
return refs < REFCOUNT_NONE ? PARENTREF_ABSENT : PARENTREF_PRESENT;
}