return ret;
}
+ @Override
+ boolean computeSupportedByFeatures() {
+ return prototype.isSupportedByFeatures();
+ }
+
@Override
protected boolean isParentSupportedByFeatures() {
return parent.isSupportedByFeatures();
import java.util.Optional;
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.Empty;
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.StatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
OriginalStmtCtx(final OriginalStmtCtx<A, D, E> original) {
super(original);
- this.ref = original.ref;
+ ref = original.ref;
}
OriginalStmtCtx(final StatementDefinitionContext<A, D, E> def, final StatementSourceReference ref) {
|| noSensitiveSubstatements(effective) && noSensitiveSubstatements(mutableDeclaredSubstatements());
}
+ @Override
+ final boolean computeSupportedByFeatures() {
+ // If the set of supported features has not been provided, all features are supported by default.
+ final var supportedFeatures = namespaceItem(ParserNamespaces.SUPPORTED_FEATURES, Empty.value());
+ return supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures);
+ }
+
@Override
final void markNoParentRef() {
markNoParentRef(mutableDeclaredSubstatements());
import java.util.stream.Stream;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.common.Empty;
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.stmt.SchemaNodeIdentifier;
import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.parser.spi.ParserNamespaces;
import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementState;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
return true;
}
- /*
- * If parent is supported, we need to check if-features statements of this context.
- */
- if (isParentSupportedByFeatures()) {
- // If the set of supported features has not been provided, all features are supported by default.
- final var supportedFeatures = namespaceItem(ParserNamespaces.SUPPORTED_FEATURES, Empty.value());
- if (supportedFeatures == null || StmtContextUtils.checkFeatureSupport(this, supportedFeatures)) {
- flags |= SET_SUPPORTED_BY_FEATURES;
- return true;
- }
+ // If parent is supported, we need to check if-features statements of this context.
+ if (isParentSupportedByFeatures() && computeSupportedByFeatures()) {
+ flags |= SET_SUPPORTED_BY_FEATURES;
+ return true;
}
// Either parent is not supported or this statement is not supported
return false;
}
+ /**
+ * Compute whether this statement is supported by features. Returned value is combined with
+ * {@link #isParentSupportedByFeatures()} and cached.
+ *
+ * @return {@code true} if the current feature set matches {@code if-feature} of this statement
+ */
+ abstract boolean computeSupportedByFeatures();
+
protected abstract boolean isParentSupportedByFeatures();
/**
return isIgnoringConfig(parent);
}
+ @Override
+ boolean computeSupportedByFeatures() {
+ return source.isSupportedByFeatures();
+ }
+
@Override
protected boolean isParentSupportedByFeatures() {
return parent.isSupportedByFeatures();
// Target is a prerequisite for the 'refine', hence if the target is not supported, the refine is not supported
// as well. Otherwise add a pointer to the target into refine's local namespace.
- if (refineTargetNodeCtx.isSupportedToBuildEffective()) {
+ if (refineTargetNodeCtx.isSupportedToBuildEffective() && refineTargetNodeCtx.isSupportedByFeatures()) {
subStmtCtx.addToNs(RefineTargetNamespace.INSTANCE, Empty.value(), refineTargetNodeCtx);
} else {
subStmtCtx.setUnsupported();
final var module = StmtTestUtils.parseYangSource("/bugs/YT1393/baz.yang", Set.of())
.findModuleStatement(QName.create("baz", "baz"))
.orElseThrow();
- assertEquals(5, module.effectiveSubstatements().size());
+ assertEquals(4, module.effectiveSubstatements().size());
}
@Test
--- /dev/null
+/*
+ * Copyright (c) 2023 PANTHEON.tech s.r.o. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt;
+
+import java.util.Set;
+import org.junit.jupiter.api.Test;
+
+class YT1514Test extends AbstractYangTest {
+ @Test
+ void testLeafFooFeatureSupported() {
+ assertEffectiveModelDir("/bugs/YT1514", Set.of());
+ }
+}
--- /dev/null
+module foo {
+ namespace foo;
+ prefix foo;
+
+ feature feat;
+
+ grouping grp {
+ choice foo {
+ case bar {
+ if-feature feat;
+ leaf baz {
+ type string;
+ }
+ }
+ }
+ }
+
+ container cont {
+ uses grp {
+ refine foo/bar/baz {
+ reference "something";
+ }
+ }
+ }
+}