yangtools.git
7 months agoRelease yangtools v9.0.10
jenkins-releng [Mon, 30 Oct 2023 10:19:32 +0000 (10:19 +0000)]
Release yangtools

7 months agoBump odlparent to 11.0.7 31/108731/2
Robert Varga [Sun, 29 Oct 2023 23:19:00 +0000 (00:19 +0100)]
Bump odlparent to 11.0.7

Pick up latest upgrades.

Change-Id: Ia1756aafe39d5be6e2436a1712c1ce5d3e2f6715
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoUpdate XmlToNormalizedNodesTest 38/108738/1
Robert Varga [Mon, 30 Oct 2023 09:32:50 +0000 (10:32 +0100)]
Update XmlToNormalizedNodesTest

Spell out the two YANG files used in the test.

Change-Id: Ic7fa9d591afd5985adc647dad2656a5ce2a4d9df
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoBump versions to 9.0.10-SNAPSHOT 30/108730/2
Robert Varga [Sun, 29 Oct 2023 23:15:44 +0000 (00:15 +0100)]
Bump versions to 9.0.10-SNAPSHOT

This starts the next development iteration.

Change-Id: Icd59bf39604026a9dca2402b4d0594f1e498e029
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
7 months agoRelease yangtools v9.0.9
jenkins-releng [Sun, 29 Oct 2023 21:33:55 +0000 (21:33 +0000)]
Release yangtools

7 months agoDo not create effective copy for unsupported statements 92/108492/1
Sangwook Ha [Thu, 10 Aug 2023 23:15:25 +0000 (16:15 -0700)]
Do not create effective copy for unsupported statements

If we are encountering a statement which is not supported, we should not
create an effective copy of it for the purposes of comparison.

JIRA: YANGTOOLS-1532
Change-Id: I4407e38f2a62c911b653191bf7c6cfd82ba0225e
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 10442e262ee9ef3452f8fa4112e47e2c8d7306c7)
(cherry picked from commit 041a3ae205f0388f5f0df15bbedb27a4aa627cce)
(cherry picked from commit 45aca2ea5d8491cac9d7aa8ef9557c387807e45e)

8 months agoFixup checkstyle in yang-repo-spi 05/108205/1
Robert Varga [Wed, 30 Aug 2023 11:38:44 +0000 (13:38 +0200)]
Fixup checkstyle in yang-repo-spi

Upgraded checkstyle is finding some violations, clean them up.

Change-Id: Iebc51805be902b15cc40e88c43e5c346e8936b6a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7414266f72092cb017df815eeca87f26c7aea432)

8 months agoMake model prefix handling optional 40/108140/4
Robert Varga [Sat, 30 Sep 2023 00:22:32 +0000 (02:22 +0200)]
Make model prefix handling optional

Taking model-based prefixes into account is bound to change our output,
making the encoding a tad more dense. Make the feature selectable by
users as a first step, with an eye towards making it the default.

JIRA: YANGTOOLS-1544
Change-Id: Icedf67b408182e57a99d5d1f52f728c3f64c8657
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9d64ed881c503da6edea8b14d9ecd763a586b4c3)
(cherry picked from commit 7b94bcfa992201d9baac2a96a37c4384b989ac30)

8 months agoClean up NamespacePrefixesTest 39/108139/3
Robert Varga [Sun, 1 Oct 2023 14:51:12 +0000 (16:51 +0200)]
Clean up NamespacePrefixesTest

Now that we have moved decode(), we can specialize it to asserts,
cleaning things up a bit.

Change-Id: I073fde327587bcc78619b2c227f01a5f24057d40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9c84c22a4d712c9925b584a60fabea0fb172ee57)
(cherry picked from commit 7802bb707cfb6b22a7098de52baef552da88a4e1)

8 months agoEnforce mocking in yang-data-codec-xml tests 37/108137/3
Robert Varga [Thu, 28 Sep 2023 19:22:18 +0000 (21:22 +0200)]
Enforce mocking in yang-data-codec-xml tests

Pull in our mockito-configuration, so that we correctly mock all
interactions.

Change-Id: I065b44f7fc62a052475892738a310e7894962da6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8081f3f15e1c5c91d18c0de54efc17ee3612ec50)
(cherry picked from commit de7b27d91e5f7d4b3bf56e633e125cdf85b4b82e)

8 months agoUse YANG-derived prefixes 36/108136/3
Robert Varga [Thu, 28 Sep 2023 20:33:47 +0000 (22:33 +0200)]
Use YANG-derived prefixes

All XML examples starting from RFC6020 onwards use a module's prefix to
identify the module.

This is not something that is universally feasible to do, as the
document context may indicate a different namespace mapping, which may
be more efficient to use.

Such assignments may also conflict with already-assigned prefixes and
redefining XML namespaces increases cognitive load in analysis -- hence
we have to avoid that.

Also prefix assignments are not a global namespace, so we could easily
end up with ambigous mappings. This is unlikely, but it can easily
happen.

With an EffectiveModelContext we can perform analysis on what is valid
within that enclosed world and use that as a guide. When
NamespacePrefixes decides current RandomPrefix (which is not random at
all!) does not have a mapping, we can consult an analysis object to give
us guidance.

This patch renames RandomPrefix to 'NamespacePrefixes' and introduces
PreferredPrefixes, which can be computed from an EffectiveModelContext.

These two then act in unison to assign prefixes based on prefix
statements present in modules forming an EffectiveModelContext whenever
we need to do such a thing.

JIRA: YANGTOOLS-1544
Change-Id: Iafc5806f53d8927e46f059287e2ae3ed2c77ff26
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 316df6dff3f5d3126840db3b732a0797fbd3d35a)
(cherry picked from commit 97d718a9572a91c1b73f8956859ba5c829d03a7e)

8 months agoRemove references to TestCase 38/108138/2
Robert Varga [Fri, 29 Sep 2023 19:00:37 +0000 (21:00 +0200)]
Remove references to TestCase

All we are doing is subclassing and routing to XMLAssert. Just route a
static call.

Change-Id: I786cef83dea43af0d10fab72da202a0989099acb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 248767ccb030bd71494eb4251d7a792d4460b23e)
(cherry picked from commit 274e1aa8f95216047cc9317d7ec8d57d7fcd6849)

8 months agoClean up XML instance identifier class naming 35/108135/1
Robert Varga [Thu, 28 Sep 2023 17:39:39 +0000 (19:39 +0200)]
Clean up XML instance identifier class naming

Naming of things here is not great. We have two distinct implementations
of a full Codec, one of which can handle serialization and the other can
handle parsing.

Clean up naming, by having a top-level, fixed,
InstanceIdentifierXmlCodec, which is what we give users. We then have
InstanceIdentifier{Deserializer,Serializer}, which are bound, single-use
delegates.

This allows us to ditch the thread local stack we have been keeping to
deal with the fact that the implementation is directly internal.

Furthermore we optimize instantiation, so that we minimize the number of
calls to DataSchemaContextTree.from().

JIRA: YANGTOOLS-1543
Change-Id: I1ca884fe57086311111f12b3ba223d08f3676a93
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 99715f7b5483c08f7fe4ec9232281ea04a3941b2)
(cherry picked from commit 3f51d57d3473a02afd1b7cbaf38190e2297fb156)

8 months agoFix XML instance identifier encoding 34/108134/1
Robert Varga [Thu, 28 Sep 2023 15:19:05 +0000 (17:19 +0200)]
Fix XML instance identifier encoding

XmlStringInstanceIdentifierCodec is not encoding prefixes properly. Use
the same trick we use for normal writeout.

Also improve mocking to cover all interactions we expect to happen.

JIRA: YANGTOOLS-1543
Change-Id: Ie018137599bd5a79db962da9573cbbca6bfc0599
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9eb8ac2c8481d48e9eac7f39be3b7b89a4629e8f)
(cherry picked from commit a639ed620880959fb059594a40baf396f8df3da3)

8 months agoImprove YT1473Test stubbing 33/108133/1
Robert Varga [Thu, 28 Sep 2023 16:55:28 +0000 (18:55 +0200)]
Improve YT1473Test stubbing

Execute this test with MockitoExtension, which automatically verifies
all subbings. Refactor assertions accordingly.

JIRA: YANGTOOLS-1543
Change-Id: I099611b575f6a0775600c03e5f3edca41ff0bdd5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4703e9b77dd0d52ce0e7019f718d42f52eed3bb5)
(cherry picked from commit 7a58bdf1bbc064609e410117d6d4c9a9e6b86d89)

8 months agoDo not pass null to codec 32/108132/1
Robert Varga [Thu, 28 Sep 2023 17:06:20 +0000 (19:06 +0200)]
Do not pass null to codec

We are expecting a checked exception and are passing a null argument for
something which we are supposed to interact with. Use a proper mock for
argument. This will allow us to further extend verification should the
implementation change.

JIRA: YANGTOOLS-1543
Change-Id: I0f1defd442ae60ee9e9b1b7a43949eed320ac148
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3462009a37acbe180611e93f8c479bb6fcf62e8a)
(cherry picked from commit b9b2c65fa1f1850779e8b5367e505654d366fc32)

8 months agoImprove context reporting 31/108131/1
Robert Varga [Fri, 22 Sep 2023 23:56:17 +0000 (01:56 +0200)]
Improve context reporting

If we fail at first step, we end up emitting an empty string, which
makes the output not nice. Quote the emitted string.

Change-Id: Ic54f7fd69a902de03205355b37fdc72d9979c051
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ac5a7ba138a2a091f395a2df7b9316c4ebf86e03)
(cherry picked from commit 839cad863d0dcb68f8be19d07c28a2d46ef20a8d)

8 months agoMigrate RandomPrefixTest to JUnit5 30/108130/1
Robert Varga [Thu, 28 Sep 2023 19:45:46 +0000 (21:45 +0200)]
Migrate RandomPrefixTest to JUnit5

Hide the test and clean it up.

Change-Id: I7c5ddc6d04e40e42967089ccea9777347a4daa30
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f8cd76e304a92b75d50171a12817bc3ad4e8e210)
(cherry picked from commit 00c46655ae9945c31a795300895036b6b2eff7c7)

8 months agoClean up XmlStringInstanceIdentifierCodec instantiation 29/108129/1
Robert Varga [Thu, 28 Sep 2023 17:21:32 +0000 (19:21 +0200)]
Clean up XmlStringInstanceIdentifierCodec instantiation

We are inherently tied to the model context of our XmlCodecFactory.
Simplify the constructor and do not store the EffectiveModelContext.

Change-Id: I7676813295275926642018665908f11ec47f402b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 14e932f10fd660f7faca0053a94b4c3d29b86653)
(cherry picked from commit d9a711ee7f9fd518a161b33321f3072479b9f6af)

8 months agoModernize SchemaAwareXMLStreamWriterUtils a bit 28/108128/1
Robert Varga [Thu, 28 Sep 2023 16:02:36 +0000 (18:02 +0200)]
Modernize SchemaAwareXMLStreamWriterUtils a bit

Do not implemented EffectiveModelContextProvider to improve visibility
into invocations. Also use local variable type inference for brevity.

Change-Id: I3141562b0050435ed79f9bd06aa2dac03e59ec08
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ca4f2e05e9916b6843889ccf860a1a531960e22b)
(cherry picked from commit 3e63b435e600d34c6fbd47639cd59f7c8c92fa46)

8 months agoSimplify SchemaAwareXMLStreamNormalizedNodeStreamWriter 27/108127/1
Robert Varga [Thu, 28 Sep 2023 16:04:48 +0000 (18:04 +0200)]
Simplify SchemaAwareXMLStreamNormalizedNodeStreamWriter

There is no need to implement EffectiveModelContext provider here.

Change-Id: I39585b8dc2cefa844110ccf87aa52e9e925599f9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8e96df87d83477b78145e71d8db6781aeaf22a55)
(cherry picked from commit a6d2ee1c6400d946334f4fba19ca6ef32978f8dc)

8 months agoReparent RandomPrefixInstanceIdentifierSerializer 26/108126/1
Robert Varga [Thu, 28 Sep 2023 18:33:54 +0000 (20:33 +0200)]
Reparent RandomPrefixInstanceIdentifierSerializer

We are the only direct subclass of
AbstractStringInstanceIdentifierCodec, which is a direct superclass of
AbstractModuleStringInstanceIdentifierCodec.

Use the latter as superclass, opening up the possiblity of merging the
two abstract classes.

Change-Id: Iee985fb54b102c4764fa4e9685652762db5265b2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 99ba8bec562610435ec94949e1c205b9676c0b84)
(cherry picked from commit 7a8a4bfc9ac807a0a3fd69b951ebad669f1b45c1)

8 months agoModernize SchemaAwareXMLStreamNormalizedNodeStreamWriter a bit 25/108125/1
Robert Varga [Thu, 28 Sep 2023 16:01:25 +0000 (18:01 +0200)]
Modernize SchemaAwareXMLStreamNormalizedNodeStreamWriter a bit

Use instanceof patterns to eliminate explicit casts.

Change-Id: I63e7dc828c03ea4110793b9dd86f0add1ac16c0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 585f8b98cad6508a63fa311f270791d20b487600)
(cherry picked from commit a1c4f462223e309b4549481c71d2b5ca0c778859)

8 months agoModernize XMLStreamWriterUtils 24/108124/1
Robert Varga [Wed, 27 Sep 2023 20:11:26 +0000 (22:11 +0200)]
Modernize XMLStreamWriterUtils

Use instanceof patterns and local variable type inference.

Change-Id: I13ace859c67f508955666d7a8f6599b66b083d96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7416872ac820bc8c1c49a16b52eb9294f1915eea)
(cherry picked from commit d0812de9edd5c2806c3a447fad399b0e91dc348b)

8 months agoReport checked exception in instance identifier writeout 23/108123/1
Robert Varga [Fri, 22 Sep 2023 23:33:03 +0000 (01:33 +0200)]
Report checked exception in instance identifier writeout

Both XML and JSON codecs are talking to a source of
IllegalArgumentExceptions. They should convert them to
XMLStreamException/IOException.

JIRA: YANGTOOLS-1542
Change-Id: Ia5ac633e37ed19c29d4593e2e886501c7baa59dd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1ca7a65e5458b997162fb7255d7cbc782ae28371)
(cherry picked from commit fc60ee72a287c95659a4e2a631f2cc67183d5c4d)

8 months agoExpose JSONCodec and XmlCodec 84/107884/1
Robert Varga [Thu, 14 Sep 2023 19:55:17 +0000 (21:55 +0200)]
Expose JSONCodec and XmlCodec

We have a need to emit YangInstanceIdentifier values into raw writers.
We already have this capability exposed through
{JSON,Xml}Codec.writeValue().

This patch exposes that ability, forcing all AbstractCodecFactories to
do so.

JIRA: YANGTOOLS-1541
Change-Id: I854d67b6a1a57b6a8288c41db9714a3292fef093
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5e6c947ffadb6e3bf6c230abd813ee1c27b08819)
(cherry picked from commit e1b5e6df05dc302a515ef30de4d6a985a304ed2a)

8 months agoRevert "Hide XmlCodecFactory internals" 83/107883/1
Robert Varga [Fri, 15 Sep 2023 13:56:34 +0000 (15:56 +0200)]
Revert "Hide XmlCodecFactory internals"

This reverts commit db06703aa3c1c68d9481b5823c16a570a23dfb6e. It is not
needed as we are about to expose XmlCodec.

JIRA: YANGTOOLS-1541
Change-Id: I861f0363d995517aa6a5a41f1e9077842379dfbe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 135f3a0813c6a6bce6f12c5803eab3f19470dff4)

9 months agoIssue releaseFence() at the of ready() 26/107726/1
Robert Varga [Mon, 4 Sep 2023 20:35:22 +0000 (22:35 +0200)]
Issue releaseFence() at the of ready()

We seem to be observing stale state during modification validation. Make
sure we flush out any and all modifications before we complete ready().

Change-Id: I0f388d143526c96ff1684828dd16fc9ee681305b
JIRA: YANGTOOLS-1537
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 85b0d24aae1ea5d90d07f08dc2da3998bf9a299e)
(cherry picked from commit d0405636db466e73b8ced9c4aa2b98cc12067378)

9 months agoClean up checkSealed() 25/107725/1
Robert Varga [Mon, 4 Sep 2023 21:00:34 +0000 (23:00 +0200)]
Clean up checkSealed()

This method is mis-named, it should be called checkOpen(). Also use
an explicit if/throw to eliminate a negation.

Change-Id: Ia7baa03708711b8076ffdd512fbccacd906e3ffb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d62bf8450405d2487e0ab1b8bff63f50fcb9b991)
(cherry picked from commit 92268b508defc847d27adf6ff6a437794953096e)

9 months agoUse Optional.isEmpty() 24/107724/1
Robert Varga [Mon, 4 Sep 2023 20:46:15 +0000 (22:46 +0200)]
Use Optional.isEmpty()

We have a number of calls to '!Optional.isPresent()'. Java 11 provides a
convenience Optional.isEmpty() for this case, so use that instead.

Change-Id: I519671f470d804e62bae07ec4c5a71aaa08a29f8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a115f79e3818c774d7fc932426d9ef2b65fcae4f)
(cherry picked from commit 1cf3f3704ae1f16ecd39bf67187c6004a45a811d)

9 months agoFix ModifiedNode.identifier nullness 23/107723/1
Robert Varga [Mon, 4 Sep 2023 18:06:12 +0000 (20:06 +0200)]
Fix ModifiedNode.identifier nullness

The identifier should always we present, enforce and annotate that.

Change-Id: I0bcebec56ab6fcee6b3c3b396dddbda92282729f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d761afdb4ea3eab052038dfd185fc5ef65fb2696)
(cherry picked from commit 9116ce01122065da7a494fc8a7f9ad1d6b28a13a)

9 months agoMove ModifiedNode.IS_TERMINAL_PREDICATE 22/107722/1
Robert Varga [Mon, 4 Sep 2023 17:41:10 +0000 (19:41 +0200)]
Move ModifiedNode.IS_TERMINAL_PREDICATE

This predicate has a single user, inline it. Also modernize
InMemoryDataTreeModification while we are in the area.

Change-Id: I3cb15fbcb75d0a28c158256e3ef01e218b90dd2a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ca6c727d73497c2fce7d5be59f9fcc4dff860d70)
(cherry picked from commit c4ed5004f7d9dc3fdd3f54f48b922b605e202765)

9 months agoAdd ValidatedTreeNode 21/107721/1
Robert Varga [Sun, 3 Sep 2023 21:10:01 +0000 (23:10 +0200)]
Add ValidatedTreeNode

We need to @SuppressFBWarnings a use of Optional<TreeNode> being
nullable. Replace Optional with a dedicated record, which provides
adaptation.

Change-Id: Idcd57cc899cacb09d7bec1711d0d084027716734
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6e154f382548320411bc0c22523f2885d00eb802)
(cherry picked from commit dcc74d83636ec1eabbb29f19a76421352d877ef3)

9 months agoUse an instanceof expression 20/107720/1
Robert Varga [Sun, 3 Sep 2023 19:01:59 +0000 (21:01 +0200)]
Use an instanceof expression

We have an-if-and-a-cast, use an instanceof expression instead.

Change-Id: Iee350a79fe740e2434ea1ce35071aa63315f1ae6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5c7760892986122a248ca9baffdd1a16035a90bb)
(cherry picked from commit 2438bacd013b46e26b418b948b60e8821da6085a)

9 months agoImprove NodeModification 19/107719/1
Robert Varga [Sun, 3 Sep 2023 18:42:24 +0000 (20:42 +0200)]
Improve NodeModification

This is a faux-interface to split access. Seal it an allow it to be
implemented only by ModifiedNode.

Introduce NodeModification.isEmpty(), which short-circuits the access to
children.value(). Convert users to prefer this method over accessing
getChildren() -- i.e. moving the potential allocation further down.

Change-Id: Ibce631b729fd496374580be94902c2b18e55268f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit dba093af96755e7fa599b455048b5eab92526d35)
(cherry picked from commit e7fde3389625a3005ecae42e61148b0c6ebba42e)

9 months agoHide XmlCodecFactory internals 49/107549/2
Robert Varga [Mon, 28 Aug 2023 11:15:55 +0000 (13:15 +0200)]
Hide XmlCodecFactory internals

We are getting warnings about leaking XmlCodec. While this is not
exactly true, mitigate these warnings by splitting the real logic
into a package-private class while retaining the same external
XmlCodecFactory facade.

JIRA: YANGTOOLS-1534
Change-Id: I719cf82f00d4580505d92d7126be6d2c09c26a4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit db06703aa3c1c68d9481b5823c16a570a23dfb6e)
(cherry picked from commit d614f302532641396e54b12bd20a69fe5485bc9b)

9 months agoFix XML codec error reporting 48/107548/2
Robert Varga [Sat, 26 Aug 2023 20:59:58 +0000 (22:59 +0200)]
Fix XML codec error reporting

When we deal with anything ContainerLike, aside of ContainerSchemaNode
and ListNodeSchemaNode, we should just accept there is no support and
proceed to throw a descriptive exception.

JIRA: YANGTOOLS-1533
Change-Id: I7a173f3a21dd55d21e48570690427cee0c0ad16f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2ebb91d3916ba7d252df9386cf3c0067040d4a9b)
(cherry picked from commit 28e5e91a8a5e437897246c114be602e596459bd8)

9 months agoSeal XmlCodec 38/107538/1
Robert Varga [Sat, 26 Aug 2023 21:13:12 +0000 (23:13 +0200)]
Seal XmlCodec

We require Java 17, make sure XmlCodec is sealed to be explicit about
what implementations are there.

JIRA: YANGTOOLS-1534
Change-Id: I12ca115663a06666345e956ea9b0901834d1c4c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 64826bc2c5d076bc1f241c0a03a13f12b8b60d4b)
(cherry picked from commit c1f99faeea6dc24dc0fd9c91c28fe8feb31297fd)

9 months agoAdd Inference.isEmpty() 37/107537/1
Robert Varga [Wed, 16 Aug 2023 08:48:38 +0000 (10:48 +0200)]
Add Inference.isEmpty()

Downstreams need logic to adjust the inference unless it is empty.
Expose an isEmpty() method, which efficiently indicates whether the
inference is empty.

Change-Id: Ief6df4d8c2e1db34ea65bb6bdbd7e47525683dad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1fb404a623cfde730cfd9d6d7f2c34595028e80a)
(cherry picked from commit 6f7c8b17227633c5911b3245176f1436a7a87093)

10 months agoDo not trim element content for string leaf values 61/106961/2
Robert Varga [Thu, 20 Jul 2023 23:35:57 +0000 (01:35 +0200)]
Do not trim element content for string leaf values

Trimming element text leads to values being mis-represented -- for
example if the content is a YANG string, we really need to pick it up
directly.

We should completely avoid trimming, but that would lead to not
recognizing previously-accepted XML documents, for example those which
correspond to a uint8 with leading whitespace.

JIRA: YANGTOOLS-1522
Change-Id: Ib1e05a9428a66765b2f85cfde723fe27076f68ee
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e4d7042ceaaf302725209f5bdb037be99a092790)
(cherry picked from commit fa9c3960fcbbbfc93e1c629bfab7a1be00b72ec9)

10 months agoEnrich YangParserTestUtils with parseYang(String) 63/106963/1
matus.matok [Thu, 20 Apr 2023 10:13:56 +0000 (12:13 +0200)]
Enrich YangParserTestUtils with parseYang(String)

Added a new static method parseYang() to YangParserTestUtils which allows for
parsing a yang file directly from s string input. This allows for higher
flexibility as we do not need to deal with resource accessibility across
modules. Additionally, it is sometimes more convenient to prefer this new form
of input rather than the old one.

JIRA: YANGTOOLS-1483
Change-Id: I4865b73ba8770669a54dd5be167b2ca2d63f3585
Signed-off-by: matus.matok <matus.matok@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a0e551c041c426eecd6c6ee6456abe3fa6922a6f)
(cherry picked from commit e77a8ab727b7929e91cf6f8d0afbdb6ab6148de2)

10 months agoImprove XmlParserStream error reporting 60/106960/1
Robert Varga [Fri, 21 Jul 2023 05:04:55 +0000 (07:04 +0200)]
Improve XmlParserStream error reporting

When we encounter an unhandled schema, we should report ISE instead of
IAE to differentiate the two cases.

Change-Id: I9222f821a259ede5b8d56e5111297de565f01d2d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f7f98cc72d28be550a0bd93c25e21abb5184168d)

12 months agoFix InferredStatementContext.isSupportedByFeatures() 66/106366/1
Robert Varga [Thu, 1 Jun 2023 14:24:45 +0000 (16:24 +0200)]
Fix InferredStatementContext.isSupportedByFeatures()

StmtContextUtils.checkFeatureSupport() does not work for
InferredStatementContext, as it does not have any declared
substatements -- that only works for OriginalStmtCtx and its subclasses.

Split out computation of this statement's contribution to
isSupportedByFeatures() into a separate method -- allowing
{Inferred,Replica}StatementContext to forward to their prototype or
source.

This also flushes out a bad assertion in YT1393Test, as the second
augment now get correctly disabled.

JIRA: YANGTOOLS-1514
Change-Id: Icf9740cd828bd337b76f38cf33ee29d607f680aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 17e18b8ef8877adeaa56e05bcacb3c47c2b6e1c6)
(cherry picked from commit 4c8f62d510ff524defd058f505add819676cc993)

12 months agoBump versions to 9.0.9-SNAPSHOT 28/106228/1
Robert Varga [Mon, 29 May 2023 14:35:37 +0000 (16:35 +0200)]
Bump versions to 9.0.9-SNAPSHOT

This starts the next development iteration.

Change-Id: Ia97ffd06aefd3a95307e25305e18f5eaaae88427
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoRelease yangtools v9.0.8
jenkins-releng [Mon, 29 May 2023 11:47:13 +0000 (11:47 +0000)]
Release yangtools

12 months agoBump odlparent to 11.0.6 20/106220/1
Robert Varga [Mon, 29 May 2023 08:25:05 +0000 (10:25 +0200)]
Bump odlparent to 11.0.6

Pick up latest updates.

Change-Id: I9e6bef019c1c9c7d951e76dad2f1d9639214aac8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
12 months agoConvert dependency checking to aether 71/105971/1
Robert Varga [Mon, 15 May 2023 16:44:12 +0000 (18:44 +0200)]
Convert dependency checking to aether

maven-3.9.1 warns when we are using the RepositorySystem. Convert type
checks and remove the mocked test. This allows us to hide the
checkClasspath() method and use injected values. Also inline
getPluginTransitiveDependencies(), as it is now a single-caller thing.

JIRA: YANGTOOLS-1505
Change-Id: I9585774047b99fac557b6b92f5d51eaacfdd0af3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3873a00f5e83dd912df147d75ad600324b30c427)
(cherry picked from commit 8f2b637f29b3f0da7cada41c3ce14701750a127e)

12 months agoRemove YangToSourcesMojo.remoteRepos 70/105970/2
Robert Varga [Mon, 15 May 2023 15:52:09 +0000 (17:52 +0200)]
Remove YangToSourcesMojo.remoteRepos

This is a shorthand and the only user already has project handy.

Change-Id: I1fd6e98c9b781f30a978dc194aacaaa25deec498
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0e7c0c09ddfec121a558b7d918eeffce7e33c86c)
(cherry picked from commit 5ec82b42573af14dc5d131a14c77c91e11ff663a)

12 months agoMove yang.skip property 69/105969/2
Robert Varga [Sat, 13 May 2023 18:33:20 +0000 (20:33 +0200)]
Move yang.skip property

Clean up order of user-visible properties vs. components.

Change-Id: I73f019f98a669b65b411af26681dc98390dc2c40
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bfd37c967ea3341cfd0b6df4beb1059a31f2befa)
(cherry picked from commit 9d957744145a5c7301d4a8e40b5e839c63e2025f)

12 months agoRemove YangToSourcesMojo.parserMode 68/105968/1
Robert Varga [Sat, 13 May 2023 17:16:06 +0000 (19:16 +0200)]
Remove YangToSourcesMojo.parserMode

The parser mode is picked up from the code generators now, remove it.

Change-Id: I9ef0c93c7a7e78c5b1b04459b56257a173eea83a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 56c86596327ef6782006c99c52af2dc4969d03b5)
(cherry picked from commit 47266e0f3c104a5b4caaf97b86611b5494f17891)

13 months agoImprove DistinctNodeContainer.getChildByArg() 47/105447/1
Robert Varga [Sun, 23 Apr 2023 06:51:50 +0000 (08:51 +0200)]
Improve DistinctNodeContainer.getChildByArg()

Improve the reported exception to include the key that was being looked
up.

Change-Id: Ica2885543d5d2c68fd84db54c57948f468f8fa2e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 01eb4c388c218d3cf47d36e0b1258de0150cdef6)

14 months agoBump versions to 9.0.8-SNAPSHOT 70/105370/1
Robert Varga [Tue, 11 Apr 2023 14:13:55 +0000 (16:13 +0200)]
Bump versions to 9.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: I5974d7016974cc5263285ce5a85a77ab67bc107f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoBump odlparent to 11.0.5 37/105337/4
Robert Varga [Mon, 10 Apr 2023 18:06:00 +0000 (20:06 +0200)]
Bump odlparent to 11.0.5

Adopt latest fixes from upstream.

Change-Id: Ic5ddc61fcd46a4dc571ac98faf4d3d3cf5fa4723
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoUse instanceof pattern 44/105344/1
Robert Varga [Sat, 8 Apr 2023 19:56:30 +0000 (21:56 +0200)]
Use instanceof pattern

This removes an unnecessary cast.

Change-Id: I5fed4dbc753f7691b89fe059cbb4f89cf0fc3600
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 623a947f51795732fa55dd77861a194ec238bce8)

14 months agoSimplify InferredStatementContext.hasEmptySubstatements() 43/105343/1
Robert Varga [Mon, 10 Apr 2023 18:33:27 +0000 (20:33 +0200)]
Simplify InferredStatementContext.hasEmptySubstatements()

SonarCloud is pointing out a code smell around explicit 'false',
refactor to eliminate it.

Change-Id: I7d6eb0f902d72dcdf616b48f9b02994b7280358c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 55f97a833864de6a596f6584d1da38f574ee3f78)

14 months agoMigrate users of Optional.get() 34/105334/6
Robert Varga [Sat, 8 Apr 2023 20:28:58 +0000 (22:28 +0200)]
Migrate users of Optional.get()

Optional.orElseThrow() has a more explicit name, preventing potential
confusion with Future.get() and making it clear there might be an
exception coming.

Also take the time to modernize code with local variable type inference,
instanceof patterns and similar.

Change-Id: Ifca580e0f6c652da270260dc126f79d7f32b9ff2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 months agoRefactor globalOrStatementSpecific() 20/105320/1
Robert Varga [Thu, 6 Apr 2023 21:42:52 +0000 (23:42 +0200)]
Refactor globalOrStatementSpecific()

Current implementation elicits a nullness warning, which is not quite
there -- at the cost of verifyNotNull().

If we refactor checks we can actually make it more performant and
transparent. This is advanteous bacause a null parent implies current is
a GLOBAL storage -- and we therefore can just check the storage type for
STATEMENT_LOCAL.

As it turns out we can refactor the loop to make it obvious, in that we
manually check parent storage. This makes the code flow nicer and more
transparent -- there are no IDE-invisible non-null guarantees. A null
parent storage indicates GLOBAL storage, hence we can bail.

A further boon is that we can simplify the StorageType check to only
compare to STATEMENT_LOCAL.

Change-Id: I5a5b7faf312db6de7f1cebe654f18e9785f58bac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6f866bb7c52a0ed2d4fb9bd4f590fd1a325fc50a)
(cherry picked from commit 3d28c233f9f2cd93b5ceadf1ab9ca2c480e4e801)

14 months agoFix bits/instance-identifier value serdes 07/104907/2
Robert Varga [Fri, 6 Jan 2023 15:30:27 +0000 (16:30 +0100)]
Fix bits/instance-identifier value serdes

Bits and instance-identifier values need to be recognized. Fix their
serialization and parsing and enable tests.

JIRA: YANGTOOLS-1473
Change-Id: If5b40d4642e4d8353e8dfad492166987fc3c536b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
(cherry picked from commit b0d52d88a50259a179b0f128ba9c5e39f4dd30e9)

14 months agoFix identity-ref value parsing/serialization 06/104906/2
Robert Varga [Fri, 6 Jan 2023 15:30:27 +0000 (16:30 +0100)]
Fix identity-ref value parsing/serialization

When encountering a QName value in a leaf, a leaf-list or implied as the
value of a key, we need to properly encode it. The same is true when
parsing, where we have to consult current namespace mapping.

As a side-effect of this, we are also fixing the case of a leaf-list
entry referenced in a path argument -- which is important for all
non-String types.

JIRA: YANGTOOLS-1473
Change-Id: Id50ebd9a3c0c1378f1af8451b86c66e323757eba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
(cherry picked from commit 7c8fd1ae5a6942fb3600ab9d05185cd4293f5f51)

14 months agoFix String value parsing/serialization 05/104905/2
Robert Varga [Fri, 6 Jan 2023 15:30:27 +0000 (16:30 +0100)]
Fix String value parsing/serialization

When encoding user-supplied values from user we need to be mindful of
their actual content: we cannot just use single quotes (') everywhere,
as the value itself can contain a single quote, in which case the
resulting string would have unbalanced quotes and nominally unparseable.

Adjust both sides of the serialization picture to account for this and
use YANG section 6.1.3 for escaping rules.

JIRA: YANGTOOLS-1473
Change-Id: I0df9beaf720a78682b6bde606a1359e7f1a09df8
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f31f6f001ec2263715ebfd5f28d214b56e9a0344)

14 months agoUpdate test suite 04/104904/2
Robert Varga [Tue, 14 Mar 2023 07:49:38 +0000 (08:49 +0100)]
Update test suite

Change I6226cc8ebe48acc03a62309efec2ab205549e0fb has a few deficiencies
in the models and test consistency. Improve the tests before we start
addressing the issues.

JIRA: YANGTOOLS-1473
Change-Id: Ie1f4e5fa99a8258abe09c005d352dd971a98c051
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3882dd90f1af909696a4e1ebad57aae1282cf956)

14 months agoModernize AbstractStringInstanceIdentifierCodec 03/104903/2
Robert Varga [Fri, 6 Jan 2023 15:08:11 +0000 (16:08 +0100)]
Modernize AbstractStringInstanceIdentifierCodec

Use instanceof patterns and local variable type inference.

Change-Id: I0b2bb0de72ab207ed01060cf3d6c76dbf5e450bd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1aa58ce7aca9f9e65e0fa3b5d9101af9945e38a5)

14 months agoImprove XmlCodecFactory a bit 02/104902/2
Robert Varga [Tue, 14 Mar 2023 12:37:00 +0000 (13:37 +0100)]
Improve XmlCodecFactory a bit

Remove an unneeded cast in test code by exposing the fact that
instanceIdentifierCodec() operates on YangInstanceIdentifier.

JIRA: YANGTOOLS-1473
Change-Id: Ib915a0b4c93674e1e266359070bb6b06da20094c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 90a498521a7ec3fd62ed91c2c0016ab334a93da2)

14 months agoTests for YangInstanceIdentifier key value serialization 01/104901/2
Robert Varga [Fri, 6 Jan 2023 14:24:24 +0000 (15:24 +0100)]
Tests for YangInstanceIdentifier key value serialization

There are a number of corner cases which we do not handle. This patch
adds @Ignored tests which hightlight basic serialization problems here.

JIRA: YANGTOOLS-1473
Change-Id: I6226cc8ebe48acc03a62309efec2ab205549e0fb
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6fca49a9a8daff89d5304c15d3e5c734dfa3da11)

14 months agoImprove JSONCodecFactory 11/104911/1
Robert Varga [Fri, 6 Jan 2023 13:38:44 +0000 (14:38 +0100)]
Improve JSONCodecFactory

Improve type safety for tests by returning a well-defined JSONCodec.

Change-Id: Id0ba808b03c3b035ad77d545dc4acdc60920188a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit fa2207496b5d7097863f6c1163c15091b48bd063)

14 months agoOptimize StmtContextUtils.isMandatoryNode() 00/104900/1
Robert Varga [Wed, 15 Mar 2023 17:50:22 +0000 (18:50 +0100)]
Optimize StmtContextUtils.isMandatoryNode()

Use instanceof pattern and a switch expression to remove an explicit
cast and make the implementation less verbose.

Change-Id: Ic4800aac65469565f4aead71a740f96aa3d126bf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit af5447de59826de9504b6b742a6fa7e1cf52a1cc)
(cherry picked from commit 24737704c2ae0b5f26df0891d36131c4ad7fa0ca)

14 months agoCheck requested schema tree statement namespace 91/104891/1
Sangwook Ha [Fri, 27 Jan 2023 22:24:14 +0000 (14:24 -0800)]
Check requested schema tree statement namespace

When we have a reactor when two children of an InferredStatementContext
differ only in namespace, we cannot blindly service
requestSchemaTreeChild().

Check whether the namespaces match, as we can only materialize
statements that match our targetModule.

JIRA: YANGTOOLS-1480
Change-Id: I4d9c6e6361fe2d5383e6de43e3c1bb54bac4e935
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a9bdd9337094457150a89f630dedd21d70177a90)

15 months agoMake AbstractContainerSchemaNode generic 00/104600/1
Robert Varga [Tue, 14 Mar 2023 20:02:50 +0000 (21:02 +0100)]
Make AbstractContainerSchemaNode generic

This is a private superclass shared by two subclasses, which each store
the same object in an additional field. Make the superclass generic,
eliminating a field.

Change-Id: I27552291dd1f2d9bae45ba883ae6d28f28e78870
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5c6018d7dd2063af57a6795cbafd41e877c34bed)
(cherry picked from commit 83a87e052a9a5c0ae54e857097836d512800d9c0)

15 months agoInline NamespaceStorageSupport.accessNamespaces() 61/104861/1
Robert Varga [Mon, 13 Mar 2023 18:26:21 +0000 (19:26 +0100)]
Inline NamespaceStorageSupport.accessNamespaces()

We have multiple callers, but all of duplicate the functionality
of getLocalNamespace(). Inline accessNamespaces() into
getLocalNamespace() and adjust users to use that instead duplicating its
code.

This removes a the need for a number of warning suppressions and makes
it clearer as to what is going on.

Change-Id: Ia210c6275b64093063eaf58a67412e94c3a29419
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 131816618ba0dd44880b58092fc062375f8d7389)

15 months agoUse an instanceof pattern 60/104860/1
Robert Varga [Mon, 13 Mar 2023 18:21:06 +0000 (19:21 +0100)]
Use an instanceof pattern

InferredStatementContext uses check-and-cast, which we can simplify for
Java 17.

Change-Id: I7bba54874bd19ff0de79d665879003c82b3e8cac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0b1fb0b77af5eecca184f6d390ff2c9af14457ba)

15 months agoUse local variable type inference a bit more 59/104859/1
Robert Varga [Mon, 13 Mar 2023 17:00:48 +0000 (18:00 +0100)]
Use local variable type inference a bit more

Reduce verbosity by using local variable type inference.

Change-Id: I8e02d0642b6e28052332a5f5dd5e9601442af8db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0bb9d758a7d7faabbc6cca057a166c997e1b5040)

15 months agoRemove a naked cast 58/104858/1
Robert Varga [Mon, 13 Mar 2023 17:00:07 +0000 (18:00 +0100)]
Remove a naked cast

We have a utility to perform a checked cast, use that instead to improve
defensiveness.

Change-Id: Id20c0690bc36ecd3eea0fc902c727d78450bdccd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e036e09b003ace450a0392405a56818921487e82)

15 months agoFix augment/deviate mechanics 49/104849/1
Sangwook Ha [Mon, 30 Jan 2023 21:50:33 +0000 (13:50 -0800)]
Fix augment/deviate mechanics

Parsing of YANG models with a deviation fails if the deviation target
node is conditionally augmented based on a feature.

The problem is we are reusing are reusing setUnsupported() for two
cases: when the feature is not supported and when the target is not
available.

Separate the second case into a separate boolean, and if the target is
available, propagate children to target as unsupported -- which makes
namespace resolution work correctly and deviate properly sees the
children as unsupported.

JIRA: YANGTOOLS-1485
Change-Id: I954185dd0067667faae8073e222f07b65907e675
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 46497a560b73b86f51936e3326881657e523185f)

15 months agoSimplify ModifierImpl.contextImpl() 48/104848/1
Robert Varga [Mon, 13 Mar 2023 15:04:36 +0000 (16:04 +0100)]
Simplify ModifierImpl.contextImpl()

Use an instanceof pattern to make the check we are making more
transparent.

Change-Id: If6d92be744e1e063f96feb7428c09c4984cf2c9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a83dfa8d5ff23238f182283945d868ab52a13035)

15 months agoRemove getLocalName() invocation 80/104780/1
Robert Varga [Mon, 6 Mar 2023 14:50:56 +0000 (15:50 +0100)]
Remove getLocalName() invocation

We can easily refer to localName field, do just that.

Change-Id: I0b51e77c1b5e2fe61b3190bc661541682dec8e4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit aa1b05c3a2ab1f1088cd895df97d844203a42a98)

15 months agoClean up AbstractMagnesiumDataInput 67/104167/1
Robert Varga [Wed, 22 Feb 2023 14:47:10 +0000 (15:47 +0100)]
Clean up AbstractMagnesiumDataInput

Use switch expression for dispatch and annotate @NonNull returns.

Change-Id: I263cd4be713a58b528576c8df4f3520585e16951
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 49b83c2e5ce7f70faf357ac414309a594dd691f2)

15 months agoRemove duplicate findCorrespondingAugment() 72/104472/1
Robert Varga [Tue, 21 Feb 2023 14:53:48 +0000 (15:53 +0100)]
Remove duplicate findCorrespondingAugment()

We already have a version of this method in a public place, reuse it
from there.

Change-Id: I5ec6d4004a41d7813ae345730eff154ce3304d45
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9164338f3131a48f053fae3941829bfc18da98ea)

15 months agoUse instanceof patterns in CompositeNodeDataWithSchema 71/104471/1
Robert Varga [Tue, 21 Feb 2023 14:50:16 +0000 (15:50 +0100)]
Use instanceof patterns in CompositeNodeDataWithSchema

Reduce the number of explicit casts.

Change-Id: Idd89ac1e59eb479b6b7ed837ff2a665b49b183f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6566c6bca77698bc09e31a01b73b1707b14e86b9)

15 months agoUse instanceof pattern in DataContainerContextNode 70/104470/1
Robert Varga [Tue, 21 Feb 2023 14:47:57 +0000 (15:47 +0100)]
Use instanceof pattern in DataContainerContextNode

Check-and-assign to eliminate a cast.

Change-Id: I4385e7f7499e64dbb90822c1dff5d1995b182dd5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e8a6fbd2fd742bf1e3761ca2a0bc096fa7474b1b)

15 months agoClean up NormalizedNodeSchemaUtils 69/104469/1
Robert Varga [Tue, 21 Feb 2023 14:44:38 +0000 (15:44 +0100)]
Clean up NormalizedNodeSchemaUtils

Use instanceof pattern to simplify casts. Also simplify
findCorrespondingAugment(), making the logic more obvious.

Change-Id: I7f134d333aa2543169acdf30a5e4e116bb7ca22e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f4f7172940fcb54a351f6d9fba9293ebc82b0d4f)

15 months agoUse instanceof patterns in DataSchemaContextNode 68/104468/1
Robert Varga [Tue, 21 Feb 2023 14:46:58 +0000 (15:46 +0100)]
Use instanceof patterns in DataSchemaContextNode

Reduce the number of casts by using an instanceof pattern.

Change-Id: Ia9f4a26143d5d19b339bae2d74af0c7572d99e2f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 722154b4a6d7cfa080f1f3d0db291bca212b383e)

15 months agoFix anyData content normalization incl no data case 52/104452/2
Ruslan Kashapov [Tue, 10 Jan 2023 08:25:30 +0000 (10:25 +0200)]
Fix anyData content normalization incl no data case

Parsing of anydata content is now performed with inference
pointing to anydata node itself as a root (parentNode),
not first child. This allows proper normalization of any
anydata content incl empty case.

List/leaf-list element parsing logic was updated to detach
schema node value check as a condition bc top level node
identifiers are not matching when anydata content is parsed.
Local name and namespace match is used instead.

JIRA: YANGTOOLS-1011
Change-Id: I09ae84c44ada198b888d901dff0425b29400fb4f
Signed-off-by: Anna Bencurova <Anna.Bencurova@pantheon.tech>
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
(cherry picked from commit 68e5e4f9d8261ef5e6fd9fcf62cd84c45b8a7739)

15 months agoOptimize ModifierImpl.AbstractPrerequisite 88/104388/1
Robert Varga [Tue, 14 Feb 2023 10:17:31 +0000 (11:17 +0100)]
Optimize ModifierImpl.AbstractPrerequisite

Object analysis shows we are recording outer class multiple times,
leading to suboptimimal object layout. Make the class hierarchy static,
with outer class recorded in explicit field, reducing
size of PhaseModificationInNamespacePath from 40-80 (48 typical) bytes
to 32-64 (40 typical) bytes. Other subclasses observe a similar
reduction.

JIRA: YANGTOOLS-1486
Change-Id: Ifc3da86a564bc54f4247996e622787a8528422b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 007dd4ccf28dd4288bafbce38a00c2b8d3ec2a68)

15 months agoUse a switch expression to get validator 87/104387/1
Robert Varga [Tue, 14 Feb 2023 09:45:28 +0000 (10:45 +0100)]
Use a switch expression to get validator

We are looking at an enumeration, hence we can use switch expression
exhaustiveness to eliminate an ISE.

Change-Id: Iebfd1b7f8d5ea19a5c7508c5f1a4f3d69074ab84
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 444398f5b137cb9f8f12cd451f7e3059260e8611)

15 months agoDo do not check unique in unsupported lists 82/104382/1
Sangwook Ha [Mon, 30 Jan 2023 21:50:33 +0000 (13:50 -0800)]
Do do not check unique in unsupported lists

Parsing of YANG models fails if a list conditional on a feature has a
unique statement and the feature is not supported.

Add test cases to reproduce the issue and fix
RequireEffectiveList.isApplicable() to also check for
isSupportedByFeatures().

JIRA: YANGTOOLS-1481
Change-Id: Id73f3f36fc5300e4c9fe97c32a25e58ab75078e4
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a94cb0f875a6b56360f64a6ba49d209a3dddd1ee)

16 months agoDo not access size indirect through body() 51/104151/1
Robert Varga [Tue, 24 Jan 2023 13:32:43 +0000 (14:32 +0100)]
Do not access size indirect through body()

This seems to be more efficient, but needs to be evaluated.

Change-Id: Ia8ddc618b7b98a82ad51d97c349d035793386562
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 63dd7f36f6f23ce6e35cd0027ea042147fec641c)

16 months agoFix ReactorStmtCtx.calculateParentRefcount() 89/104189/1
Sangwook Ha [Wed, 4 Jan 2023 04:12:51 +0000 (20:12 -0800)]
Fix ReactorStmtCtx.calculateParentRefcount()

If we have an empty grouping, which is referenced via augment-uses to a
different module, then if that module is buildEffective()'d first, we
end up with the grouping being swept.

This turns out to be a bug in parentRef determination -- in this
particular case we observe parent being REFCOUNT_NONE and invoke it
recursively -- and since the parent is a module, it itself does not have
a parentRef. This leads to us thinking the grouping does not have a
parentRef, whereas it does.

Update calculateParentRefcount() to recognize parent.refCount == 0 as
parent holding us down.

The problem manifests itself in the test when the models are processed
in order foo.yang, bar.yang -- but not when bar.yang is processed before
foo.yang.

Unfortunately the order of processing is not predictable in
BuildGlobalContext, hence we repeat the test 4 times.

JIRA: YANGTOOLS-1474
Change-Id: Ib3d55fb92d5a6d34230722ab1cd39e8f8831b6fe
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ad55ca2b2e72f15d7963cfcb011e4f7610889fce)

16 months agoSplit calculateParentRefcount() 88/104188/1
Robert Varga [Mon, 30 Jan 2023 10:01:54 +0000 (11:01 +0100)]
Split calculateParentRefcount()

The real meat of the method operates solely on parent, so split it off
into a dedicated method.

Change-Id: I9e3b8a19d4031372669c454bcbd3fbd5ceb29e07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f1eab654288b106cf7ddb956aa37fb63d446b1b0)

17 months agoAllow unqualified node-identifiers in instance-identifier 53/103953/1
Ruslan Kashapov [Mon, 24 Oct 2022 13:04:41 +0000 (16:04 +0300)]
Allow unqualified node-identifiers in instance-identifier

node-identifier has an optional prefix, make sure we reflect this in our
class design.

JIRA: YANGTOOLS-1361
Change-Id: I928eabf5d2508d9be1390f7662998829cb06af81
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 173787948ff24c4098602e351fb097a55a4ffd85)

17 months agoCorrect instance-identifier escaping 52/103952/1
Robert Varga [Tue, 3 Jan 2023 15:39:04 +0000 (16:39 +0100)]
Correct instance-identifier escaping

Dealing with single-quoted and double-quoted strings in
instance-identifier differs quite a bit. In order to deal with these
strings, we need to differentiate them in lexer, for which we create
separate modes.

This forces us to explicitly define lexer lokens and only match raw
strings in their mode -- ensuring there are no surprises.

JIRA: YANGTOOLS-1458
Change-Id: I3f58c10f068da1128d8a7c1c5bed3917bfea0c78
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 45e8951a576c6bf2cb2bd0290167619b8be2fc5a)

17 months agoForce instanceIdentifier to consume all input 51/103951/1
Robert Varga [Tue, 3 Jan 2023 19:25:10 +0000 (20:25 +0100)]
Force instanceIdentifier to consume all input

We need ANTLR to completely process the input string, hence force an EOF
token in instanceIdentifier.

JIRA: YANGTOOLS-1361
Change-Id: I80f1b326a47857e4e8f36c568901d19f771cef96
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 9eda34f44f1fc1027c357ad02923484e16b6ac0c)

17 months agoFix InstanceIdentifierParser's lexer 50/103950/1
Robert Varga [Tue, 3 Jan 2023 19:21:08 +0000 (20:21 +0100)]
Fix InstanceIdentifierParser's lexer

We have a day-0 bug here: we are using xpathLexer instead of
instanceIdentifierLexer.

JIRA: YANGTOOLS-1361
Change-Id: Ic4c074577c8a6fce9fbc22ef5da8e54b5df75faa
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 8175666c67304af22cda102db8a183784b659799)

17 months agoGuarantee LocationPath.Absolute from implementation 49/103949/1
Robert Varga [Tue, 3 Jan 2023 18:14:52 +0000 (19:14 +0100)]
Guarantee LocationPath.Absolute from implementation

This makes it more type-safe to operate on tests etc.

Change-Id: Ib325c31092519e0644f02608cbca55e3dbca81b6
Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 53407d16787eeef7e59dab3199cfa16447d653a0)

17 months agoModernize XPathParserTest 48/103948/1
Robert Varga [Tue, 3 Jan 2023 17:27:31 +0000 (18:27 +0100)]
Modernize XPathParserTest

Use variable type inference and simplify test w.r.t. use in JUnit 5.
Ditches use of Hamcrest as well.

Change-Id: I209480067e4c22ac903086ce05e50d72a7517c73
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 271b91470354f7decb14811cddd0491b9baa48a8)

17 months agoModernize ParseTreeUtils 47/103947/1
Robert Varga [Tue, 3 Jan 2023 15:53:48 +0000 (16:53 +0100)]
Modernize ParseTreeUtils

Use instanceof patterns, local variable type inference and
String.formatted().

Change-Id: I759bb20d8f73100d0b555cf50cdd8f8405334388
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f1f369cc314053498972f83aaee226f1fe88959a)

17 months agoModernize InstanceIdentifierParser 46/103946/1
Robert Varga [Tue, 3 Jan 2023 15:33:19 +0000 (16:33 +0100)]
Modernize InstanceIdentifierParser

Use switch expressions, instanceof pattern and local variable type
inference.

Change-Id: I609a17afc5915ae340b8ee0bc9fe7a2f74fa8ac1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit a8b25dbe1b83518844ba8a1c3d5fe970400b7f16)

17 months agoBump versions to 9.0.7-SNAPSHOT 50/103850/1
Robert Varga [Sun, 1 Jan 2023 11:56:35 +0000 (12:56 +0100)]
Bump versions to 9.0.7-SNAPSHOT

This starts the next development iteration.

Change-Id: Ic5853e675a09792f1330b79f0a43e7d6ca720ba7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 months agoBump odlparent to 11.0.4 45/103845/1
Robert Varga [Sat, 31 Dec 2022 18:02:57 +0000 (19:02 +0100)]
Bump odlparent to 11.0.4

Adopt updates from upstream.

Change-Id: Ieea5cf06caaec869a374e191f7de1c554510a636
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
17 months agoImprove Descendant check 38/103738/1
Robert Varga [Wed, 21 Dec 2022 23:00:56 +0000 (00:00 +0100)]
Improve Descendant check

Rather than asserting Absolute, use an explicit if with instanceof
expression to guard list additions. Also retain declaration order
by not going through an intermediate HashSet.

Change-Id: I0292aa8f927a101de83979da808cf84032bfb021
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit e3d8fe2ba1ab33920596f1dd3140e7ac4bf6e75f)

17 months agoDo not suppress 'uses' node effects 34/103734/1
Sangwook Ha [Sun, 4 Dec 2022 06:00:47 +0000 (22:00 -0800)]
Do not suppress 'uses' node effects

Parser tries to process an 'augment' statement with 'if-feature' and
fails when the feature is not supported and the 'augment' statement
targets a node defined with a nested grouping and dependent on the
feature.

Add a test case (4th one) to reproduce the issue. The other test cases
show that there is no parsing issue if the augmentation target node is
defined with a single grouping or feature is supported.

The problem here is not AugmentStatementSupport, but rather
UsesStatementSupport, which fails to propagate children when if-feature
is in effect -- hence those children never make it to the schema tree,
and hence fail to be looked up.

Use 'uses' statement's if-feature to mark any children as unsupporte,
hence they are reflected in namespaces, but they will not be built.

JIRA: YANGTOOLS-1471
Change-Id: Ibd86530388a99ed3c8ade7bf9af109c6a0cfb80a
Signed-off-by: Sangwook Ha <sangwook.ha@verizon.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4ad4e83aa9150c6c32af1e04fc879e844edae5cd)