import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-import java.util.Set;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.concepts.Mutable;
import org.opendaylight.yangtools.yang.common.QName;
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.MutableStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBehaviour.Registry, Mutable {
-
- public enum PhaseCompletionProgress {
+final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBehaviour.Registry, Mutable {
+ enum PhaseCompletionProgress {
NO_PROGRESS,
PROGRESS,
FINISHED
private final Multimap<ModelProcessingPhase, ModifierImpl> modifiers = HashMultimap.create();
private final QNameToStatementDefinitionMap qnameToStmtDefMap = new QNameToStatementDefinitionMap();
private final PrefixToModuleMap prefixToModuleMap = new PrefixToModuleMap();
- private final BuildGlobalContext currentContext;
+ private final @NonNull BuildGlobalContext globalContext;
// Freed as soon as we complete ModelProcessingPhase.EFFECTIVE_MODEL
private StatementStreamSource source;
private ModelProcessingPhase inProgressPhase;
private RootStatementContext<?, ?, ?> root;
- SourceSpecificContext(final BuildGlobalContext currentContext, final StatementStreamSource source) {
- this.currentContext = requireNonNull(currentContext);
+ SourceSpecificContext(final BuildGlobalContext globalContext, final StatementStreamSource source) {
+ this.globalContext = requireNonNull(globalContext);
this.source = requireNonNull(source);
}
- boolean isEnabledSemanticVersioning() {
- return currentContext.isEnabledSemanticVersioning();
+ @NonNull BuildGlobalContext globalContext() {
+ return globalContext;
}
ModelProcessingPhase getInProgressPhase() {
AbstractResumedStatement<?, ?, ?> createDeclaredChild(final AbstractResumedStatement<?, ?, ?> current,
final int childId, final QName name, final String argument, final StatementSourceReference ref) {
- StatementDefinitionContext<?, ?, ?> def = currentContext.getStatementDefinition(getRootVersion(), name);
+ StatementDefinitionContext<?, ?, ?> def = globalContext.getStatementDefinition(getRootVersion(), name);
if (def == null) {
- def = currentContext.getModelDefinedStatementDefinition(name);
+ def = globalContext.getModelDefinedStatementDefinition(name);
if (def == null) {
final StatementSupport<?, ?, ?> extension = qnameToStmtDefMap.get(name);
if (extension != null) {
def = new StatementDefinitionContext<>(extension);
- currentContext.putModelDefinedStatementDefinition(name, def);
+ globalContext.putModelDefinedStatementDefinition(name, def);
}
}
} else if (current != null && StmtContextUtils.isUnrecognizedStatement(current)) {
@Override
public <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviour<K, V, N> getNamespaceBehaviour(
final Class<N> type) {
- return currentContext.getNamespaceBehaviour(type);
+ return globalContext.getNamespaceBehaviour(type);
}
@Override
public NamespaceStorageNode getParentNamespaceStorage() {
- return currentContext;
+ return globalContext;
}
PhaseCompletionProgress tryToCompletePhase(final ModelProcessingPhase phase) {
private QNameToStatementDefinition stmtDef() {
// regular YANG statements and extension supports added
- final StatementSupportBundle supportsForPhase = currentContext.getSupportsForPhase(inProgressPhase);
+ final StatementSupportBundle supportsForPhase = globalContext.getSupportsForPhase(inProgressPhase);
qnameToStmtDefMap.putAll(supportsForPhase.getCommonDefinitions());
qnameToStmtDefMap.putAll(supportsForPhase.getDefinitionsSpecificForVersion(getRootVersion()));
}
// We need to any and all extension statements which have been declared in the context
- final Map<QName, StatementSupport<?, ?, ?>> extensions = currentContext.getNamespace(
+ final Map<QName, StatementSupport<?, ?, ?>> extensions = globalContext.getNamespace(
StatementDefinitionNamespace.class);
if (extensions != null) {
extensions.forEach((qname, support) -> {
return qnameToStmtDefMap;
}
- public Set<YangVersion> getSupportedVersions() {
- return currentContext.getSupportedVersions();
- }
-
- void addMutableStmtToSeal(final MutableStatement mutableStatement) {
- currentContext.addMutableStmtToSeal(mutableStatement);
- }
-
Collection<SourceIdentifier> getRequiredSources() {
return root.getRequiredSources();
}