import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
+import java.util.function.Predicate;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
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.source.SupportedFeaturesNamespace.SupportedFeatures;
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;
private static final Logger LOG = LoggerFactory.getLogger(BuildGlobalContext.class);
private static final List<ModelProcessingPhase> PHASE_EXECUTION_ORDER = ImmutableList.<ModelProcessingPhase>builder()
+ .add(ModelProcessingPhase.SOURCE_PRE_LINKAGE)
.add(ModelProcessingPhase.SOURCE_LINKAGE)
.add(ModelProcessingPhase.STATEMENT_DEFINITION)
.add(ModelProcessingPhase.FULL_DECLARATION)
private ModelProcessingPhase currentPhase = ModelProcessingPhase.INIT;
private ModelProcessingPhase finishedPhase = ModelProcessingPhase.INIT;
- public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports) {
+ public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
+ final Predicate<QName> isFeatureSupported) {
super();
this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
+
+ addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES, isFeatureSupported);
}
- public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports, final Map<ValidationBundleType,Collection<?>> supportedValidation) {
+ public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
+ final Map<ValidationBundleType,Collection<?>> supportedValidation,
+ final Predicate<QName> isFeatureSupported) {
super();
this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
for (Entry<ValidationBundleType, Collection<?>> validationBundle : supportedValidation.entrySet()) {
addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue());
}
+
+ addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES, isFeatureSupported);
}
public StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase currentPhase) {
// We reset progressing to false.
progressing = false;
Iterator<SourceSpecificContext> currentSource = sourcesToProgress.iterator();
- while(currentSource.hasNext()) {
+ while (currentSource.hasNext()) {
SourceSpecificContext nextSourceCtx = currentSource.next();
PhaseCompletionProgress sourceProgress = nextSourceCtx.tryToCompletePhase(currentPhase);
switch (sourceProgress) {