import java.util.Set;
import java.util.SortedMap;
import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.util.RecursiveObjectLeaker;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
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.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour;
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.Registry;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceNotAvailableException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
private final ImmutableMap<ModelProcessingPhase, StatementSupportBundle> supports;
private final Set<SourceSpecificContext> sources = new HashSet<>();
private final ImmutableSet<YangVersion> supportedVersions;
- private final boolean enabledSemanticVersions;
private Set<SourceSpecificContext> libSources = new HashSet<>();
private ModelProcessingPhase currentPhase = ModelProcessingPhase.INIT;
private ModelProcessingPhase finishedPhase = ModelProcessingPhase.INIT;
BuildGlobalContext(final ImmutableMap<ModelProcessingPhase, StatementSupportBundle> supports,
- final ImmutableMap<ValidationBundleType, Collection<?>> supportedValidation,
- final StatementParserMode statementParserMode) {
+ final ImmutableMap<ValidationBundleType, Collection<?>> supportedValidation) {
this.supports = requireNonNull(supports, "BuildGlobalContext#supports cannot be null");
- switch (statementParserMode) {
- case DEFAULT_MODE:
- enabledSemanticVersions = false;
- break;
- case SEMVER_MODE:
- enabledSemanticVersions = true;
- break;
- default:
- throw new IllegalArgumentException("Unhandled parser mode " + statementParserMode);
- }
-
addToNamespace(ValidationBundlesNamespace.class, supportedValidation);
this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
}
- boolean isEnabledSemanticVersioning() {
- return enabledSemanticVersions;
- }
-
StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase phase) {
return supports.get(phase);
}
}
void addLibSource(final @NonNull StatementStreamSource libSource) {
- checkState(!isEnabledSemanticVersioning(),
- "Library sources are not supported in semantic version mode currently.");
checkState(currentPhase == ModelProcessingPhase.INIT,
"Add library source is allowed in ModelProcessingPhase.INIT only");
libSources.add(new SourceSpecificContext(this, libSource));
}
@Override
- public <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> getNamespaceBehaviour(
+ public <K, V, N extends ParserNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> getNamespaceBehaviour(
final Class<N> type) {
NamespaceBehaviourWithListeners<?, ?, ?> potential = supportedNamespaces.get(type);
if (potential == null) {
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- private <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> createNamespaceContext(
+ private <K, V, N extends ParserNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> createNamespaceContext(
final NamespaceBehaviour<K, V, N> potentialRaw) {
if (potentialRaw instanceof DerivedNamespaceBehaviour) {
final VirtualNamespaceContext derivedContext = new VirtualNamespaceContext(
checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL);
final List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size());
for (final SourceSpecificContext source : sources) {
- rootStatements.add(source.getRoot().buildDeclared());
+ rootStatements.add(source.getRoot().declared());
}
return new ReactorDeclaredModel(rootStatements);
}
final List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size());
final List<EffectiveStatement<?, ?>> rootEffectiveStatements = new ArrayList<>(sources.size());
- try {
- for (final SourceSpecificContext source : sources) {
- final RootStatementContext<?, ?, ?> root = source.getRoot();
- try {
- rootStatements.add(root.buildDeclared());
- rootEffectiveStatements.add(root.buildEffective());
- } catch (final RuntimeException ex) {
- throw propagateException(source, ex);
- }
+ for (final SourceSpecificContext source : sources) {
+ final RootStatementContext<?, ?, ?> root = source.getRoot();
+ try {
+ rootStatements.add(root.declared());
+ rootEffectiveStatements.add(root.buildEffective());
+ } catch (final RuntimeException ex) {
+ throw propagateException(source, ex);
}
- } finally {
- RecursiveObjectLeaker.cleanup();
}
sealMutableStatements();
while (currentSource.hasNext()) {
final SourceSpecificContext nextSourceCtx = currentSource.next();
try {
- final PhaseCompletionProgress sourceProgress = nextSourceCtx.tryToCompletePhase(currentPhase);
+ final PhaseCompletionProgress sourceProgress =
+ nextSourceCtx.tryToCompletePhase(currentPhase.executionOrder());
switch (sourceProgress) {
case FINISHED:
currentSource.remove();