import org.opendaylight.yangtools.yang.parser.spi.source.ImplicitSubstatement;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter.ResumedStatement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Intermediate subclass of StatementContextBase facing the parser stream via implementation of ResumedStatement. This
*/
abstract class AbstractResumedStatement<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
extends StatementContextBase<A, D, E> implements ResumedStatement {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractResumedStatement.class);
+
private final @NonNull StatementSourceReference statementDeclSource;
private final String rawArgument;
- private List<StatementContextBase<?, ?, ?>> effective = ImmutableList.of();
+ private List<ReactorStmtCtx<?, ?, ?>> effective = ImmutableList.of();
private StatementMap substatements = StatementMap.empty();
private @Nullable D declaredInstance;
}
@Override
- public final D buildDeclared() {
+ public final D declared() {
final D existing;
return (existing = declaredInstance) != null ? existing : loadDeclared();
}
final String argument) {
final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase();
checkState(inProgressPhase != ModelProcessingPhase.EFFECTIVE_MODEL,
- "Declared statement cannot be added in effective phase at: %s", getStatementSourceReference());
+ "Declared statement cannot be added in effective phase at: %s", sourceReference());
final Optional<StatementSupport<?, ?, ?>> implicitParent =
definition().getImplicitParentFor(def.getPublicView());
}
@Override
- final Iterable<StatementContextBase<?, ?, ?>> effectiveChildrenToComplete() {
+ final Iterable<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete() {
return effective;
}
return effective.stream();
}
+ @Override
+ final void markNoParentRef() {
+ markNoParentRef(substatements);
+ markNoParentRef(effective);
+ }
+
+ @Override
+ final int sweepSubstatements() {
+ // First we need to sweep all statements, which may trigger sweeps all across the place, for example:
+ // - 'effective' member sweeping a 'substatements' member
+ // - 'substatements' member sweeping a 'substatements' member which came before it during iteration
+ // We then iterate once again, counting what remains unswept
+ sweep(substatements);
+ sweep(effective);
+ final int count = countUnswept(substatements) + countUnswept(effective);
+ if (count != 0) {
+ LOG.debug("{} children left to sweep from {}", count, this);
+ }
+ substatements = null;
+ effective = null;
+ return count;
+ }
+
/**
* Lookup substatement by its offset in this statement.
*