Do not use substatements in StmtContextUtils.getRootModuleQName() 34/102134/1
authorSangwook Ha <sangwook.ha@verizon.com>
Tue, 7 Jun 2022 21:12:36 +0000 (14:12 -0700)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 13:42:40 +0000 (15:42 +0200)
commitc9028bba87de9adfa4607b9df600508bba4d3550
treed0766a879851d4b25d705509a81ab8611653c9f7
parent23d130981f5357ef7da53710df5be12728ad6204
Do not use substatements in StmtContextUtils.getRootModuleQName()

Building effective model fails when a grouping in a submodule
is augmented from another submodule or the unique statement points
to a leaf in a grouping from another submodule.

Add test cases to reproduce the issues, which points to us accessing
substatements of submodules after all references have been resolved.

Since we already rely on SOURCE_LINKAGE being complete in this method
(e.g. ModuleCtxToModuleQName being populated), switch from using
statement enumeration to also using the BelongsToPrefixToModuleCtx
namespace, which resolved during that same phase.

JIRA: YANGTOOLS-1436
Change-Id: I71eb1122bf7c3820043a3197249a3b2fba6e9e8c
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 30f4e375338124bbb66d2bf1e1c65d0968fd1f0e)
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1436Test.java [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1436/augment/foo-a.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1436/augment/foo-b.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1436/augment/foo.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1436/unique/bar-a.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1436/unique/bar-b.yang [new file with mode: 0644]
parser/yang-parser-rfc7950/src/test/resources/bugs/YT1436/unique/bar.yang [new file with mode: 0644]
parser/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java