import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
import org.opendaylight.yangtools.yang.parser.spi.PreLinkageModuleNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.CommonStmtCtx;
import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionModuleNamespace;
import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
abstract class AbstractModuleStatementSupport
extends BaseStatementSupport<UnqualifiedQName, ModuleStatement, ModuleEffectiveStatement> {
try {
return UnqualifiedQName.of(value);
} catch (IllegalArgumentException e) {
- throw new SourceException(e.getMessage(), ctx.getStatementSourceReference(), e);
+ throw new SourceException(e.getMessage(), ctx.sourceReference(), e);
}
}
final String moduleName = stmt.coerceRawStatementArgument();
final URI moduleNs = firstAttributeOf(stmt.declaredSubstatements(), NamespaceStatement.class);
- SourceException.throwIfNull(moduleNs, stmt.getStatementSourceReference(),
+ SourceException.throwIfNull(moduleNs, stmt.sourceReference(),
"Namespace of the module [%s] is missing", moduleName);
stmt.addToNs(ModuleNameToNamespace.class, moduleName, moduleNs);
final String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
- SourceException.throwIfNull(modulePrefix, stmt.getStatementSourceReference(),
+ SourceException.throwIfNull(modulePrefix, stmt.sourceReference(),
"Prefix of the module [%s] is missing", moduleName);
stmt.addToNs(ImpPrefixToNamespace.class, modulePrefix, moduleNs);
final Optional<URI> moduleNs = Optional.ofNullable(firstAttributeOf(stmt.declaredSubstatements(),
NamespaceStatement.class));
- SourceException.throwIf(!moduleNs.isPresent(), stmt.getStatementSourceReference(),
+ SourceException.throwIf(!moduleNs.isPresent(), stmt.sourceReference(),
"Namespace of the module [%s] is missing", stmt.getStatementArgument());
final Optional<Revision> revisionDate = StmtContextUtils.getLatestRevision(stmt.declaredSubstatements());
final StmtContext<?, ModuleStatement, ModuleEffectiveStatement> possibleDuplicateModule =
stmt.getFromNamespace(NamespaceToModule.class, qNameModule);
if (possibleDuplicateModule != null && possibleDuplicateModule != stmt) {
- throw new SourceException(stmt.getStatementSourceReference(), "Module namespace collision: %s. At %s",
- qNameModule.getNamespace(), possibleDuplicateModule.getStatementSourceReference());
+ throw new SourceException(stmt.sourceReference(), "Module namespace collision: %s. At %s",
+ qNameModule.getNamespace(), possibleDuplicateModule.sourceReference());
}
final String moduleName = stmt.coerceRawStatementArgument();
stmt.addContext(NamespaceToModule.class, qNameModule, stmt);
final String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
- SourceException.throwIfNull(modulePrefix, stmt.getStatementSourceReference(),
+ SourceException.throwIfNull(modulePrefix, stmt.sourceReference(),
"Prefix of the module [%s] is missing", stmt.getStatementArgument());
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
@Override
protected final ModuleStatement createEmptyDeclared(final StmtContext<UnqualifiedQName, ModuleStatement, ?> ctx) {
- throw noNamespace(ctx.getStatementSourceReference());
+ throw noNamespace(ctx);
}
@Override
protected final ModuleEffectiveStatement createEffective(final Current<UnqualifiedQName, ModuleStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
if (substatements.isEmpty()) {
- throw noNamespace(stmt.sourceReference());
+ throw noNamespace(stmt);
}
final List<Submodule> submodules = new ArrayList<>();
return submodules == null ? List.of() : submodules.values();
}
- private static SourceException noNamespace(final @NonNull StatementSourceReference ref) {
- return new SourceException("No namespace declared in module", ref);
+ private static SourceException noNamespace(final @NonNull CommonStmtCtx stmt) {
+ return new SourceException("No namespace declared in module", stmt.sourceReference());
}
private static void addToSemVerModuleNamespace(