Integrate {Inference,Source}Exception with CommonStmtCtx
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / leaf_list / AbstractLeafListStatementSupport.java
index c9db870bd1d024b93aa0c72af3232a548e9fd063..78ac1c394ff2ddd01bfb9374f903871f466a53d5 100644 (file)
@@ -53,10 +53,9 @@ abstract class AbstractLeafListStatementSupport
     protected LeafListEffectiveStatement createEffective(final Current<QName, LeafListStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         final TypeEffectiveStatement<?> typeStmt = SourceException.throwIfNull(
-                findFirstStatement(substatements, TypeEffectiveStatement.class), stmt.sourceReference(),
+                findFirstStatement(substatements, TypeEffectiveStatement.class), stmt,
                 "Leaf-list is missing a 'type' statement");
 
-        final SchemaPath path = stmt.getSchemaPath();
         final LeafListSchemaNode original = (LeafListSchemaNode) stmt.original();
 
         final int flags = new FlagsBuilder()
@@ -75,8 +74,7 @@ abstract class AbstractLeafListStatementSupport
         // FIXME: We need to interpret the default value in terms of supplied element type
         SourceException.throwIf(
                 EffectiveStmtUtils.hasDefaultValueMarkedWithIfFeature(stmt.yangVersion(), typeStmt, defaultValues),
-                stmt.sourceReference(),
-                "Leaf-list '%s' has one of its default values '%s' marked with an if-feature statement.",
+                stmt, "Leaf-list '%s' has one of its default values '%s' marked with an if-feature statement.",
                 stmt.argument(), defaultValues);
 
         // FIXME: RFC7950 section 7.7.4: we need to check for min-elements and defaultValues conflict
@@ -85,6 +83,7 @@ abstract class AbstractLeafListStatementSupport
                 EffectiveStmtUtils.createElementCountConstraint(substatements);
 
         final LeafListStatement declared = stmt.declared();
+        final SchemaPath path = stmt.wrapSchemaPath();
         if (defaultValues.isEmpty()) {
             return original == null && !elementCountConstraint.isPresent()
                 ? new EmptyLeafListEffectiveStatement(declared, path, flags, substatements)