Do not use substatements in StmtContextUtils.getRootModuleQName() 33/102133/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:41:31 +0000 (15:41 +0200)
commitedebc7052ba36a28d188d430604deac4043b76a1
tree4650096f635ed0a814793534deba6f5983d33ed2
parent24d4f0dde279e5a8afb5843ab351e511c5d17014
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