StmtContextUtils.parseNodeIdentifier() is augmentation-agnostic 46/93946/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 27 Nov 2020 03:15:12 +0000 (04:15 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 27 Nov 2020 03:35:35 +0000 (04:35 +0100)
This special-casing code for augmentation history was used when we
did not have BaseQNameStatementSupport.adaptArgumentValue() and used
the parser in context which are not adapted.

Since we have no callers actually hitting this special case, we can
remove it.

Change-Id: Ieaca3ec844fa8e4bc7b28db6732d94d7120e0fdd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java

index 6e59f57d1d65d3638d7619eb4a6a5c32471f2b5e..dc08ef20a58cc5b24aab8e59eeffa5a3ec4a50a4 100644 (file)
@@ -510,25 +510,12 @@ public final class StmtContextUtils {
         return internedQName(ctx, str);
     }
 
-    public static QName parseNodeIdentifier(StmtContext<?, ?, ?> ctx, final String prefix,
+    public static QName parseNodeIdentifier(final StmtContext<?, ?, ?> ctx, final String prefix,
             final String localName) {
-        final QNameModule module = getModuleQNameByPrefix(ctx, prefix);
-        if (module != null) {
-            return internedQName(ctx, module, localName);
-        }
-
-        if (ctx.getCopyHistory().getLastOperation() == CopyType.ADDED_BY_AUGMENTATION) {
-            final Optional<? extends StmtContext<?, ?, ?>> optOrigCtx = ctx.getOriginalCtx();
-            if (optOrigCtx.isPresent()) {
-                ctx = optOrigCtx.get();
-                final QNameModule origModule = getModuleQNameByPrefix(ctx, prefix);
-                if (origModule != null) {
-                    return internedQName(ctx, origModule, localName);
-                }
-            }
-        }
-
-        throw new InferenceException(ctx.getStatementSourceReference(), "Cannot resolve QNameModule for '%s'", prefix);
+        return internedQName(ctx,
+            InferenceException.throwIfNull(getModuleQNameByPrefix(ctx, prefix), ctx.getStatementSourceReference(),
+                "Cannot resolve QNameModule for '%s'", prefix),
+            localName);
     }
 
     /**