* @param <A> statement argument type
* @param <D> declared statement type
* @return statement context that was searched for or null if was not found
- * @deprecated Use {@link StmtContext#findSubstatementArgument(Class)} instead.
+ * @deprecated Use {@link BoundStmtCtx#findSubstatementArgument(Class)} instead.
*/
@Deprecated(forRemoval = true)
public static <A, D extends DeclaredStatement<A>> StmtContext<A, ?, ?> findFirstSubstatement(
}
private static boolean isRelevantForIfFeatureAndWhenOnListKeysCheck(final StmtContext<?, ?, ?> ctx) {
- return YangVersion.VERSION_1_1.equals(ctx.getRootVersion()) && hasParentOfType(ctx, YangStmtMapping.LIST)
+ return YangVersion.VERSION_1_1.equals(ctx.yangVersion()) && hasParentOfType(ctx, YangStmtMapping.LIST)
&& findFirstDeclaredSubstatement(ctx.coerceParentContext(), KeyStatement.class) != null;
}
leafStmtCtx.allSubstatements().forEach(leafSubstmtCtx -> {
final StatementDefinition statementDef = leafSubstmtCtx.publicDefinition();
SourceException.throwIf(YangStmtMapping.IF_FEATURE.equals(statementDef)
- || YangStmtMapping.WHEN.equals(statementDef), leafStmtCtx.sourceReference(),
+ || YangStmtMapping.WHEN.equals(statementDef), leafStmtCtx,
"%s statement is not allowed in %s leaf statement which is specified as a list key.",
statementDef.getStatementName(), leafStmtCtx.argument());
});
localName = value;
qnameModule = getRootModuleQName(ctx);
}
- if (qnameModule == null && ctx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
+ if (qnameModule == null && ctx.history().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
ctx = ctx.getOriginalCtx().orElse(null);
qnameModule = getModuleQNameByPrefix(ctx, prefix);
}
}
- return internedQName(ctx, InferenceException.throwIfNull(qnameModule, ctx.sourceReference(),
+ return internedQName(ctx, InferenceException.throwIfNull(qnameModule, ctx,
"Cannot resolve QNameModule for '%s'", value), localName);
}
* @throws SourceException if the string is not a valid YANG identifier
*/
public static QName parseIdentifier(final StmtContext<?, ?, ?> ctx, final String str) {
- SourceException.throwIf(str.isEmpty(), ctx.sourceReference(), "Identifier may not be an empty string");
+ SourceException.throwIf(str.isEmpty(), ctx, "Identifier may not be an empty string");
return internedQName(ctx, str);
}
public static QName parseNodeIdentifier(final StmtContext<?, ?, ?> ctx, final String prefix,
final String localName) {
return internedQName(ctx,
- InferenceException.throwIfNull(getModuleQNameByPrefix(ctx, prefix), ctx.sourceReference(),
+ InferenceException.throwIfNull(getModuleQNameByPrefix(ctx, prefix), ctx,
"Cannot resolve QNameModule for '%s'", prefix),
localName);
}
* @throws SourceException if the string is not a valid YANG node identifier
*/
public static QName parseNodeIdentifier(final StmtContext<?, ?, ?> ctx, final String str) {
- SourceException.throwIf(str.isEmpty(), ctx.sourceReference(), "Node identifier may not be an empty string");
+ SourceException.throwIf(str.isEmpty(), ctx, "Node identifier may not be an empty string");
final int colon = str.indexOf(':');
if (colon == -1) {
}
final String prefix = str.substring(0, colon);
- SourceException.throwIf(prefix.isEmpty(), ctx.sourceReference(), "String '%s' has an empty prefix", str);
+ SourceException.throwIf(prefix.isEmpty(), ctx, "String '%s' has an empty prefix", str);
final String localName = str.substring(colon + 1);
- SourceException.throwIf(localName.isEmpty(), ctx.sourceReference(), "String '%s' has an empty identifier", str);
+ SourceException.throwIf(localName.isEmpty(), ctx, "String '%s' has an empty identifier", str);
return parseNodeIdentifier(ctx, prefix, localName);
}
return internedQName(ctx, getRootModuleQName(ctx), localName);
}
- private static QName internedQName(final StmtContext<?, ?, ?> ctx, final QNameModule module,
+ private static QName internedQName(final CommonStmtCtx ctx, final QNameModule module,
final String localName) {
final QName template;
try {
template = QName.create(module, localName);
} catch (IllegalArgumentException e) {
- throw new SourceException(ctx.sourceReference(), e, "Invalid identifier '%s'", localName);
+ throw new SourceException(ctx, e, "Invalid identifier '%s'", localName);
}
return template.intern();
}