import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleIdentifier;
import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BelongsEffectiveToStatementImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BelongsToEffectiveStatementImpl;
public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
implements BelongsToStatement {
@Override
public EffectiveStatement<String, BelongsToStatement> createEffective(
final StmtContext<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> ctx) {
- return new BelongsEffectiveToStatementImpl(ctx);
+ return new BelongsToEffectiveStatementImpl(ctx);
}
@Override
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.source.DeclarationInTextSource;
import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> extends
AbstractEffectiveDocumentedNode<String, D> implements Module, MutableStatement {
this.name = argument();
- final PrefixEffectiveStatementImpl prefixStmt = firstEffective(PrefixEffectiveStatementImpl.class);
- this.prefix = (prefixStmt == null) ? null : prefixStmt.argument();
+ EffectiveStatementBase<?, ?> parentOfPrefix = this;
+ if (ctx.getPublicDefinition() == YangStmtMapping.SUBMODULE) {
+ parentOfPrefix = firstEffective(BelongsToEffectiveStatementImpl.class);
+ SourceException.throwIfNull(parentOfPrefix, ctx.getStatementSourceReference(),
+ "Unable to find belongs-to statement in submodule %s.", ctx.getStatementArgument());
+ }
+
+ final PrefixEffectiveStatementImpl prefixStmt = parentOfPrefix
+ .firstEffective(PrefixEffectiveStatementImpl.class);
+ SourceException.throwIfNull(prefixStmt, ctx.getStatementSourceReference(),
+ "Unable to resolve prefix for module or submodule %s.", ctx.getStatementArgument());
+ this.prefix = prefixStmt.argument();
final YangVersionEffectiveStatementImpl yangVersionStmt = firstEffective(YangVersionEffectiveStatementImpl.class);
this.yangVersion = (yangVersionStmt == null) ? YangVersion.VERSION_1 : yangVersionStmt.argument();
import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-public final class BelongsEffectiveToStatementImpl extends DeclaredEffectiveStatementBase<String, BelongsToStatement> {
- public BelongsEffectiveToStatementImpl(final StmtContext<String, BelongsToStatement, ?> ctx) {
+public final class BelongsToEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, BelongsToStatement> {
+ public BelongsToEffectiveStatementImpl(final StmtContext<String, BelongsToStatement, ?> ctx) {
super(ctx);
}
}