Bug 5200: Yang parser doesn't fill error-app-tag and error-message in constraints
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / StmtContextUtils.java
index 05b7f67c333ceab95ede69325755457f7db658c5..6b5f8439df66415bf61a180ffbdd23af8080f1f3 100644 (file)
@@ -71,6 +71,12 @@ public final class StmtContextUtils {
         return producesDeclared(ctx, declaredType) ? (AT) ctx.getStatementArgument() : null;
     }
 
+    public static <AT, DT extends DeclaredStatement<AT>> AT firstSubstatementAttributeOf(
+            final StmtContext<?, ?, ?> ctx, final Class<DT> declaredType) {
+        AT firstAttribute = firstAttributeOf(ctx.effectiveSubstatements(), declaredType);
+        return firstAttribute != null ? firstAttribute : firstAttributeOf(ctx.declaredSubstatements(), declaredType);
+    }
+
     @SuppressWarnings("unchecked")
     public static <AT,DT extends DeclaredStatement<AT>> StmtContext<AT, ?, ?> findFirstDeclaredSubstatement(
             final StmtContext<?, ?, ?> stmtContext, final Class<DT> declaredType) {