Migrate rawStatementArgument()/getStatementSourceReference() callers 52/93952/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 27 Nov 2020 08:18:13 +0000 (09:18 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 27 Nov 2020 08:18:13 +0000 (09:18 +0100)
This is a mass migration of callers, deprecating the two methods
in the process.

Change-Id: Ibda969a84d5a45b624d581e10ed5706b4066625f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
60 files changed:
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/AbstractResumedStatement.java
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/InferredStatementContext.java
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ArgumentUtils.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/XPathSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/augment/AbstractAugmentStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/base/BaseStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/belongs_to/BelongsToStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/choice/AbstractChoiceStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviate/AbstractDeviateStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/deviation/DeviationStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/extension/UnrecognizedStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/fraction_digits/FractionDigitsStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/grouping/AbstractGroupingStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/identity/AbstractIdentityStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/if_feature/AbstractIfFeatureStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/if_feature/IfFeaturePredicateVisitor.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/AbstractImportStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/RevisionImport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/import_/SemanticVersionImport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/include/AbstractIncludeStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/key/KeyStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/length/LengthStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/list/AbstractListStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/min_elements/MinElementsStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/modifier/ModifierStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/module/AbstractModuleStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/namespace/NamespaceStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/ordered_by/OrderedByStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathExpressionParser.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/pattern/AbstractPatternStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/position/PositionStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/range/RangeStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/revision/RevisionStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/revision_date/RevisionDateStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/status/StatusStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/AbstractSubmoduleStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/submodule/SubmoduleEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractIdentityRefSpecificationSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractLeafrefSpecificationSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/AbstractTypeStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/BitsSpecificationSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/Decimal64SpecificationSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/EnumSpecificationSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/type/UnionSpecificationSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/typedef/TypedefStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/unique/UniqueStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/uses/UsesStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/value/ValueStatementSupport.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/yang_version/YangVersionStatementSupport.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/path/PathExpressionParserTest.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/SchemaTreeNamespace.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractDeclaredStatement.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SubstatementValidator.java

index 8a92906875077204da7184a75ed2ffcae9f26ad6..004676dfbb8e3636235c812019008a9a029c6760 100644 (file)
@@ -167,7 +167,7 @@ abstract class AbstractResumedStatement<A, D extends DeclaredStatement<A>, E ext
                     final String argument) {
         final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase();
         checkState(inProgressPhase != ModelProcessingPhase.EFFECTIVE_MODEL,
-                "Declared statement cannot be added in effective phase at: %s", getStatementSourceReference());
+                "Declared statement cannot be added in effective phase at: %s", sourceReference());
 
         final Optional<StatementSupport<?, ?, ?>> implicitParent =
                 definition().getImplicitParentFor(def.getPublicView());
index c6e3034064fbf46a83e7649c1478e51246efdac2..6a95b0118644332a016899c83d220c54cb10aed6 100644 (file)
@@ -240,7 +240,7 @@ final class InferredStatementContext<A, D extends DeclaredStatement<A>, E extend
 
         @SuppressWarnings("unchecked")
         final Mutable<QName, Y, Z> ret = (Mutable<QName, Y, Z>) copySubstatement((Mutable<?, ?, ?>) template)
-            .orElseThrow(() -> new InferenceException(getStatementSourceReference(),
+            .orElseThrow(() -> new InferenceException(sourceReference(),
                 "Failed to materialize child %s template %s", qname, template));
         ensureCompletedPhase(ret);
         addMaterialized(template, ret);
index 2c9d6970978389a22851f4482c8cb179a17384a6..91c60419558f66c70b852c62d958e0cd90b1981e 100644 (file)
@@ -63,7 +63,7 @@ public final class RootStatementContext<A, D extends DeclaredStatement<A>, E ext
         final StatementSourceReference ref, final String rawArgument) {
         super(def, ref, rawArgument);
         this.sourceContext = requireNonNull(sourceContext);
-        this.argument = def.parseArgumentValue(this, rawStatementArgument());
+        this.argument = def.parseArgumentValue(this, rawArgument());
     }
 
     RootStatementContext(final SourceSpecificContext sourceContext, final StatementDefinitionContext<A, D, E> def,
@@ -234,7 +234,7 @@ public final class RootStatementContext<A, D extends DeclaredStatement<A>, E ext
 
     void setRootVersionImpl(final YangVersion version) {
         checkArgument(sourceContext.globalContext().getSupportedVersions().contains(version),
-                "Unsupported yang version %s in %s", version, getStatementSourceReference());
+                "Unsupported yang version %s in %s", version, sourceReference());
         checkState(this.rootVersion == null, "Version of root %s has been already set to %s", argument,
                 this.rootVersion);
         this.rootVersion = requireNonNull(version);
index 944f7831c312bcd4824181adf36fcf182953c808..911e92cd63057410a25a2178d951516855669ae9 100644 (file)
@@ -152,7 +152,7 @@ final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeha
                     root.getRootIdentifier());
         } else {
             final QName rootStatement = root.definition().getStatementName();
-            final String rootArgument = root.rawStatementArgument();
+            final String rootArgument = root.rawArgument();
 
             checkState(Objects.equals(def.getStatementName(), rootStatement) && Objects.equals(argument, rootArgument),
                 "Root statement was already defined as '%s %s'.", rootStatement, rootArgument);
@@ -333,8 +333,7 @@ final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeha
         }
 
         final String message = String.format("Yang model processing phase %s failed", identifier);
-        final InferenceException e = new InferenceException(message, root.getStatementSourceReference(),
-            exceptions.get(0));
+        final InferenceException e = new InferenceException(message, root.sourceReference(), exceptions.get(0));
         exceptions.listIterator(1).forEachRemaining(e::addSuppressed);
 
         return Optional.of(e);
index 4f72b2d9d58c898a6b5497e7dea152e19d6b50f1..5a65edbd5e7e840511e337ec97befa9f58e87577 100644 (file)
@@ -420,7 +420,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
         final Iterator<StatementContextBase<?, ?, ?>> iterator = effective.iterator();
         while (iterator.hasNext()) {
             final Mutable<?, ?, ?> next = iterator.next();
-            if (statementDef.equals(next.publicDefinition()) && statementArg.equals(next.rawStatementArgument())) {
+            if (statementDef.equals(next.publicDefinition()) && statementArg.equals(next.rawArgument())) {
                 iterator.remove();
             }
         }
@@ -435,7 +435,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
         // FIXME: YANGTOOLS-652: This does not need to be a SubstatementContext, in can be a specialized
         //                       StatementContextBase subclass.
         final Mutable<X, Y, Z> ret = new SubstatementContext<>(this, new StatementDefinitionContext<>(support),
-                ImplicitSubstatement.of(getStatementSourceReference()), rawArg);
+                ImplicitSubstatement.of(sourceReference()), rawArg);
         support.onStatementAdded(ret);
         addEffectiveSubstatement(ret);
         return ret;
@@ -526,7 +526,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
             final List<StatementContextBase<?, ?, ?>> effective, final int toAdd) {
         // We cannot allow statement to be further mutated
         verify(completedPhase != ModelProcessingPhase.EFFECTIVE_MODEL, "Cannot modify finished statement at %s",
-            getStatementSourceReference());
+            sourceReference());
         return beforeAddEffectiveStatementUnsafe(effective, toAdd);
     }
 
@@ -535,7 +535,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
         final ModelProcessingPhase inProgressPhase = getRoot().getSourceContext().getInProgressPhase();
         checkState(inProgressPhase == ModelProcessingPhase.FULL_DECLARATION
                 || inProgressPhase == ModelProcessingPhase.EFFECTIVE_MODEL,
-                "Effective statement cannot be added in declared phase at: %s", getStatementSourceReference());
+                "Effective statement cannot be added in declared phase at: %s", sourceReference());
 
         return effective.isEmpty() ? new ArrayList<>(toAdd) : effective;
     }
@@ -781,8 +781,8 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
      * @throws NullPointerException if any of the arguments is null
      */
     void addPhaseCompletedListener(final ModelProcessingPhase phase, final OnPhaseFinished listener) {
-        checkNotNull(phase, "Statement context processing phase cannot be null at: %s", getStatementSourceReference());
-        checkNotNull(listener, "Statement context phase listener cannot be null at: %s", getStatementSourceReference());
+        checkNotNull(phase, "Statement context processing phase cannot be null at: %s", sourceReference());
+        checkNotNull(listener, "Statement context phase listener cannot be null at: %s", sourceReference());
 
         ModelProcessingPhase finishedPhase = completedPhase;
         while (finishedPhase != null) {
@@ -808,7 +808,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
         ModelProcessingPhase finishedPhase = completedPhase;
         while (finishedPhase != null) {
             checkState(!phase.equals(finishedPhase), "Mutation registered after phase was completed at: %s",
-                getStatementSourceReference());
+                sourceReference());
             finishedPhase = finishedPhase.getPreviousPhase();
         }
 
@@ -881,8 +881,8 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
 
         if (implicitParent.isPresent()) {
             final StatementDefinitionContext<?, ?, ?> def = new StatementDefinitionContext<>(implicitParent.get());
-            result = new SubstatementContext(this, def, original.getStatementSourceReference(),
-                original.rawStatementArgument(), original.getStatementArgument(), type);
+            result = new SubstatementContext(this, def, original.sourceReference(), original.rawArgument(),
+                original.argument(), type);
 
             final CopyType childCopyType;
             switch (type) {
@@ -930,8 +930,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
         final StatementDefinitionContext<?, ?, ?> def = new StatementDefinitionContext<>(optImplicit.get());
         final CopyType type = original.getCopyHistory().getLastOperation();
         final SubstatementContext<?, ?, ?> result = new SubstatementContext(original.getParentContext(), def,
-            original.getStatementSourceReference(), original.rawStatementArgument(), original.getStatementArgument(),
-            type);
+            original.sourceReference(), original.rawArgument(), original.argument(), type);
 
         result.addEffectiveSubstatement(original.reparent(result));
         result.setCompletedPhase(original.getCompletedPhase());
@@ -976,7 +975,7 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
             isConfig = optConfig.orElseThrow();
             if (isConfig) {
                 // Validity check: if parent is config=false this cannot be a config=true
-                InferenceException.throwIf(!parent.isConfiguration(), getStatementSourceReference(),
+                InferenceException.throwIf(!parent.isConfiguration(), sourceReference(),
                         "Parent node has config=false, this node must not be specifed as config=true");
             }
         } else {
@@ -1094,6 +1093,6 @@ public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E
     }
 
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return toStringHelper.add("definition", definition).add("rawArgument", rawStatementArgument());
+        return toStringHelper.add("definition", definition).add("rawArgument", rawArgument());
     }
 }
index 0fb23c74594a8d76364e1b3ee7dfbebc043d2986..d84283efcaf03ba7f4039052398119b9632e2d2a 100644 (file)
@@ -33,7 +33,7 @@ final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends Eff
             final StatementSourceReference ref, final String rawArgument) {
         super(def, ref, rawArgument);
         this.parent = requireNonNull(parent, "Parent must not be null");
-        this.argument = def.parseArgumentValue(this, rawStatementArgument());
+        this.argument = def.parseArgumentValue(this, rawArgument());
     }
 
     // FIXME: YANGTOOLS-784: this constructor is only called in contexts where a different implementation
index 99f7be9c319468357fd005eb488503b2d602385d..3d5f539c615cc89fc1ff9a94c661114dcf774d83 100644 (file)
@@ -245,7 +245,7 @@ public abstract class AbstractEffectiveModule<D extends DeclaredStatement<Unqual
             final String name) {
         return SourceException.throwIfNull(
             StmtContextUtils.firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class),
-            stmt.getStatementSourceReference(), "Unable to resolve prefix for %s %s.", type, name);
+            stmt.sourceReference(), "Unable to resolve prefix for %s %s.", type, name);
     }
 
     // Alright. this is quite ugly
index 8c1210b70386635d38be70e361a17e92d1928e81..74f482b265562dfaad12976f03b20e2a635cb453 100644 (file)
@@ -70,7 +70,7 @@ public final class ArgumentUtils {
             return Boolean.FALSE;
         } else {
             final StatementDefinition def = ctx.publicDefinition();
-            throw new SourceException(ctx.getStatementSourceReference(),
+            throw new SourceException(ctx.sourceReference(),
                 "Invalid '%s' statement %s '%s', it can be either 'true' or 'false'",
                 def.getStatementName(), def.getArgumentDefinition().get().getArgumentName(), input);
         }
@@ -103,13 +103,13 @@ public final class ArgumentUtils {
             try {
                 qnames.add(StmtContextUtils.parseNodeIdentifier(ctx, nodeName));
             } catch (final RuntimeException e) {
-                throw new SourceException(ctx.getStatementSourceReference(), e,
+                throw new SourceException(ctx.sourceReference(), e,
                         "Failed to parse node '%s' in path '%s'", nodeName, path);
             }
         }
 
         if (qnames.isEmpty()) {
-            throw new SourceException("Schema node identifier must not be empty", ctx.getStatementSourceReference());
+            throw new SourceException("Schema node identifier must not be empty", ctx.sourceReference());
         }
         return qnames;
     }
index 498a2ca9a6f8e6e436c1691ed6496ba7e7902095..a9ac8fa740f83c23807975698431466e9b799412 100644 (file)
@@ -39,14 +39,13 @@ public final class XPathSupport {
         try {
             parsed = parser.parseExpression(xpath);
         } catch (XPathExpressionException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
-                "Argument \"%s\" is not valid XPath string", xpath);
+            throw new SourceException(ctx.sourceReference(), e, "Argument \"%s\" is not valid XPath string", xpath);
         }
 
         if (ctx.getRootVersion().compareTo(parsed.getYangVersion()) < 0) {
             LOG.warn("{} features required in {} context to parse expression '{}' [at {}]",
                 parsed.getYangVersion().getReference(), ctx.getRootVersion().getReference(), xpath,
-                ctx.getStatementSourceReference());
+                ctx.sourceReference());
         }
         return parsed;
     }
index 31e1218c0c1ab8069a298ad40778dcae62c9f5c4..1e54260f5d01b7c41eb3782fbb9779d3ebeabbbe 100644 (file)
@@ -67,7 +67,7 @@ abstract class AbstractAugmentStatementSupport
     @Override
     public final SchemaNodeIdentifier parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
         SourceException.throwIf(PATH_REL_PATTERN1.matcher(value).matches()
-            || PATH_REL_PATTERN2.matcher(value).matches(), ctx.getStatementSourceReference(),
+            || PATH_REL_PATTERN2.matcher(value).matches(), ctx.sourceReference(),
             "Augment argument \'%s\' is not valid, it can be only absolute path; or descendant if used in uses",
             value);
 
@@ -118,9 +118,8 @@ abstract class AbstractAugmentStatementSupport
                     copyFromSourceToTarget(augmentSourceCtx, augmentTargetCtx);
                     augmentTargetCtx.addEffectiveSubstatement(augmentSourceCtx);
                 } catch (final SourceException e) {
-                    LOG.warn("Failed to add augmentation {} defined at {}",
-                        augmentTargetCtx.getStatementSourceReference(),
-                            augmentSourceCtx.getStatementSourceReference(), e);
+                    LOG.warn("Failed to add augmentation {} defined at {}", augmentTargetCtx.sourceReference(),
+                            augmentSourceCtx.sourceReference(), e);
                 }
             }
 
@@ -136,13 +135,13 @@ abstract class AbstractAugmentStatementSupport
                     if (targetNode.isPresent() && StmtContextUtils.isUnknownStatement(targetNode.get())) {
                         augmentNode.setIsSupportedToBuildEffective(false);
                         LOG.warn("Uses-augment to unknown node {}. Augmentation has not been performed. At line: {}",
-                            augmentArg, augmentNode.getStatementSourceReference());
+                            augmentArg, augmentNode.sourceReference());
                         return;
                     }
                 }
 
-                throw new InferenceException(augmentNode.getStatementSourceReference(),
-                        "Augment target '%s' not found", augmentNode.getStatementArgument());
+                throw new InferenceException(augmentNode.sourceReference(), "Augment target '%s' not found",
+                    augmentNode.getStatementArgument());
             }
         });
     }
@@ -257,11 +256,10 @@ abstract class AbstractAugmentStatementSupport
         if (sourceCtx.producesDeclared(DataDefinitionStatement.class)) {
             for (final StmtContext<?, ?, ?> subStatement : targetCtx.allSubstatements()) {
                 if (subStatement.producesDeclared(DataDefinitionStatement.class)) {
-                    InferenceException.throwIf(
-                        Objects.equals(sourceCtx.getStatementArgument(), subStatement.getStatementArgument()),
-                        sourceCtx.getStatementSourceReference(),
+                    InferenceException.throwIf(Objects.equals(sourceCtx.argument(), subStatement.argument()),
+                        sourceCtx.sourceReference(),
                         "An augment cannot add node named '%s' because this name is already used in target",
-                        sourceCtx.rawStatementArgument());
+                        sourceCtx.rawArgument());
                 }
             }
         }
@@ -279,10 +277,9 @@ abstract class AbstractAugmentStatementSupport
             sourceCtx.allSubstatementsStream().forEach(AbstractAugmentStatementSupport::checkForMandatoryNodes);
         }
 
-        InferenceException.throwIf(StmtContextUtils.isMandatoryNode(sourceCtx),
-                sourceCtx.getStatementSourceReference(),
-                "An augment cannot add node '%s' because it is mandatory and in module different than target",
-                sourceCtx.rawStatementArgument());
+        InferenceException.throwIf(StmtContextUtils.isMandatoryNode(sourceCtx), sourceCtx.sourceReference(),
+            "An augment cannot add node '%s' because it is mandatory and in module different than target",
+            sourceCtx.rawArgument());
     }
 
     private static boolean requireCheckOfMandatoryNodes(final StmtContext<?, ?, ?> sourceCtx,
index cb4adf9f194991743f292787c4d524ff67ee5aed..5e779b6abf18e34cd3a161965488b5dc061d1219 100644 (file)
@@ -67,7 +67,7 @@ public final class BaseStatementSupport extends BaseQNameStatementSupport<BaseSt
 
                 @Override
                 public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
-                    throw new InferenceException(baseStmtCtx.getStatementSourceReference(),
+                    throw new InferenceException(baseStmtCtx.sourceReference(),
                         "Unable to resolve identity %s and base identity %s",
                         baseParentCtx.getStatementArgument(), baseStmtCtx.getStatementArgument());
                 }
index b420e10cc3d0c465da2a0eec6c0a124a23e2b8b7..ce4a243a8c91303e73349d381744a509a16c4fcd 100644 (file)
@@ -76,8 +76,8 @@ public final class BelongsToStatementSupport
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
                 if (failed.contains(belongsToPrereq)) {
-                    throw new InferenceException(belongsToCtx.getStatementSourceReference(),
-                        "Module '%s' from belongs-to was not found", belongsToCtx.getStatementArgument());
+                    throw new InferenceException(belongsToCtx.sourceReference(),
+                        "Module '%s' from belongs-to was not found", belongsToCtx.argument());
                 }
             }
         });
index ef932c5f64138fbb8425664ea3a7cebd9426d0fc..89cd7112ad18f9207b4e44ae4a7d8d27773156f0 100644 (file)
@@ -67,8 +67,8 @@ abstract class AbstractChoiceStatementSupport
             try {
                 qname = QName.create(stmt.getArgument(), defaultArg);
             } catch (IllegalArgumentException e) {
-                throw new SourceException(stmt.sourceReference(), "Default statement has invalid name '%s'",
-                        defaultArg, e);
+                throw new SourceException(stmt.sourceReference(), "Default statement has invalid name '%s'", defaultArg,
+                    e);
             }
 
             // FIXME: this does not work with submodules, as they are
index 08e609a6743a9ab89e559890622c0335d7797dbc..f2a16708b087fe264bbc67007d924939076e2027 100644 (file)
@@ -105,8 +105,8 @@ abstract class AbstractDeviateStatementSupport
 
     @Override
     public final DeviateKind parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return SourceException.throwIfNull(KEYWORD_TO_DEVIATE_MAP.get(value),
-            ctx.getStatementSourceReference(), "String '%s' is not valid deviate argument", value);
+        return SourceException.throwIfNull(KEYWORD_TO_DEVIATE_MAP.get(value), ctx.sourceReference(),
+            "String '%s' is not valid deviate argument", value);
     }
 
     @Override
@@ -162,7 +162,7 @@ abstract class AbstractDeviateStatementSupport
 
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
-                throw new InferenceException(deviateStmtCtx.coerceParentContext().getStatementSourceReference(),
+                throw new InferenceException(deviateStmtCtx.coerceParentContext().sourceReference(),
                     "Deviation target '%s' not found.", deviationTarget);
             }
         });
@@ -261,7 +261,7 @@ abstract class AbstractDeviateStatementSupport
                     && YangStmtMapping.LEAF.equals(targetCtx.publicDefinition())) {
                 for (final StmtContext<?, ?, ?> targetCtxSubstatement : targetCtx.allSubstatements()) {
                     InferenceException.throwIf(stmtToBeAdded.equals(targetCtxSubstatement.publicDefinition()),
-                        stmtCtxToBeAdded.getStatementSourceReference(),
+                        stmtCtxToBeAdded.sourceReference(),
                         "Deviation cannot add substatement %s to target node %s because it is already defined "
                         + "in target and can appear only once.",
                         stmtToBeAdded.getStatementName(), targetCtx.getStatementArgument());
@@ -290,7 +290,7 @@ abstract class AbstractDeviateStatementSupport
                 && YangStmtMapping.LEAF_LIST.equals(targetCtx.publicDefinition())) {
             LOG.error("Deviation cannot replace substatement {} in target leaf-list {} because a leaf-list can "
                     + "have multiple default statements. At line: {}", stmtToBeReplaced.getStatementName(),
-                    targetCtx.getStatementArgument(), stmtCtxToBeReplaced.getStatementSourceReference());
+                    targetCtx.getStatementArgument(), stmtCtxToBeReplaced.sourceReference());
             return;
         }
 
@@ -318,7 +318,7 @@ abstract class AbstractDeviateStatementSupport
             return;
         }
 
-        throw new InferenceException(stmtCtxToBeReplaced.getStatementSourceReference(), "Deviation cannot replace "
+        throw new InferenceException(stmtCtxToBeReplaced.sourceReference(), "Deviation cannot replace "
                 + "substatement %s in target node %s because it does not exist in target node.",
                 stmtToBeReplaced.getStatementName(), targetCtx.getStatementArgument());
     }
@@ -356,7 +356,7 @@ abstract class AbstractDeviateStatementSupport
 
         LOG.error("Deviation cannot delete substatement {} with argument '{}' in target node {} because it does "
                 + "not exist in the target node. At line: {}", stmtToBeDeleted.getStatementName(), stmtArgument,
-                targetCtx.getStatementArgument(), stmtCtxToBeDeleted.getStatementSourceReference());
+                targetCtx.getStatementArgument(), stmtCtxToBeDeleted.sourceReference());
     }
 
     private static void copyStatement(final Mutable<?, ?, ?> stmtCtxToBeCopied,
@@ -378,9 +378,9 @@ abstract class AbstractDeviateStatementSupport
     private static void validateDeviationTarget(final StmtContext<?, ?, ?> deviateSubStmtCtx,
             final StmtContext<?, ?, ?> targetCtx) {
         InferenceException.throwIf(!isSupportedDeviationTarget(deviateSubStmtCtx, targetCtx,
-                targetCtx.getRootVersion()), deviateSubStmtCtx.getStatementSourceReference(),
-                "%s is not a valid deviation target for substatement %s.",
-                targetCtx.getStatementArgument(), deviateSubStmtCtx.publicDefinition().getStatementName());
+            targetCtx.getRootVersion()), deviateSubStmtCtx.sourceReference(),
+            "%s is not a valid deviation target for substatement %s.", targetCtx.argument(),
+            deviateSubStmtCtx.publicDefinition().getStatementName());
     }
 
     private static boolean isSupportedDeviationTarget(final StmtContext<?, ?, ?> deviateSubstatementCtx,
index d4e7c712ec57442a7bbe5250244c54b483b0c2db..3ba5d94fb078d43b8297d0fb24b4b6454cebeafc 100644 (file)
@@ -57,7 +57,7 @@ public final class DeviationStatementSupport
                 .getModule();
 
         if (currentModule.equals(targetModule)) {
-            throw new InferenceException(ctx.getStatementSourceReference(),
+            throw new InferenceException(ctx.sourceReference(),
                     "Deviation must not target the same module as the one it is defined in: %s", currentModule);
         }
     }
index 2a7dec913ed7155b4f7fba52dc92da6091031828..e6c906fd8eb30a02cdac547bb1a8cb711a9c3034 100644 (file)
@@ -58,7 +58,7 @@ final class UnrecognizedStatementSupport
     @Override
     protected UnrecognizedStatement createDeclared(final StmtContext<String, UnrecognizedStatement, ?> ctx,
             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
-        return new UnrecognizedStatementImpl(ctx.rawStatementArgument(), ctx.publicDefinition(), substatements);
+        return new UnrecognizedStatementImpl(ctx.rawArgument(), ctx.publicDefinition(), substatements);
     }
 
     @Override
index 99005fd06dd03c39d7f00d09916114acd6ec58e2..16fcefbf0d6e501bb7ba47689cfe3aa699269be3 100644 (file)
@@ -63,12 +63,12 @@ public final class FractionDigitsStatementSupport
         try {
             fractionDigits = Integer.parseInt(value);
         } catch (NumberFormatException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
-                "%s is not valid fraction-digits integer argument", value);
+            throw new SourceException(ctx.sourceReference(), e, "%s is not valid fraction-digits integer argument",
+                value);
         }
         if (fractionDigits < 1 || fractionDigits > 18) {
             throw new SourceException("fraction-digits argument should be integer within [1..18]",
-                ctx.getStatementSourceReference());
+                ctx.sourceReference());
         }
         return fractionDigits;
     }
index e08b5afd0620621e055740d9f74db8b19e8a18a1..26ec9ea155772235288f3803cfda56bf7f6db765 100644 (file)
@@ -84,7 +84,6 @@ abstract class AbstractGroupingStatementSupport
     private static void checkConflict(final StmtContext<?, ?, ?> parent, final StmtContext<QName, ?, ?> stmt) {
         final QName arg = stmt.coerceStatementArgument();
         final StmtContext<?, ?, ?> existing = parent.getFromNamespace(GroupingNamespace.class, arg);
-        SourceException.throwIf(existing != null, stmt.getStatementSourceReference(), "Duplicate name for grouping %s",
-                arg);
+        SourceException.throwIf(existing != null, stmt.sourceReference(), "Duplicate name for grouping %s", arg);
     }
 }
\ No newline at end of file
index 44f5b46be772c81c548a7256397e97f493ba2729..cc7c9e458c5a2b090822fdc001b21a4c237ec5fe 100644 (file)
@@ -51,8 +51,7 @@ abstract class AbstractIdentityStatementSupport
             final Mutable<QName, IdentityStatement, IdentityEffectiveStatement> stmt) {
         final QName qname = stmt.coerceStatementArgument();
         final StmtContext<?, ?, ?> prev = stmt.getFromNamespace(IdentityNamespace.class, qname);
-        SourceException.throwIf(prev != null, stmt.getStatementSourceReference(), "Duplicate identity definition %s",
-                qname);
+        SourceException.throwIf(prev != null, stmt.sourceReference(), "Duplicate identity definition %s", qname);
         stmt.addToNs(IdentityNamespace.class, qname, stmt);
     }
 
index 933eae7955209f1c7279118318ac44e6e0e487fb..b8ecc00bf1d8c2dfa4aa688b267e9e896a225815 100644 (file)
@@ -73,9 +73,8 @@ abstract class AbstractIfFeatureStatementSupport
                     unresolvedFeatures.add(verifyNotNull(backRef.get(prereq)));
                 }
 
-                throw new InferenceException(stmt.getStatementSourceReference(),
-                    "Failed to resolve feature references %s in \"%s\"", unresolvedFeatures,
-                    stmt.rawStatementArgument());
+                throw new InferenceException(stmt.sourceReference(),
+                    "Failed to resolve feature references %s in \"%s\"", unresolvedFeatures, stmt.rawArgument());
             }
         });
     }
index 5191e190ff2eeba22247d03d60294eed89115d51..54f0eeb06d77a205f9b3d5216a170fe4a2e6ee3d 100644 (file)
@@ -41,7 +41,7 @@ final class IfFeaturePredicateVisitor extends IfFeatureExpressionParserBaseVisit
         final IfFeatureExpressionLexer lexer = new IfFeatureExpressionLexer(CharStreams.fromString(value));
         final IfFeatureExpressionParser parser = new IfFeatureExpressionParser(new CommonTokenStream(lexer));
         final IfFeatureExpr ret = new IfFeaturePredicateVisitor(ctx).visit(SourceExceptionParser.parse(lexer, parser,
-            parser::if_feature_expr, ctx.getStatementSourceReference()));
+            parser::if_feature_expr, ctx.sourceReference()));
 
         return ret;
     }
@@ -79,7 +79,7 @@ final class IfFeaturePredicateVisitor extends IfFeatureExpressionParserBaseVisit
         }
 
         throw new SourceException("Unexpected grammar context during parsing of IfFeature expression. "
-                + "Most probably IfFeature grammar has been changed.", stmtCtx.getStatementSourceReference());
+                + "Most probably IfFeature grammar has been changed.", stmtCtx.sourceReference());
     }
 
     @Override
index 56b122722493f40ce81701343dc6b01222c696d8..bd81814faeb3b4c0719408b87e75c3a0edde0c08 100644 (file)
@@ -73,15 +73,15 @@ abstract class AbstractImportStatementSupport
                         moduleName);
                 Verify.verifyNotNull(importedModuleNamespace);
                 final String impPrefix = SourceException.throwIfNull(
-                    firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class),
-                    stmt.getStatementSourceReference(), "Missing prefix statement");
+                    firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class), stmt.sourceReference(),
+                    "Missing prefix statement");
 
                 stmt.addToNs(ImpPrefixToNamespace.class, impPrefix, importedModuleNamespace);
             }
 
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
-                InferenceException.throwIf(failed.contains(imported), stmt.getStatementSourceReference(),
+                InferenceException.throwIf(failed.contains(imported), stmt.sourceReference(),
                         "Imported module [%s] was not found.", moduleName);
             }
         });
index cca75d2b78902f7a309582cf924b79ee97651be0..da4d2821a363da2ce3fd2950dfbe5f6b99e28fff 100644 (file)
@@ -66,7 +66,7 @@ final class RevisionImport {
                 final StmtContext<?, ?, ?> importedModule = imported.resolve(ctx);
 
                 final QNameModule mod = InferenceException.throwIfNull(stmt.getFromNamespace(
-                    ModuleCtxToModuleQName.class, importedModule), stmt.getStatementSourceReference(),
+                    ModuleCtxToModuleQName.class, importedModule), stmt.sourceReference(),
                     "Failed to find module of %s", importedModule);
 
                 linkageTarget.resolve(ctx).addToNs(ImportedModuleContext.class,
@@ -82,8 +82,8 @@ final class RevisionImport {
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
                 if (failed.contains(imported)) {
-                    throw new InferenceException(stmt.getStatementSourceReference(),
-                            "Imported module [%s] was not found.", moduleName);
+                    throw new InferenceException(stmt.sourceReference(), "Imported module [%s] was not found.",
+                        moduleName);
                 }
             }
         });
index fddf91b152efb2edc7f2ead8a77fb2c1fe33d7b1..13b394dfbbcd11b13c94174884cf92d5ad122241 100644 (file)
@@ -150,7 +150,7 @@ final class SemanticVersionImport {
                 stmt.addToNs(ImportPrefixToSemVerSourceIdentifier.class, impPrefix, semVerModuleIdentifier);
 
                 final QNameModule mod = InferenceException.throwIfNull(stmt.getFromNamespace(
-                    ModuleCtxToModuleQName.class, importedModule), stmt.getStatementSourceReference(),
+                    ModuleCtxToModuleQName.class, importedModule), stmt.sourceReference(),
                     "Failed to find module of %s", importedModule);
 
                 final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(),
@@ -162,7 +162,7 @@ final class SemanticVersionImport {
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
                 if (failed.contains(imported)) {
-                    throw new InferenceException(stmt.getStatementSourceReference(),
+                    throw new InferenceException(stmt.sourceReference(),
                             "Unable to find module compatible with requested import [%s(%s)].", moduleName,
                             getRequestedImportVersionString(stmt));
                 }
index f87bcddd1f88fd983d1d411717ae9f77e46d9eba..d9a58e31c621e2a3f085f957f4924f86eeac6cb2 100644 (file)
@@ -81,8 +81,7 @@ abstract class AbstractIncludeStatementSupport
 
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
-                InferenceException.throwIf(failed.contains(requiresCtxPrerequisite),
-                    stmt.getStatementSourceReference(),
+                InferenceException.throwIf(failed.contains(requiresCtxPrerequisite), stmt.sourceReference(),
                     "Included submodule '%s' was not found: ", stmt.getStatementArgument());
             }
         });
index d4ab2e686962619337ad94dce01fa26ce59450f0..7d7190aa000ae5d335c696260382c4e78142ad5c 100644 (file)
@@ -56,8 +56,8 @@ public final class KeyStatementSupport
 
         // Throws NPE on nulls, retains first inserted value, cannot be modified
         final ImmutableSet<QName> ret = builder.build();
-        SourceException.throwIf(ret.size() != tokens, ctx.getStatementSourceReference(),
-                "Key argument '%s' contains duplicates", value);
+        SourceException.throwIf(ret.size() != tokens, ctx.sourceReference(), "Key argument '%s' contains duplicates",
+            value);
         return ret;
     }
 
index eed28a0ce2e4ef37b62b7408b436d08b72a977f1..fba826934f500a49fc94c87c5358f049bec731a0 100644 (file)
@@ -60,10 +60,10 @@ public final class LengthStatementSupport
                 max = parseIntegerConstraintValue(ctx, boundaries.next());
 
                 // if min larger than max then error
-                SourceException.throwIf(ArgumentUtils.compareNumbers(min, max) == 1, ctx.getStatementSourceReference(),
-                        "Length constraint %s has descending order of boundaries; should be ascending.", singleRange);
-                SourceException.throwIf(boundaries.hasNext(), ctx.getStatementSourceReference(),
-                        "Wrong number of boundaries in length constraint %s.", singleRange);
+                SourceException.throwIf(ArgumentUtils.compareNumbers(min, max) == 1, ctx.sourceReference(),
+                    "Length constraint %s has descending order of boundaries; should be ascending.", singleRange);
+                SourceException.throwIf(boundaries.hasNext(), ctx.sourceReference(),
+                    "Wrong number of boundaries in length constraint %s.", singleRange);
             } else {
                 max = min;
             }
@@ -71,7 +71,7 @@ public final class LengthStatementSupport
             // some of intervals overlapping
             InferenceException.throwIf(ranges.size() > 1
                 && ArgumentUtils.compareNumbers(min, Iterables.getLast(ranges).upperBound()) != 1,
-                        ctx.getStatementSourceReference(),  "Some of the length ranges in %s are not disjoint", value);
+                        ctx.sourceReference(),  "Some of the length ranges in %s are not disjoint", value);
             ranges.add(ValueRange.of(min, max));
         }
 
@@ -113,7 +113,7 @@ public final class LengthStatementSupport
         try {
             return new BigInteger(value);
         } catch (final NumberFormatException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e, "Value %s is not a valid integer", value);
+            throw new SourceException(ctx.sourceReference(), e, "Value %s is not a valid integer", value);
         }
     }
 }
\ No newline at end of file
index 8a1a9b6a2de42a94f0f871be9635e1240550a553..860a0dfe19536d0423bec9623e879e3d7f97769c 100644 (file)
@@ -127,7 +127,7 @@ abstract class AbstractListStatementSupport extends
             ((Mutable<?, ?, ?>) warnCtx).addToNs(ConfigListWarningNamespace.class, Boolean.TRUE, Boolean.TRUE);
             LOG.info("Configuration list {} does not define any keys in violation of RFC7950 section 7.8.2. While "
                     + "this is fine with OpenDaylight, it can cause interoperability issues with other systems "
-                    + "[defined at {}]", ctx.getStatementArgument(), warnCtx.getStatementSourceReference());
+                    + "[defined at {}]", ctx.getStatementArgument(), warnCtx.sourceReference());
         }
     }
 
index 27f35a6b64f4c86f20e35c2fb2947f986516fd94..6170a02c71da1b841f35ec2757fe115e7a32f809 100644 (file)
@@ -38,7 +38,7 @@ public final class MinElementsStatementSupport
         try {
             return Integer.valueOf(value);
         } catch (NumberFormatException e) {
-            throw new SourceException("Invalid min-elements argument", ctx.getStatementSourceReference(), e);
+            throw new SourceException("Invalid min-elements argument", ctx.sourceReference(), e);
         }
     }
 
index 8536478835e3f87cf28ecd2bb4574af65d10c178..2c2d6783e97229e6646468305d0dbdf4f1570fdf 100644 (file)
@@ -36,7 +36,7 @@ public final class ModifierStatementSupport
 
     @Override
     public ModifierKind parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return SourceException.unwrap(ModifierKind.parse(value), ctx.getStatementSourceReference(),
+        return SourceException.unwrap(ModifierKind.parse(value), ctx.sourceReference(),
             "'%s' is not valid argument of modifier statement", value);
     }
 
index f41c7b131c96e339d6435dc6a5b2ed0d84ce48db..54030aefebbd6925dbe0f4aaf09fec26d633cd29 100644 (file)
@@ -38,6 +38,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
 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;
@@ -55,7 +56,6 @@ import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelon
 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> {
@@ -68,7 +68,7 @@ abstract class AbstractModuleStatementSupport
         try {
             return UnqualifiedQName.of(value);
         } catch (IllegalArgumentException e) {
-            throw new SourceException(e.getMessage(), ctx.getStatementSourceReference(), e);
+            throw new SourceException(e.getMessage(), ctx.sourceReference(), e);
         }
     }
 
@@ -78,12 +78,12 @@ abstract class AbstractModuleStatementSupport
         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);
 
@@ -103,7 +103,7 @@ abstract class AbstractModuleStatementSupport
 
         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());
@@ -111,8 +111,8 @@ abstract class AbstractModuleStatementSupport
         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();
@@ -123,7 +123,7 @@ abstract class AbstractModuleStatementSupport
         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);
@@ -173,14 +173,14 @@ abstract class AbstractModuleStatementSupport
 
     @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<>();
@@ -199,8 +199,8 @@ abstract class AbstractModuleStatementSupport
         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(
index 0183cab28ce68fac2f2d63fd92bcc5ee0fed6f2a..548fb5ea0389456c4bde9359b458dafc2ef19574 100644 (file)
@@ -42,7 +42,7 @@ public final class NamespaceStatementSupport
         try {
             return new URI(value);
         } catch (URISyntaxException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e, "Invalid namespace \"%s\"", value);
+            throw new SourceException(ctx.sourceReference(), e, "Invalid namespace \"%s\"", value);
         }
     }
 
index 9359e67e64d6df927a91e24dd11017e3f9a295a2..e1373b46052db47c26a9555730c3173531722fec 100644 (file)
@@ -53,7 +53,7 @@ public final class OrderedByStatementSupport
         try {
             return Ordering.forArgument(value);
         } catch (IllegalArgumentException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e, "Invalid ordered-by argument '%s'", value);
+            throw new SourceException(ctx.sourceReference(), e, "Invalid ordered-by argument '%s'", value);
         }
     }
 
index 02b92bce9cdd5d12c7c0e20f78a28d3af3bdbc4c..7fae6a57aca9d144cac347332c24a07f35283899 100644 (file)
@@ -79,7 +79,7 @@ class PathExpressionParser {
         final LeafRefPathLexer lexer = new LeafRefPathLexer(CharStreams.fromString(pathArg));
         final LeafRefPathParser parser = new LeafRefPathParser(new CommonTokenStream(lexer));
         final Path_argContext path = SourceExceptionParser.parse(lexer, parser, parser::path_arg,
-            ctx.getStatementSourceReference());
+            ctx.sourceReference());
 
         final ParseTree childPath = path.getChild(0);
         final Steps steps;
index a799b6741118a8176f3afd36ec7bafdd2dd02c4b..9a8710b6db039e3290b7b700ed5372cd6e79733f 100644 (file)
@@ -34,8 +34,7 @@ abstract class AbstractPatternStatementSupport
         try {
             Pattern.compile(pattern);
         } catch (final PatternSyntaxException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
-                "Pattern \"%s\" failed to compile", pattern);
+            throw new SourceException(ctx.sourceReference(), e, "Pattern \"%s\" failed to compile", pattern);
         }
         return PatternExpression.of(value, pattern);
     }
index dfe9a89756e235b4f419750ec33609f78d849703..03935e82d577033703cb7a859bf8505ab5e70213 100644 (file)
@@ -38,8 +38,7 @@ public final class PositionStatementSupport
         try {
             return Uint32.valueOf(value).intern();
         } catch (IllegalArgumentException e) {
-            throw new SourceException(String.format("Bit position value %s is not valid integer", value),
-                    ctx.getStatementSourceReference(), e);
+            throw new SourceException(ctx.sourceReference(), e, "Bit position value %s is not valid integer", value);
         }
     }
 
index 5a693b307eba467cdcd89d2f1450890414a0cc64..71e5fa6add098e855583a76249ba4d96808ca102 100644 (file)
@@ -61,9 +61,9 @@ public final class RangeStatementSupport
                 max = parseDecimalConstraintValue(ctx, boundaries.next());
 
                 // if min larger than max then error
-                SourceException.throwIf(ArgumentUtils.compareNumbers(min, max) == 1, ctx.getStatementSourceReference(),
-                        "Range constraint %s has descending order of boundaries; should be ascending", singleRange);
-                SourceException.throwIf(boundaries.hasNext(), ctx.getStatementSourceReference(),
+                SourceException.throwIf(ArgumentUtils.compareNumbers(min, max) == 1, ctx.sourceReference(),
+                    "Range constraint %s has descending order of boundaries; should be ascending", singleRange);
+                SourceException.throwIf(boundaries.hasNext(), ctx.sourceReference(),
                     "Wrong number of boundaries in range constraint %s", singleRange);
             } else {
                 max = min;
@@ -72,7 +72,7 @@ public final class RangeStatementSupport
             // some of intervals overlapping
             InferenceException.throwIf(ranges.size() > 1
                 && ArgumentUtils.compareNumbers(min, Iterables.getLast(ranges).upperBound()) != 1,
-                ctx.getStatementSourceReference(),  "Some of the value ranges in %s are not disjoint", rangeArgument);
+                ctx.sourceReference(),  "Some of the value ranges in %s are not disjoint", rangeArgument);
             ranges.add(ValueRange.of(min, max));
         }
 
@@ -114,8 +114,7 @@ public final class RangeStatementSupport
         try {
             return value.indexOf('.') != -1 ? new BigDecimal(value) : new BigInteger(value);
         } catch (final NumberFormatException e) {
-            throw new SourceException(String.format("Value %s is not a valid decimal number", value),
-                    ctx.getStatementSourceReference(), e);
+            throw new SourceException(ctx.sourceReference(), e, "Value %s is not a valid decimal number", value);
         }
     }
 }
\ No newline at end of file
index 78d303fd5bb3521e95a16d1d7d77dbf19a6220be..f6f83e7b9303abde4d8e843007a22152ed23cebc 100644 (file)
@@ -43,7 +43,7 @@ public final class RevisionStatementSupport
         try {
             return Revision.of(value);
         } catch (DateTimeParseException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
+            throw new SourceException(ctx.sourceReference(), e,
                 "Revision value %s is not in required format yyyy-MM-dd", value);
         }
     }
index 18216d438f0efc9d0c5000df49a8cee42a27aa26..4bbcacc13bea54650493b4f08c24532ccc087eef 100644 (file)
@@ -40,7 +40,7 @@ public final class RevisionDateStatementSupport
         try {
             return Revision.of(value);
         } catch (DateTimeParseException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
+            throw new SourceException(ctx.sourceReference(), e,
                 "Revision value %s is not in required format yyyy-MM-dd", value);
         }
     }
index 10acc671f3bcfe0219836d3c6fbb8d7e72aa4f2b..1673357ce1c235c36903466f13a2161ad0f70c1a 100644 (file)
@@ -63,7 +63,7 @@ public final class StatusStatementSupport
             case "obsolete":
                 return Status.OBSOLETE;
             default:
-                throw new SourceException(ctx.getStatementSourceReference(),
+                throw new SourceException(ctx.sourceReference(),
                     "Invalid status '%s', must be one of 'current', 'deprecated' or 'obsolete'", value);
         }
     }
index 55e9a39bd63c6e72ca24da759544d5517665b535..ce8728461579dd5614388e9cc8da5953ff3c4f15 100644 (file)
@@ -23,13 +23,13 @@ import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
+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.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 abstract class AbstractSubmoduleStatementSupport
         extends BaseStatementSupport<UnqualifiedQName, SubmoduleStatement, SubmoduleEffectiveStatement> {
@@ -42,7 +42,7 @@ abstract class AbstractSubmoduleStatementSupport
         try {
             return UnqualifiedQName.of(value);
         } catch (IllegalArgumentException e) {
-            throw new SourceException(e.getMessage(), ctx.getStatementSourceReference(), e);
+            throw new SourceException(e.getMessage(), ctx.sourceReference(), e);
         }
     }
 
@@ -62,8 +62,8 @@ abstract class AbstractSubmoduleStatementSupport
         final StmtContext<?, SubmoduleStatement, SubmoduleEffectiveStatement>
             possibleDuplicateSubmodule = stmt.getFromNamespace(SubmoduleNamespace.class, submoduleIdentifier);
         if (possibleDuplicateSubmodule != null && possibleDuplicateSubmodule != stmt) {
-            throw new SourceException(stmt.getStatementSourceReference(), "Submodule name collision: %s. At %s",
-                    stmt.rawStatementArgument(), possibleDuplicateSubmodule.getStatementSourceReference());
+            throw new SourceException(stmt.sourceReference(), "Submodule name collision: %s. At %s",
+                    stmt.rawArgument(), possibleDuplicateSubmodule.sourceReference());
         }
 
         stmt.addContext(SubmoduleNamespace.class, submoduleIdentifier, stmt);
@@ -71,10 +71,10 @@ abstract class AbstractSubmoduleStatementSupport
         final String belongsToModuleName = firstAttributeOf(stmt.declaredSubstatements(), BelongsToStatement.class);
         final StmtContext<?, ?, ?> prefixSubStmtCtx = findFirstDeclaredSubstatement(stmt, 0,
                 BelongsToStatement.class, PrefixStatement.class);
-        SourceException.throwIfNull(prefixSubStmtCtx, stmt.getStatementSourceReference(),
-                "Prefix of belongsTo statement is missing in submodule [%s]", stmt.rawStatementArgument());
+        SourceException.throwIfNull(prefixSubStmtCtx, stmt.sourceReference(),
+                "Prefix of belongsTo statement is missing in submodule [%s]", stmt.rawArgument());
 
-        final String prefix = prefixSubStmtCtx.rawStatementArgument();
+        final String prefix = prefixSubStmtCtx.rawArgument();
         stmt.addToNs(BelongsToPrefixToModuleName.class, prefix, belongsToModuleName);
     }
 
@@ -88,19 +88,19 @@ abstract class AbstractSubmoduleStatementSupport
     @Override
     protected final SubmoduleStatement createEmptyDeclared(
             final StmtContext<UnqualifiedQName, SubmoduleStatement, ?> ctx) {
-        throw noBelongsTo(ctx.getStatementSourceReference());
+        throw noBelongsTo(ctx);
     }
 
     @Override
     protected SubmoduleEffectiveStatement createEffective(final Current<UnqualifiedQName, SubmoduleStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noBelongsTo(stmt.sourceReference());
+            throw noBelongsTo(stmt);
         }
         return new SubmoduleEffectiveStatementImpl(stmt, substatements);
     }
 
-    private static SourceException noBelongsTo(final StatementSourceReference ref) {
-        return new SourceException("No belongs-to declared in submodule", ref);
+    private static SourceException noBelongsTo(final CommonStmtCtx stmt) {
+        return new SourceException("No belongs-to declared in submodule", stmt.sourceReference());
     }
 }
index dff99f6fcf5428ce60a74f961d9a74d4b26a43f8..ae2a0453d12c37caaafb85c3e036e6ddb9fb4521 100644 (file)
@@ -149,8 +149,8 @@ final class SubmoduleEffectiveStatementImpl
     private static @NonNull String findSubmodulePrefix(final StmtContext<UnqualifiedQName, ?, ?> ctx) {
         final String name = ctx.getRawArgument();
         final StmtContext<?, ?, ?> belongsTo = SourceException.throwIfNull(
-                StmtContextUtils.findFirstDeclaredSubstatement(ctx, BelongsToStatement.class),
-                ctx.sourceReference(), "Unable to find belongs-to statement in submodule %s.", name);
+            StmtContextUtils.findFirstDeclaredSubstatement(ctx, BelongsToStatement.class), ctx.sourceReference(),
+            "Unable to find belongs-to statement in submodule %s.", name);
         return findPrefix(belongsTo, "submodule", name);
     }
 }
index d6f044e9ea244d56a6a1bf93514a59406c108443..867afc24e7cd525692a11f3b0539f73adcf5cbed 100644 (file)
@@ -23,13 +23,13 @@ import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.type.IdentityrefTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.IdentityNamespace;
+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.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 abstract class AbstractIdentityRefSpecificationSupport
         extends BaseStatementSupport<String, IdentityRefSpecification,
@@ -53,7 +53,7 @@ abstract class AbstractIdentityRefSpecificationSupport
         for (StmtContext<QName, BaseStatement, ?> baseStmt : baseStatements) {
             final QName baseIdentity = baseStmt.coerceStatementArgument();
             final StmtContext<?, ?, ?> stmtCtx = stmt.getFromNamespace(IdentityNamespace.class, baseIdentity);
-            InferenceException.throwIfNull(stmtCtx, stmt.getStatementSourceReference(),
+            InferenceException.throwIfNull(stmtCtx, stmt.sourceReference(),
                 "Referenced base identity '%s' doesn't exist in given scope (module, imported modules, submodules)",
                     baseIdentity.getLocalName());
         }
@@ -68,7 +68,7 @@ abstract class AbstractIdentityRefSpecificationSupport
     @Override
     protected final IdentityRefSpecification createEmptyDeclared(
             final StmtContext<String, IdentityRefSpecification, ?> ctx) {
-        throw noBase(ctx.getStatementSourceReference());
+        throw noBase(ctx);
     }
 
     @Override
@@ -76,7 +76,7 @@ abstract class AbstractIdentityRefSpecificationSupport
             final Current<String, IdentityRefSpecification> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noBase(stmt.sourceReference());
+            throw noBase(stmt);
         }
 
         final IdentityrefTypeBuilder builder = BaseTypes.identityrefTypeBuilder(stmt.getSchemaPath());
@@ -92,7 +92,7 @@ abstract class AbstractIdentityRefSpecificationSupport
         return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
     }
 
-    private static SourceException noBase(final StatementSourceReference ref) {
+    private static SourceException noBase(final CommonStmtCtx stmt) {
         /*
          *  https://tools.ietf.org/html/rfc7950#section-9.10.2
          *
@@ -100,6 +100,6 @@ abstract class AbstractIdentityRefSpecificationSupport
          *     statement, MUST be present at least once if the type is
          *     "identityref".
          */
-        return new SourceException("At least one base statement has to be present", ref);
+        return new SourceException("At least one base statement has to be present", stmt.sourceReference());
     }
 }
\ No newline at end of file
index adc474db74751ee123ef2e93bb4c946b6d110ff1..6fdc3b41263f9efee2991392ef78dcaaddc6f3c6 100644 (file)
@@ -17,10 +17,10 @@ import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.LeafrefSpeci
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.type.LeafrefTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+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.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 abstract class AbstractLeafrefSpecificationSupport
         extends BaseStatementSupport<String, LeafrefSpecification, EffectiveStatement<String, LeafrefSpecification>> {
@@ -41,7 +41,7 @@ abstract class AbstractLeafrefSpecificationSupport
 
     @Override
     protected final LeafrefSpecification createEmptyDeclared(final StmtContext<String, LeafrefSpecification, ?> ctx) {
-        throw noPath(ctx.getStatementSourceReference());
+        throw noPath(ctx);
     }
 
     @Override
@@ -49,7 +49,7 @@ abstract class AbstractLeafrefSpecificationSupport
             final Current<String, LeafrefSpecification> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noPath(stmt.sourceReference());
+            throw noPath(stmt);
         }
 
         final LeafrefTypeBuilder builder = BaseTypes.leafrefTypeBuilder(stmt.getSchemaPath());
@@ -65,13 +65,13 @@ abstract class AbstractLeafrefSpecificationSupport
         return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
     }
 
-    private static SourceException noPath(final StatementSourceReference ref) {
+    private static SourceException noPath(final CommonStmtCtx stmt) {
         /*
          *  https://tools.ietf.org/html/rfc7950#section-9.12
          *
          *     When the type is "union", the "type" statement (Section 7.4) MUST be
          *     present.
          */
-        return new SourceException("A path statement has to be present", ref);
+        return new SourceException("A path statement has to be present", stmt.sourceReference());
     }
 }
\ No newline at end of file
index ec970f10cbe287a15a8fdeafafd12ea893d8c07e..d4cfade4b74e139f04497fc032afab6e6e1f480b 100644 (file)
@@ -190,7 +190,7 @@ abstract class AbstractTypeStatementSupport
 
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
-                InferenceException.throwIf(failed.contains(typePrereq), stmt.getStatementSourceReference(),
+                InferenceException.throwIf(failed.contains(typePrereq), stmt.sourceReference(),
                     "Type [%s] was not found.", typeQName);
             }
         });
@@ -341,9 +341,9 @@ abstract class AbstractTypeStatementSupport
                 return BuiltinEffectiveStatement.UINT64;
             default:
                 final QName qname = StmtContextUtils.parseNodeIdentifier(ctx.caerbannog(), argument);
-                final StmtContext<?, TypedefStatement, TypedefEffectiveStatement> typedef =
-                        SourceException.throwIfNull(ctx.getFromNamespace(TypeNamespace.class, qname),
-                            ctx.sourceReference(), "Type '%s' not found", qname);
+                final StmtContext<?, TypedefStatement, TypedefEffectiveStatement> typedef = SourceException.throwIfNull(
+                    ctx.getFromNamespace(TypeNamespace.class, qname), ctx.sourceReference(),
+                    "Type '%s' not found", qname);
                 return typedef.buildEffective().asTypeEffectiveStatement();
         }
     }
@@ -477,8 +477,7 @@ abstract class AbstractTypeStatementSupport
         try {
             return new TypeEffectiveStatementImpl<>(declared, substatements, builder);
         } catch (InvalidRangeConstraintException e) {
-            throw new SourceException(ctx.sourceReference(), e, "Invalid range constraint: %s",
-                e.getOffendingRanges());
+            throw new SourceException(ctx.sourceReference(), e, "Invalid range constraint: %s", e.getOffendingRanges());
         }
     }
 
index 3743381c7b70d049fb9401cd6e957749a7716b38..71cf68009eb1f5ded0c50a513c303859068a6a15 100644 (file)
@@ -19,11 +19,11 @@ import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.type.BitsTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+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.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 final class BitsSpecificationSupport
         extends BaseStatementSupport<String, BitsSpecification, EffectiveStatement<String, BitsSpecification>> {
@@ -54,7 +54,7 @@ final class BitsSpecificationSupport
 
     @Override
     protected BitsSpecification createEmptyDeclared(final StmtContext<String, BitsSpecification, ?> ctx) {
-        throw noBits(ctx.getStatementSourceReference());
+        throw noBits(ctx);
     }
 
     @Override
@@ -62,7 +62,7 @@ final class BitsSpecificationSupport
             final Current<String, BitsSpecification> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noBits(stmt.sourceReference());
+            throw noBits(stmt);
         }
 
         final BitsTypeBuilder builder = BaseTypes.bitsTypeBuilder(stmt.getSchemaPath());
@@ -97,13 +97,13 @@ final class BitsSpecificationSupport
         return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
     }
 
-    private static SourceException noBits(final StatementSourceReference ref) {
+    private static SourceException noBits(final CommonStmtCtx stmt) {
         /*
          *  https://tools.ietf.org/html/rfc7950#section-9.7.4:
          *
          *     The "bit" statement, which is a substatement to the "type" statement,
          *     MUST be present if the type is "bits".
          */
-        return new SourceException("At least one bit statement has to be present", ref);
+        return new SourceException("At least one bit statement has to be present", stmt.sourceReference());
     }
 }
index 352a4cbb84634b0dc20eef505478fef89636d311..e40f70356b5e85c869b54f592912d361060732fe 100644 (file)
@@ -17,11 +17,11 @@ import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.Decimal64Spe
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.type.DecimalTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+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.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 final class Decimal64SpecificationSupport extends BaseStatementSupport<String, Decimal64Specification,
         EffectiveStatement<String, Decimal64Specification>> {
@@ -53,7 +53,7 @@ final class Decimal64SpecificationSupport extends BaseStatementSupport<String, D
 
     @Override
     protected Decimal64Specification createEmptyDeclared(final StmtContext<String, Decimal64Specification, ?> ctx) {
-        throw noFracDigits(ctx.getStatementSourceReference());
+        throw noFracDigits(ctx);
     }
 
     @Override
@@ -61,7 +61,7 @@ final class Decimal64SpecificationSupport extends BaseStatementSupport<String, D
             final Current<String, Decimal64Specification> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noFracDigits(stmt.sourceReference());
+            throw noFracDigits(stmt);
         }
 
         final DecimalTypeBuilder builder = BaseTypes.decimalTypeBuilder(stmt.getSchemaPath());
@@ -78,13 +78,13 @@ final class Decimal64SpecificationSupport extends BaseStatementSupport<String, D
         return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
     }
 
-    private static SourceException noFracDigits(final StatementSourceReference ref) {
+    private static SourceException noFracDigits(final CommonStmtCtx stmt) {
         /*
          *  https://tools.ietf.org/html/rfc7950#section-9.3.4
          *
          *     The "fraction-digits" statement, which is a substatement to the
          *     "type" statement, MUST be present if the type is "decimal64".
          */
-        return new SourceException("At least one fraction-digits statement has to be present", ref);
+        return new SourceException("At least one fraction-digits statement has to be present", stmt.sourceReference());
     }
 }
\ No newline at end of file
index 0cf62859e16dc47dc55ce74f9e1b1aa8e3e602aa..e957feacd6f67e67298c0a0d2038f2fcef27dd37 100644 (file)
@@ -19,11 +19,11 @@ import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPai
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.type.EnumerationTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+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.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 final class EnumSpecificationSupport
         extends BaseStatementSupport<String, EnumSpecification, EffectiveStatement<String, EnumSpecification>> {
@@ -52,7 +52,7 @@ final class EnumSpecificationSupport
 
     @Override
     protected EnumSpecification createEmptyDeclared(final StmtContext<String, EnumSpecification, ?> ctx) {
-        throw noEnum(ctx.getStatementSourceReference());
+        throw noEnum(ctx);
     }
 
     @Override
@@ -60,7 +60,7 @@ final class EnumSpecificationSupport
             final Current<String, EnumSpecification> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noEnum(stmt.sourceReference());
+            throw noEnum(stmt);
         }
 
         final EnumerationTypeBuilder builder = BaseTypes.enumerationTypeBuilder(stmt.getSchemaPath());
@@ -96,14 +96,14 @@ final class EnumSpecificationSupport
         return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
     }
 
-    private static SourceException noEnum(final StatementSourceReference ref) {
+    private static SourceException noEnum(final CommonStmtCtx stmt) {
         /*
          *  https://tools.ietf.org/html/rfc7950#section-9.6.4
          *
          *     The "enum" statement, which is a substatement to the "type"
          *     statement, MUST be present if the type is "enumeration".
          */
-        return new SourceException("At least one enum statement has to be present", ref);
+        return new SourceException("At least one enum statement has to be present", stmt.sourceReference());
     }
 
 }
\ No newline at end of file
index 9f069355b4b461d7ea1dfac7b1682770c96dead4..6504bbd131e6da7cb8abe583ca8035f4637c8839 100644 (file)
@@ -17,11 +17,11 @@ import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement.UnionSpecifi
 import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.type.UnionTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+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.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
 final class UnionSpecificationSupport
         extends BaseStatementSupport<String, UnionSpecification, EffectiveStatement<String, UnionSpecification>> {
@@ -52,7 +52,7 @@ final class UnionSpecificationSupport
 
     @Override
     protected UnionSpecification createEmptyDeclared(final StmtContext<String, UnionSpecification, ?> ctx) {
-        throw noType(ctx.getStatementSourceReference());
+        throw noType(ctx);
     }
 
     @Override
@@ -60,7 +60,7 @@ final class UnionSpecificationSupport
             final Current<String, UnionSpecification> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
         if (substatements.isEmpty()) {
-            throw noType(stmt.sourceReference());
+            throw noType(stmt);
         }
 
         final UnionTypeBuilder builder = BaseTypes.unionTypeBuilder(stmt.getSchemaPath());
@@ -74,13 +74,13 @@ final class UnionSpecificationSupport
         return new TypeEffectiveStatementImpl<>(stmt.declared(), substatements, builder);
     }
 
-    private static SourceException noType(final @NonNull StatementSourceReference ref) {
+    private static SourceException noType(final @NonNull CommonStmtCtx stmt) {
         /*
          *  https://tools.ietf.org/html/rfc7950#section-9.12
          *
          *     When the type is "union", the "type" statement (Section 7.4) MUST be
          *     present.
          */
-        return new SourceException("At least one type statement has to be present", ref);
+        return new SourceException("At least one type statement has to be present", stmt.sourceReference());
     }
 }
index 51a2cab813ed8bd015eaaf443bba6f0062244be7..a084a5ac1a1e99596f2127b219917d2163cdd9e3 100644 (file)
@@ -112,8 +112,7 @@ public final class TypedefStatementSupport extends
         final QName arg = stmt.coerceStatementArgument();
         final StmtContext<?, ?, ?> existing = parent.getFromNamespace(TypeNamespace.class, arg);
         // RFC7950 sections 5.5 and 6.2.1: identifiers must not be shadowed
-        SourceException.throwIf(existing != null, stmt.getStatementSourceReference(), "Duplicate name for typedef %s",
-                arg);
+        SourceException.throwIf(existing != null, stmt.sourceReference(), "Duplicate name for typedef %s", arg);
     }
 
     private static void checkDeclared(final StmtContext<QName, TypedefStatement, ?> ctx) {
index 4a68c8b97ebaa961c57c35544bec069606f5de73..5e6763204af26b2004f6c15d12ab15573839789e 100644 (file)
@@ -55,9 +55,9 @@ public final class UniqueStatementSupport
     @Override
     public ImmutableSet<Descendant> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
         final ImmutableSet<Descendant> uniqueConstraints = parseUniqueConstraintArgument(ctx, value);
-        SourceException.throwIf(uniqueConstraints.isEmpty(), ctx.getStatementSourceReference(),
-                "Invalid argument value '%s' of unique statement. The value must contains at least "
-                        + "one descendant schema node identifier.", value);
+        SourceException.throwIf(uniqueConstraints.isEmpty(), ctx.sourceReference(),
+            "Invalid argument value '%s' of unique statement. The value must contains at least one descendant schema "
+                + "node identifier.", value);
         return uniqueConstraints;
     }
 
@@ -94,9 +94,9 @@ public final class UniqueStatementSupport
         final Set<Descendant> uniqueConstraintNodes = new HashSet<>();
         for (final String uniqueArgToken : SEP_SPLITTER.split(nocrlf)) {
             final SchemaNodeIdentifier nodeIdentifier = ArgumentUtils.nodeIdentifierFromPath(ctx, uniqueArgToken);
-            SourceException.throwIf(nodeIdentifier instanceof Absolute, ctx.getStatementSourceReference(),
-                    "Unique statement argument '%s' contains schema node identifier '%s' "
-                            + "which is not in the descendant node identifier form.", argumentValue, uniqueArgToken);
+            SourceException.throwIf(nodeIdentifier instanceof Absolute, ctx.sourceReference(),
+                "Unique statement argument '%s' contains schema node identifier '%s' which is not in the descendant "
+                    + "node identifier form.", argumentValue, uniqueArgToken);
             uniqueConstraintNodes.add((Descendant) nodeIdentifier);
         }
         return ImmutableSet.copyOf(uniqueConstraintNodes);
index 96dac6261b6f842564e78eef6de43e3938379f30..a3259f1d0df123c5ab057b5b7be741c0d497664e 100644 (file)
@@ -117,9 +117,9 @@ public final class UsesStatementSupport
 
             @Override
             public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
-                InferenceException.throwIf(failed.contains(sourceGroupingPre),
-                        usesNode.getStatementSourceReference(), "Grouping '%s' was not resolved.", groupingName);
-                throw new InferenceException("Unknown error occurred.", usesNode.getStatementSourceReference());
+                InferenceException.throwIf(failed.contains(sourceGroupingPre), usesNode.sourceReference(),
+                    "Grouping '%s' was not resolved.", groupingName);
+                throw new InferenceException("Unknown error occurred.", usesNode.sourceReference());
             }
         });
     }
@@ -293,13 +293,12 @@ public final class UsesStatementSupport
 
     private static void performRefine(final Mutable<?, ?, ?> subStmtCtx, final StmtContext<?, ?, ?> usesParentCtx) {
         final Object refineArgument = subStmtCtx.getStatementArgument();
-        InferenceException.throwIf(!(refineArgument instanceof SchemaNodeIdentifier),
-            subStmtCtx.getStatementSourceReference(),
+        InferenceException.throwIf(!(refineArgument instanceof SchemaNodeIdentifier), subStmtCtx.sourceReference(),
             "Invalid refine argument %s. It must be instance of SchemaNodeIdentifier.", refineArgument);
 
         final Optional<StmtContext<?, ?, ?>> optRefineTargetCtx = SchemaTreeNamespace.findNode(
             usesParentCtx, (SchemaNodeIdentifier) refineArgument);
-        InferenceException.throwIf(!optRefineTargetCtx.isPresent(), subStmtCtx.getStatementSourceReference(),
+        InferenceException.throwIf(!optRefineTargetCtx.isPresent(), subStmtCtx.sourceReference(),
             "Refine target node %s not found.", refineArgument);
 
         final StmtContext<?, ?, ?> refineTargetNodeCtx = optRefineTargetCtx.get();
@@ -307,7 +306,7 @@ public final class UsesStatementSupport
             LOG.trace("Refine node '{}' in uses '{}' has target node unknown statement '{}'. "
                 + "Refine has been skipped. At line: {}", subStmtCtx.getStatementArgument(),
                 subStmtCtx.coerceParentContext().getStatementArgument(),
-                refineTargetNodeCtx.getStatementArgument(), subStmtCtx.getStatementSourceReference());
+                refineTargetNodeCtx.getStatementArgument(), subStmtCtx.sourceReference());
             subStmtCtx.addAsEffectOfStatement(refineTargetNodeCtx);
             return;
         }
@@ -332,10 +331,9 @@ public final class UsesStatementSupport
         final StatementDefinition refineSubstatementDef = refineSubstatementCtx.publicDefinition();
 
         SourceException.throwIf(!isSupportedRefineTarget(refineSubstatementCtx, refineTargetNodeCtx),
-                refineSubstatementCtx.getStatementSourceReference(),
+                refineSubstatementCtx.sourceReference(),
                 "Error in module '%s' in the refine of uses '%s': can not perform refine of '%s' for the target '%s'.",
-                refineSubstatementCtx.getRoot().rawStatementArgument(),
-                refineSubstatementCtx.coerceParentContext().getStatementArgument(),
+                refineSubstatementCtx.getRoot().rawArgument(), refineSubstatementCtx.coerceParentContext().argument(),
                 refineSubstatementCtx.publicDefinition(), refineTargetNodeCtx.publicDefinition());
 
         if (isAllowedToAddByRefine(refineSubstatementDef)) {
index 2819873d82e132dd1e192e3c22a6ea0a4da560e7..b3d360634cb920bc7d0936f18a144fefb64fcab3 100644 (file)
@@ -38,7 +38,7 @@ public final class ValueStatementSupport
         try {
             return Integer.valueOf(value);
         } catch (NumberFormatException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
+            throw new SourceException(ctx.sourceReference(), e,
                 "%s is not valid value statement integer argument in a range of -2147483648..2147483647", value);
         }
     }
index 3a938d79345ae20eca45b1d575fb81387a978a26..0bb4f23ea1d21ba9f67b0c462c353348d92a43d5 100644 (file)
@@ -48,8 +48,8 @@ public final class YangVersionStatementSupport
 
     @Override
     public YangVersion parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return SourceException.unwrap(YangVersion.parse(value), ctx.getStatementSourceReference(),
-            "Unsupported YANG version %s", value);
+        return SourceException.unwrap(YangVersion.parse(value), ctx.sourceReference(),  "Unsupported YANG version %s",
+            value);
     }
 
     @Override
index 1bdcafff014fc5f3d932dded2df47335ecfc68e5..2fa82376b1964480add329d0563618a9b6d3fc7c 100644 (file)
@@ -52,7 +52,7 @@ public class PathExpressionParserTest {
 
     @Before
     public void before() {
-        doReturn(ref).when(ctx).getStatementSourceReference();
+        doReturn(ref).when(ctx).sourceReference();
     }
 
     @Test
index 793bc39511eb0ee33bd80cca8f36df54129c3e9e..28a5dfc7880dfaa8e8182b43533bec1290ab5598 100644 (file)
@@ -85,17 +85,16 @@ public final class SchemaTreeNamespace<D extends DeclaredStatement<QName>,
         return null;
     }
 
-    @SuppressWarnings("unchecked")
     @Override
+    @SuppressWarnings("unchecked")
     public void addTo(final NamespaceStorageNode storage, final QName key, final StmtContext<?, D, E> value) {
         final StmtContext<?, D, E> prev = globalOrStatementSpecific(storage).putToLocalStorageIfAbsent(
             SchemaTreeNamespace.class, key, value);
 
         if (prev != null) {
-            throw new SourceException(value.getStatementSourceReference(),
+            throw new SourceException(value.sourceReference(),
                 "Error in module '%s': cannot add '%s'. Node name collision: '%s' already declared at %s",
-                value.getRoot().rawStatementArgument(), key, prev.getStatementArgument(),
-                prev.getStatementSourceReference());
+                value.getRoot().rawArgument(), key, prev.argument(), prev.sourceReference());
         }
     }
 
@@ -141,7 +140,7 @@ public final class SchemaTreeNamespace<D extends DeclaredStatement<QName>,
         final Collection<? extends StmtContext<?, ?, ?>> unknownSubstatements = StmtContextUtils.findAllSubstatements(
             current, UnknownStatement.class);
         for (final StmtContext<?, ?, ?> unknownSubstatement : unknownSubstatements) {
-            if (localName.equals(unknownSubstatement.rawStatementArgument())) {
+            if (localName.equals(unknownSubstatement.rawArgument())) {
                 return unknownSubstatement;
             }
         }
index 1db723c6417758a2e2589ad34d62183fc726b7cd..d2128d199c44394b6a8ad3cc1e0dafc621c82c1a 100644 (file)
@@ -30,7 +30,7 @@ public abstract class AbstractDeclaredStatement<A> implements DeclaredStatement<
     private final String rawArgument;
 
     protected AbstractDeclaredStatement(final StmtContext<A, ?, ?> context) {
-        rawArgument = context.rawStatementArgument();
+        rawArgument = context.rawArgument();
         argument = context.argument();
         source = context.source();
         definition = context.publicDefinition();
index b9372e0fc0175d02f7604ad3e33144a4877bbdcb..e96b8530c3da9cf38f3040ba49a61b317f3f752a 100644 (file)
@@ -48,7 +48,7 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
         return source();
     }
 
-    // TODO: gradually migrate callers of this method
+    @Deprecated(forRemoval = true)
     default @NonNull StatementSourceReference getStatementSourceReference() {
         return sourceReference();
     }
@@ -57,8 +57,9 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
      * Return the statement argument in literal format.
      *
      * @return raw statement argument string, or null if this statement does not have an argument.
+     * @deprecated Use {@link #rawArgument()} instead.
      */
-    // TODO: gradually migrate callers of this method
+    @Deprecated(forRemoval = true)
     default @Nullable String rawStatementArgument() {
         return rawArgument();
     }
index 1262a3e6ab1d508702b4db58f1b216c204c764bf..f5fde6a803fddcd88fe09b0f4e00c5943e724fdc 100644 (file)
@@ -453,7 +453,7 @@ public final class StmtContextUtils {
         leafStmtCtx.allSubstatements().forEach(leafSubstmtCtx -> {
             final StatementDefinition statementDef = leafSubstmtCtx.publicDefinition();
             SourceException.throwIf(YangStmtMapping.IF_FEATURE.equals(statementDef)
-                    || YangStmtMapping.WHEN.equals(statementDef), leafStmtCtx.getStatementSourceReference(),
+                    || YangStmtMapping.WHEN.equals(statementDef), leafStmtCtx.sourceReference(),
                     "%s statement is not allowed in %s leaf statement which is specified as a list key.",
                     statementDef.getStatementName(), leafStmtCtx.getStatementArgument());
         });
@@ -489,8 +489,7 @@ public final class StmtContextUtils {
                 }
         }
 
-        return internedQName(ctx,
-            InferenceException.throwIfNull(qnameModule, ctx.getStatementSourceReference(),
+        return internedQName(ctx, InferenceException.throwIfNull(qnameModule, ctx.sourceReference(),
             "Cannot resolve QNameModule for '%s'", value), localName);
     }
 
@@ -504,15 +503,14 @@ public final class StmtContextUtils {
      * @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.getStatementSourceReference(),
-                "Identifier may not be an empty string");
+        SourceException.throwIf(str.isEmpty(), ctx.sourceReference(), "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.getStatementSourceReference(),
+            InferenceException.throwIfNull(getModuleQNameByPrefix(ctx, prefix), ctx.sourceReference(),
                 "Cannot resolve QNameModule for '%s'", prefix),
             localName);
     }
@@ -527,8 +525,7 @@ public final class StmtContextUtils {
      * @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.getStatementSourceReference(),
-                "Node identifier may not be an empty string");
+        SourceException.throwIf(str.isEmpty(), ctx.sourceReference(), "Node identifier may not be an empty string");
 
         final int colon = str.indexOf(':');
         if (colon == -1) {
@@ -536,11 +533,9 @@ public final class StmtContextUtils {
         }
 
         final String prefix = str.substring(0, colon);
-        SourceException.throwIf(prefix.isEmpty(), ctx.getStatementSourceReference(),
-            "String '%s' has an empty prefix", str);
+        SourceException.throwIf(prefix.isEmpty(), ctx.sourceReference(), "String '%s' has an empty prefix", str);
         final String localName = str.substring(colon + 1);
-        SourceException.throwIf(localName.isEmpty(), ctx.getStatementSourceReference(),
-            "String '%s' has an empty identifier", str);
+        SourceException.throwIf(localName.isEmpty(), ctx.sourceReference(), "String '%s' has an empty identifier", str);
 
         return parseNodeIdentifier(ctx, prefix, localName);
     }
@@ -555,7 +550,7 @@ public final class StmtContextUtils {
         try {
             template = QName.create(module, localName);
         } catch (IllegalArgumentException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e, "Invalid identifier '%s'", localName);
+            throw new SourceException(ctx.sourceReference(), e, "Invalid identifier '%s'", localName);
         }
         return template.intern();
     }
index df388872323d0c70c54f9e1f51b68f61aa3beac3..d80c428c3790d907b20f5f8da3427e0e1ef03c8e 100644 (file)
@@ -130,10 +130,10 @@ public final class SubstatementValidator {
 
             if (cardinality == null) {
                 if (ctx.getFromNamespace(ExtensionNamespace.class, key.getStatementName()) == null) {
-                    throw new InvalidSubstatementException(ctx.getStatementSourceReference(),
-                        "%s is not valid for %s. Error in module %s (%s)", key, currentStatement,
-                        ctx.getRoot().rawStatementArgument(),
-                        ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx.getRoot()));
+                    final StmtContext<?, ?, ?> root = ctx.getRoot();
+                    throw new InvalidSubstatementException(ctx.sourceReference(),
+                        "%s is not valid for %s. Error in module %s (%s)", key, currentStatement, root.rawArgument(),
+                        ctx.getFromNamespace(ModuleCtxToModuleQName.class, root));
                 }
 
                 continue;
@@ -141,20 +141,22 @@ public final class SubstatementValidator {
 
             if (cardinality.getMin() > 0) {
                 if (cardinality.getMin() > value) {
-                    throw new InvalidSubstatementException(ctx.getStatementSourceReference(),
+                    final StmtContext<?, ?, ?> root = ctx.getRoot();
+                    throw new InvalidSubstatementException(ctx.sourceReference(),
                         "Minimal count of %s for %s is %s, detected %s. Error in module %s (%s)", key, currentStatement,
-                        cardinality.getMin(), value, ctx.getRoot().rawStatementArgument(),
-                        ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx.getRoot()));
+                        cardinality.getMin(), value, root.rawArgument(),
+                        ctx.getFromNamespace(ModuleCtxToModuleQName.class, root));
                 }
 
                 // Encountered a mandatory statement, hence we are not missing it
                 missingMandatory.remove(key);
             }
             if (cardinality.getMax() < value) {
-                throw new InvalidSubstatementException(ctx.getStatementSourceReference(),
+                final StmtContext<?, ?, ?> root = ctx.getRoot();
+                throw new InvalidSubstatementException(ctx.sourceReference(),
                     "Maximal count of %s for %s is %s, detected %s. Error in module %s (%s)", key, currentStatement,
-                    cardinality.getMax(), value, ctx.getRoot().rawStatementArgument(),
-                    ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx.getRoot()));
+                    cardinality.getMax(), value, root.rawArgument(),
+                    ctx.getFromNamespace(ModuleCtxToModuleQName.class, root));
             }
         }
 
@@ -163,10 +165,9 @@ public final class SubstatementValidator {
             final Entry<StatementDefinition, Cardinality> e = missingMandatory.entrySet().iterator().next();
             final StmtContext<?, ?, ?> root = ctx.getRoot();
 
-            throw new MissingSubstatementException(ctx.getStatementSourceReference(),
+            throw new MissingSubstatementException(ctx.sourceReference(),
                 "%s is missing %s. Minimal count is %s. Error in module %s (%s)", currentStatement, e.getKey(),
-                e.getValue().getMin(), root.rawStatementArgument(), ctx.getFromNamespace(ModuleCtxToModuleQName.class,
-                    root));
+                e.getValue().getMin(), root.rawArgument(), ctx.getFromNamespace(ModuleCtxToModuleQName.class, root));
         }
     }