import com.google.common.base.Verify;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Table;
import java.util.Set;
import java.util.SortedMap;
import javax.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.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.common.YangVersion;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules.SupportedModules;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.SourceSpecificContext.PhaseCompletionProgress;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.RecursiveObjectLeaker;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
.add(ModelProcessingPhase.FULL_DECLARATION).add(ModelProcessingPhase.EFFECTIVE_MODEL).build();
private final Table<YangVersion, QName, StatementDefinitionContext<?, ?, ?>> definitions = HashBasedTable.create();
+ private final Map<QName, StatementDefinitionContext<?, ?, ?>> modelDefinedStmtDefs = new HashMap<>();
private final Map<Class<?>, NamespaceBehaviourWithListeners<?, ?, ?>> supportedNamespaces = new HashMap<>();
private final List<MutableStatement> mutableStatementsToSeal = new ArrayList<>();
private final Map<ModelProcessingPhase, StatementSupportBundle> supports;
BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
final Map<ValidationBundleType, Collection<?>> supportedValidation,
- final StatementParserMode statementParserMode, final Set<QName> supportedFeatures) {
+ final StatementParserMode statementParserMode) {
this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
switch (statementParserMode) {
addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue());
}
- if (supportedFeatures != null) {
- addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
- ImmutableSet.copyOf(supportedFeatures));
- }
this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions());
}
libSources.add(new SourceSpecificContext(this, libSource));
}
+ void setSupportedFeatures(final Set<QName> supportedFeatures) {
+ addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
+ ImmutableSet.copyOf(supportedFeatures));
+ }
+
+ void setModulesDeviatedByModules(final Map<QNameModule, Set<QNameModule>> modulesDeviatedByModules) {
+ addToNs(ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES,
+ ImmutableMap.copyOf(modulesDeviatedByModules));
+ }
+
@Override
public StorageNodeType getStorageNodeType() {
return StorageNodeType.GLOBAL;
return potential;
}
+ StatementDefinitionContext<?, ?, ?> getModelDefinedStatementDefinition(final QName name) {
+ return modelDefinedStmtDefs.get(name);
+ }
+
+ void putModelDefinedStatementDefinition(final QName name, final StatementDefinitionContext<?, ?, ?> def) {
+ modelDefinedStmtDefs.put(name, def);
+ }
+
private void executePhases() throws ReactorException {
for (final ModelProcessingPhase phase : PHASE_EXECUTION_ORDER) {
startPhase(phase);
private SomeModifiersUnresolvedException propagateException(final SourceSpecificContext source,
final RuntimeException cause) throws SomeModifiersUnresolvedException {
- final SourceIdentifier sourceId = Utils.createSourceIdentifier(source.getRoot());
+ final SourceIdentifier sourceId = StmtContextUtils.createSourceIdentifier(source.getRoot());
if (!(cause instanceof SourceException)) {
/*
* This should not be happening as all our processing should provide SourceExceptions.
if (!addedCause) {
addedCause = true;
- final SourceIdentifier sourceId = Utils.createSourceIdentifier(failedSource.getRoot());
+ final SourceIdentifier sourceId = StmtContextUtils.createSourceIdentifier(failedSource.getRoot());
buildFailure = new SomeModifiersUnresolvedException(currentPhase, sourceId, sourceEx);
} else {
buildFailure.addSuppressed(sourceEx);