import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
private final QNameToStatementDefinitionMap qnameToStmtDefMap = new QNameToStatementDefinitionMap();
private final PrefixToModuleMap prefixToModuleMap = new PrefixToModuleMap();
private final BuildGlobalContext currentContext;
- private final StatementStreamSource source;
+
+ // Freed as soon as we complete ModelProcessingPhase.EFFECTIVE_MODEL
+ private StatementStreamSource source;
/*
* "imported" namespaces in this source -- this points to RootStatementContexts of
return inProgressPhase;
}
- Optional<AbstractResumedStatement<?, ?, ?>> lookupDeclaredChild(final AbstractResumedStatement<?, ?, ?> current,
- final int childId) {
- if (current == null) {
- return Optional.empty();
- }
-
- // Fast path: we are entering a statement which was emitted in previous phase
- AbstractResumedStatement<?, ?, ?> existing = current.lookupSubstatement(childId);
- while (existing != null && StatementSource.CONTEXT == existing.getStatementSource()) {
- existing = existing.lookupSubstatement(childId);
- }
-
- return Optional.ofNullable(existing);
- }
-
AbstractResumedStatement<?, ?, ?> createDeclaredChild(final AbstractResumedStatement<?, ?, ?> current,
final int childId, final QName name, final String argument, final StatementSourceReference ref) {
StatementDefinitionContext<?, ?, ?> def = currentContext.getStatementDefinition(getRootVersion(), name);
return root != null ? root.getRootVersion() : RootStatementContext.DEFAULT_VERSION;
}
- DeclaredStatement<?> buildDeclared() {
- return root.buildDeclared();
- }
-
- EffectiveStatement<?, ?> buildEffective() {
- return root.buildEffective();
- }
-
void startPhase(final ModelProcessingPhase phase) {
final ModelProcessingPhase previousPhase = phase.getPreviousPhase();
verify(Objects.equals(previousPhase, finishedPhase),
}
@Override
- public NamespaceStorageNode getParentNamespaceStorage() {
+ public BuildGlobalContext getParentNamespaceStorage() {
return currentContext;
}
if (phaseCompleted && currentPhaseModifiers.isEmpty()) {
finishedPhase = phase;
LOG.debug("Source {} finished phase {}", source, phase);
+ if (phase == ModelProcessingPhase.EFFECTIVE_MODEL) {
+ // We have the effective model acquired, which is the final phase of source interaction.
+ LOG.trace("Releasing source {}", source);
+ source = null;
+ }
return PhaseCompletionProgress.FINISHED;
-
}
return hasProgressed ? PhaseCompletionProgress.PROGRESS : PhaseCompletionProgress.NO_PROGRESS;