import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
final SourceIdentifier belongsToSourceIdentifier = getSourceIdentifier(belongsToCtx);
final Prerequisite<StmtContext<?, ?, ?>> belongsToPrereq = belongsToAction.requiresCtx(belongsToCtx,
- ModuleNamespaceForBelongsTo.class, belongsToCtx.coerceStatementArgument(),
- ModelProcessingPhase.SOURCE_LINKAGE);
+ ModuleNamespaceForBelongsTo.class, belongsToCtx.getArgument(), ModelProcessingPhase.SOURCE_LINKAGE);
belongsToAction.apply(new InferenceAction() {
@Override
belongsToCtx.addToNs(BelongsToModuleContext.class, belongsToSourceIdentifier, belongsToModuleCtx);
belongsToCtx.addToNs(BelongsToPrefixToModuleCtx.class,
- findFirstDeclaredSubstatement(belongsToCtx, PrefixStatement.class).coerceStatementArgument(),
+ findFirstDeclaredSubstatement(belongsToCtx, PrefixStatement.class).getArgument(),
belongsToModuleCtx);
}
@Override
public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
if (failed.contains(belongsToPrereq)) {
- throw new InferenceException(belongsToCtx.getStatementSourceReference(),
- "Module '%s' from belongs-to was not found", belongsToCtx.getStatementArgument());
+ throw new InferenceException(belongsToCtx.sourceReference(),
+ "Module '%s' from belongs-to was not found", belongsToCtx.argument());
}
}
});
@Override
protected BelongsToStatement createDeclared(final StmtContext<String, BelongsToStatement, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
- return new RegularBelongsToStatement(ctx.coerceRawStatementArgument(), substatements);
+ return new RegularBelongsToStatement(ctx.getRawArgument(), substatements);
}
@Override
protected BelongsToStatement createEmptyDeclared(final StmtContext<String, BelongsToStatement, ?> ctx) {
- return new EmptyBelongsToStatement(ctx.coerceRawStatementArgument());
+ return new EmptyBelongsToStatement(ctx.getRawArgument());
}
@Override
- protected BelongsToEffectiveStatement createEffective(
- final StmtContext<String, BelongsToStatement, BelongsToEffectiveStatement> ctx,
- final BelongsToStatement declared, final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
- return new RegularBelongsToEffectiveStatement(declared, substatements);
- }
-
- @Override
- protected BelongsToEffectiveStatement createEmptyEffective(
- final StmtContext<String, BelongsToStatement, BelongsToEffectiveStatement> ctx,
- final BelongsToStatement declared) {
- return new EmptyBelongsToEffectiveStatement(declared);
+ protected BelongsToEffectiveStatement createEffective(final Current<String, BelongsToStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return substatements.isEmpty() ? new EmptyBelongsToEffectiveStatement(stmt.declared())
+ : new RegularBelongsToEffectiveStatement(stmt.declared(), substatements);
}
private static SourceIdentifier getSourceIdentifier(final StmtContext<String, BelongsToStatement,
BelongsToEffectiveStatement> belongsToCtx) {
- return RevisionSourceIdentifier.create(belongsToCtx.coerceStatementArgument());
+ return RevisionSourceIdentifier.create(belongsToCtx.getArgument());
}
@Override