import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStmtUtils;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractSchemaTreeStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.BoundStmtCtx;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStatementState;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Parent;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Parent.EffectiveConfig;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.QNameWithFlagsEffectiveStatementState;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
.addOptional(YangStmtMapping.WHEN)
.build();
+ private final boolean warnForUnkeyedLists;
+
ListStatementSupport(final YangParserConfiguration config, final SubstatementValidator validator) {
super(YangStmtMapping.LIST, instantiatedPolicy(), config, validator);
+ this.warnForUnkeyedLists = config.warnForUnkeyedLists();
}
public static @NonNull ListStatementSupport rfc6020Instance(final YangParserConfiguration config) {
}
@Override
- protected ListStatement createDeclared(final StmtContext<QName, ListStatement, ?> ctx,
- final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ protected ListStatement createDeclared(final BoundStmtCtx<QName> ctx,
+ final ImmutableList<DeclaredStatement<?>> substatements) {
return DeclaredStatements.createList(ctx.getArgument(), substatements);
}
public ListEffectiveStatement copyEffective(final Current<QName, ListStatement> stmt,
final ListEffectiveStatement original) {
return EffectiveStatements.copyList(original, stmt.getArgument(),
- computeFlags(stmt, original.effectiveSubstatements()), stmt.original(ListSchemaNode.class));
+ computeFlags(stmt, original.effectiveSubstatements()));
}
@Override
}
final int flags = computeFlags(stmt, substatements);
- if (stmt.effectiveConfig() == EffectiveConfig.TRUE && keyDefinition.isEmpty() && isInstantied(stmt)) {
+ if (warnForUnkeyedLists && stmt.effectiveConfig() == EffectiveConfig.TRUE
+ && keyDefinition.isEmpty() && isInstantied(stmt)) {
warnConfigList(stmt);
}
try {
return EffectiveStatements.createList(stmt.declared(), stmt.getArgument(), flags, substatements,
- keyDefinition, EffectiveStmtUtils.createElementCountConstraint(substatements).orElse(null),
- stmt.original(ListSchemaNode.class));
+ keyDefinition, EffectiveStmtUtils.createElementCountConstraint(substatements).orElse(null));
} catch (SubstatementIndexingException e) {
throw new SourceException(e.getMessage(), stmt, e);
}
}
+ @Override
+ public EffectiveStatementState extractEffectiveState(final ListEffectiveStatement stmt) {
+ verify(stmt instanceof ListSchemaNode, "Unexpected statement %s", stmt);
+ final var schema = (ListSchemaNode) stmt;
+ return new QNameWithFlagsEffectiveStatementState(stmt.argument(), new FlagsBuilder()
+ .setHistory(schema)
+ .setStatus(schema.getStatus())
+ .setConfiguration(schema.effectiveConfig().orElse(null))
+ .setUserOrdered(schema.isUserOrdered())
+ .toFlags());
+ }
+
private static int computeFlags(final Current<?, ?> stmt,
final Collection<? extends EffectiveStatement<?, ?>> substatements) {
return new FlagsBuilder()