import com.google.common.collect.ImmutableList;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.Status;
import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
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.stmt.GroupingEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.StatusEffectiveStatement;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseQNameStatementSupport;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
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.StmtContextUtils;
// Shadowing check: make sure we do not trample on pre-existing definitions. This catches sibling
// declarations and parent declarations which have already been declared.
checkConflict(parent, stmt);
- parent.addContext(GroupingNamespace.class, stmt.coerceStatementArgument(), stmt);
+ parent.addContext(GroupingNamespace.class, stmt.getArgument(), stmt);
}
}
}
protected final GroupingStatement createDeclared(final StmtContext<QName, GroupingStatement, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
checkDeclaredConflict(ctx);
- return new RegularGroupingStatement(ctx.coerceStatementArgument(), substatements);
+ return new RegularGroupingStatement(ctx.getArgument(), substatements);
}
@Override
protected final GroupingStatement createEmptyDeclared(final StmtContext<QName, GroupingStatement, ?> ctx) {
checkDeclaredConflict(ctx);
- return new EmptyGroupingStatement(ctx.coerceStatementArgument());
+ return new EmptyGroupingStatement(ctx.getArgument());
}
@Override
- protected final GroupingEffectiveStatement createEffective(
- final StmtContext<QName, GroupingStatement, GroupingEffectiveStatement> ctx,
- final GroupingStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- final int flags = new FlagsBuilder()
- .setHistory(ctx.getCopyHistory())
- .setStatus(findFirstArgument(substatements, StatusEffectiveStatement.class, Status.CURRENT))
- .toFlags();
-
- return new GroupingEffectiveStatementImpl(declared, ctx.getSchemaPath().get(), flags, substatements,
- ctx.getStatementSourceReference());
- }
-
- @Override
- protected GroupingEffectiveStatement createEmptyEffective(
- final StmtContext<QName, GroupingStatement, GroupingEffectiveStatement> ctx,
- final GroupingStatement declared) {
- return createEffective(ctx, declared, ImmutableList.of());
+ protected GroupingEffectiveStatement createEffective(final Current<QName, GroupingStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ try {
+ return new GroupingEffectiveStatementImpl(stmt.declared(), substatements,
+ historyAndStatusFlags(stmt.history(), substatements), stmt.getSchemaPath());
+ } catch (SubstatementIndexingException e) {
+ throw new SourceException(e.getMessage(), stmt.sourceReference(), e);
+ }
}
private static void checkDeclaredConflict(final StmtContext<QName, ?, ?> ctx) {
}
private static void checkConflict(final StmtContext<?, ?, ?> parent, final StmtContext<QName, ?, ?> stmt) {
- final QName arg = stmt.coerceStatementArgument();
+ final QName arg = stmt.getArgument();
final StmtContext<?, ?, ?> existing = parent.getFromNamespace(GroupingNamespace.class, arg);
- SourceException.throwIf(existing != null, stmt.getStatementSourceReference(), "Duplicate name for grouping %s",
- arg);
+ SourceException.throwIf(existing != null, stmt.sourceReference(), "Duplicate name for grouping %s", arg);
}
}
\ No newline at end of file