yangtools.git
2 years agoBump versions to 5.0.11-SNAPSHOT 30/96230/1 5.0.x
Robert Varga [Tue, 18 May 2021 04:23:01 +0000 (06:23 +0200)]
Bump versions to 5.0.11-SNAPSHOT

This starts the next development iteration.

Change-Id: Ifd561f585589de2a9664fa2b03991ec2c39bd2f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoBump odlparent to 7.0.10 26/96226/2
Robert Varga [Mon, 17 May 2021 21:00:32 +0000 (23:00 +0200)]
Bump odlparent to 7.0.10

Pick up latest upgrades from upstream.

Change-Id: Icf693e7146ace8278eba796464ef32f447f0feed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
2 years agoTransform QName value in identity leaf 95/95895/1
Ivan Hrasko [Thu, 22 Apr 2021 16:29:02 +0000 (18:29 +0200)]
Transform QName value in identity leaf

Leafs with identityref point to the identity's QName. Since we are
remapping namespaces, these need to be included as well.

JIRA: YANGTOOLS-1277
Change-Id: I2885dd59bcdd85cfe4f29edceaf68cb27ed7dca7
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 7042ef1344f1c38b730132e5bcb12592fcd9e9b0)

2 years agoDo not subclass YangTextSchemaSource in yang-parser-impl 73/95873/1
Robert Varga [Wed, 21 Apr 2021 05:47:24 +0000 (07:47 +0200)]
Do not subclass YangTextSchemaSource in yang-parser-impl

We have a readily-available URL-based implementation, reuse it instead
of rolling our own.

JIRA: YANGTOOLS-1275
Change-Id: I43a6215e8dbe678966c80d3d05dde5a44c8e7833
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3310cd312a6419064b7a2850865e434970ba5a67)

2 years agoDo not subclass YangTextSchemaSource in yang-repo-fs 72/95872/1
Robert Varga [Wed, 21 Apr 2021 05:36:22 +0000 (07:36 +0200)]
Do not subclass YangTextSchemaSource in yang-repo-fs

We have a readily-available File-based implementation, reuse it instead
of rolling our own.

JIRA: YANGTOOLS-1275
Change-Id: I0a6604b83cb1aa216e61f5f5be97f93d2d1dd0e4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d23aa17bf81deed1dc7208d00bd15400954edf9c)

2 years agoForward symbolic source in YinDomSchemaSource 67/95867/1
Robert Varga [Tue, 20 Apr 2021 20:47:43 +0000 (22:47 +0200)]
Forward symbolic source in YinDomSchemaSource

When we are transforming a source, we should also be forwarding symbolic
name requests.

JIRA: YANGTOOLS-1275
Change-Id: I0aa0420aee4c51d9c006f28b3e669eabc89c1787
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 738badcf0d51117f00d1ee585e546eeb454e22cc)

2 years agoExpose symbolic name in YangTextSchemaContextResolver 66/95866/1
Robert Varga [Tue, 20 Apr 2021 20:41:47 +0000 (22:41 +0200)]
Expose symbolic name in YangTextSchemaContextResolver

We have a perfectly reasonable symbolic name available here, make sure
we propagate it, aiding debugging.

JIRA: YANGTOOLS-1275
Change-Id: I60162a10da9356896cea5cb5abc2a233dea38c12
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 824faeb0e75906de57ca1d90a39f4cc86334933c)

2 years agoPropagate symbolic name through transformations 65/95865/1
Robert Varga [Tue, 20 Apr 2021 20:31:59 +0000 (22:31 +0200)]
Propagate symbolic name through transformations

Transformation to IRSchemaSource ends up losing source symbolic name,
leading to anonymous sources. Make sure we propagate any source
symbolic name.

JIRA: YANGTOOLS-1275
Change-Id: I219d4bffa66c1262683db1b6af886a052c644cde
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0e5d5323491caa4308d582bdb3d941c214146a22)

2 years agoImprove ImmutableAugmentationNodeBuilder defensiveness 64/95864/1
Robert Varga [Mon, 19 Apr 2021 19:41:10 +0000 (21:41 +0200)]
Improve ImmutableAugmentationNodeBuilder defensiveness

The check for nested augmentations is rather ugly and will trigger
a secondary UnsupportedOperationException -- simply because we are
accessing getNodeType() even for AugmentationNodes.

Fix the thinko by performing an explicit check first, which also makes
things a wee bit faster.

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

3 years agoBump versions to 5.0.10-SNAPSHOT 90/95390/1
Robert Varga [Mon, 1 Mar 2021 09:31:56 +0000 (10:31 +0100)]
Bump versions to 5.0.10-SNAPSHOT

This starts the next development iteration.

Change-Id: Ic905f51ff05fe0c836e5b113b257e4fddac0e9cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRestore unrecognized statement defensiveness 62/95362/3
Samuel Kontris [Thu, 25 Feb 2021 18:09:20 +0000 (19:09 +0100)]
Restore unrecognized statement defensiveness

We are in a bad place here, as we are trying to come up with
something that passes for a QName based on zero understanding
of argument structure.

Previous cleanup of the logic here, done in YANGTOOLS-1191
omitted a possible source of errors -- when the value contains
something resembling a qualified node identier to the point
of actually resolving to a module -- but the localname part
is not actually valid.

Fix this by going through UnqualifiedQName.tryCreate(), just
as we do in the unqualified case.

The test model is a simplified version of tailf yang models
(specifically "tailf-ncs-devices@2020-02-04.yang" model), where
the argument structure is actually a descendant schema node
identifier.

JIRA: YANGTOOLS-1261
Change-Id: I885828221382f5689b491f26161b35987dfd4482
Signed-off-by: Samuel Kontris <samuel.kontris@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 99d0a43d0f67ab0b98d56ac4a5b51cb7b1f76e80)

3 years agoDo not synchronize around ReactorStmtCtx.schemaPath 47/95347/1
Robert Varga [Mon, 1 Feb 2021 20:06:02 +0000 (21:06 +0100)]
Do not synchronize around ReactorStmtCtx.schemaPath

The reactor is inherently single-threaded, hence there is no point
in guarding this single field. Remove synchronization and add a few
markes for future improvement.

JIRA: YANGTOOLS-1218
Change-Id: Ic5017bb589ae5086bf8310995d7c03c80e12678a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0735f709c996762a2ac65338459c465bffc4dbcf)
(cherry picked from commit 7f41bd0651d810544aa1359ce1d762a8185df016)

3 years agoUn-deprecate CopyableNode, AddedByUsesAware 45/95345/1
Robert Varga [Tue, 16 Feb 2021 15:15:34 +0000 (16:15 +0100)]
Un-deprecate CopyableNode, AddedByUsesAware

These traits seem to provide a useful inference summary, related to
DerivableSchemaNode. Un-deprecate them for now to reduce noise for
valid uses which have no alternative.

Also add FIXMEs to reconsider overall design of these interfaces,
as better semantic integration allows for more consistent use.

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

3 years agoFix StringStringCodec length check 42/95342/1
Robert Varga [Wed, 24 Feb 2021 08:47:30 +0000 (09:47 +0100)]
Fix StringStringCodec length check

RFC7950 specifies that string length is counted in unicode
characters. String.length() returns the length in code units of
UTF-16, which are not the same thing.

Use String.codePointCount() to get correct results for strings
containing characters from outside of Unicode BMP.

JIRA: YANGTOOLS-1224
Change-Id: I6ff9557d61449625be975eaca00ad235bf429155
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cbadacd601e11552b749edfaaa19b64b9804e55f)
(cherry picked from commit 232f92df65f4c5dbc87102bf5300cfbcaf01ead7)

3 years agoMake CopyHistory implement CopyableNode 49/94849/1
Robert Varga [Wed, 27 Jan 2021 10:06:52 +0000 (11:06 +0100)]
Make CopyHistory implement CopyableNode

We have a few call sites checking the same thing. Make a strong
connection between CopyableNode and CopyHistory -- centralizing
checks and providing an opportunity for optimization.

CopyHistory.contains() now exists only for testing purposes.

JIRA: YANGTOOLS-1215
Change-Id: Ibc9cebe4bee6c5818570c52415c3d8a5ba1ff19d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 62c350eff478deeaa90ab0304cdc9c3623c01c83)
(cherry picked from commit 712c3ae6a666023f8febb1c7eb7c72ede2e31022)

3 years agoBump versions to 5.0.9-SNAPSHOT 72/94472/1
Robert Varga [Thu, 7 Jan 2021 13:55:58 +0000 (14:55 +0100)]
Bump versions to 5.0.9-SNAPSHOT

This starts the next development iteration.

Change-Id: I26584a1c31709b881056b0d6e07b976e6b780c9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 7.0.8 71/94471/1
Robert Varga [Thu, 7 Jan 2021 13:41:07 +0000 (14:41 +0100)]
Bump odlparent to 7.0.8

Pick up latest upgrades from upstream.

Change-Id: Idd93b702241b22905ed67d6e9c8d1105e7ccc37c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd ByteBufUtils.writeUint{8,16,32,64} 63/94463/1
Robert Varga [Mon, 4 Jan 2021 13:32:29 +0000 (14:32 +0100)]
Add ByteBufUtils.writeUint{8,16,32,64}

Plain ByteBufUtils.write() methods are hiding the width argument,
hence can potentially break binary encodings on type change.

Add explicit methods, so that the intent is documented and actually
breaks when incorrect type is applied.

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

3 years agoMake sure SmtmtNamespaceContext uses belongs-to prefix 59/94159/2
Robert Varga [Thu, 10 Dec 2020 11:48:16 +0000 (12:48 +0100)]
Make sure SmtmtNamespaceContext uses belongs-to prefix

For xpath parsing we nee to make sure we take into account the
prefix under which 'belongs-to' module is known to the submodule.

JIRA: YANGTOOLS-1201
Change-Id: Id38d76443d23eecef09f1f927c44218363a3a1d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit bb9c8c8751e338d2e683063144d1d5810b22eee7)
(cherry picked from commit 62e56229ba32a8ed6a14b4d0a6d6b1c85f442ec8)

3 years agoUse correct key-arg splitting 26/94126/1
Robert Varga [Tue, 8 Dec 2020 21:27:30 +0000 (22:27 +0100)]
Use correct key-arg splitting

The splitter we have operates on spaces and trims results to get
rid of whitespace -- probably as a consequence of us historically
having bugs there.

We currently break if someone uses double-quoted whitespace trimming,
as we do not treat '\n' as a separator and then attempt to interpret
it as a node-identifier.

Add an explicit SEP equivalent CharMatcher and use a Splitter on that,
resulting in '\t' and '\n' being correctly trimmed.

JIRA: YANGTOOLS-1200
Change-Id: Ifa3085fffcbbe24204e9d6c0d86ed8c41bd61065
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5fe0d9e2a63cc9cf3be8c39f32305cf9e2a8be4e)

3 years agoAdd UnqualifiedQName.tryCreate() 83/94083/1
Robert Varga [Sun, 6 Dec 2020 12:37:39 +0000 (13:37 +0100)]
Add UnqualifiedQName.tryCreate()

This a better approach to performing a lazy check, as it captures
the valid string in a well-known construct.

JIRA: YANGTOOLS-1191
Change-Id: I7ffe00602d3d83189d9c3f8a59365648aa36720d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c7e8081901536d97a12b141cbb538f70c7a93d61)

3 years agoDo not use exceptions for branching 82/94082/1
Robert Varga [Mon, 30 Nov 2020 16:30:24 +0000 (17:30 +0100)]
Do not use exceptions for branching

UnrecognizedEffectiveStatementImpl is mis-using
StmtContextUtils.qnameFromArgument() to attempt to create a QName,
suppressing reported exceptions.

Use a custom-tailored lookup, which utilizes
AbstractQName.isValidLocalName() and thus side-steps exceptions.

JIRA: YANGTOOLS-1191
Change-Id: Iecea9f446730e4e7840b962a95844ce5128dfb9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1bbcdd2d6510d420b916c26f54c60a1c2e1607df)
(cherry picked from commit 80b2a1b0f1fd86816047487fc97e1da5f3188ea4)

3 years agoFix YangModeledAnyxmlEffectiveStatementImpl.isMandatory() 48/94048/1
Robert Varga [Fri, 4 Dec 2020 13:27:21 +0000 (14:27 +0100)]
Fix YangModeledAnyxmlEffectiveStatementImpl.isMandatory()

We have a bug in forwarding here, fix that.

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

3 years agoFire AbstractPrerequisite listeners as soon as they resolve 92/93992/1
Robert Varga [Tue, 1 Dec 2020 13:42:15 +0000 (14:42 +0100)]
Fire AbstractPrerequisite listeners as soon as they resolve

We seem to be stuck with listeners not firing, leaving references
which need to be cleared. Ensure we fire phase listeners as soon
as they are satisfied -- repurposing tryApply() for its logical
purpose.

JIRA: YANGTOOLS-1192
Change-Id: I87d1700e2cc80bfa3fbb5be9a8dc938d6fe55c17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d70f2e9f13755ea7c3aac1f0c8d8a6b0b0861368)

3 years agoEliminate AbstractEffectiveModule.schemaTreeNamespace 60/93960/1
Robert Varga [Fri, 27 Nov 2020 10:29:19 +0000 (11:29 +0100)]
Eliminate AbstractEffectiveModule.schemaTreeNamespace

We already have DefaultWithDataTree.WithSubstatements's indices,
hence there is no point in re-doing the same work.
Eliminate duplication and defer to our superclass.

JIRA: YANGTOOLS-1188
Change-Id: I9fd775be737ef603be7ae2a914dda2c2d87bf8a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit d8119ea5b4ead35fc3dfad489e80e49a034226f6)

3 years agoSpeed up StmtContextUtils.getModuleQNameByPrefix() 27/93927/1
Robert Varga [Wed, 25 Nov 2020 02:34:26 +0000 (03:34 +0100)]
Speed up StmtContextUtils.getModuleQNameByPrefix()

We are looking up root twice here. Cache the lookup for reuse,
skipping one traversal.

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

3 years agoCorrect NonNull annotation 60/93660/1
Robert Varga [Wed, 18 Nov 2020 11:24:25 +0000 (12:24 +0100)]
Correct NonNull annotation

We are using the wrong annotation here, fix that.

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

3 years agoGraduate ChildSchemaNodeNamespace as SchemaTreeNamespace 93/93793/1
Robert Varga [Thu, 5 Nov 2020 16:16:01 +0000 (17:16 +0100)]
Graduate ChildSchemaNodeNamespace as SchemaTreeNamespace

This is a @Beta construct in yang-parser-rfc7950, but it provides
a crucial link between statements and namespaces.

In terms of semantic change, this is a direct replacement for the SPI
idea that there is a SchemaNodeIdentifierNamespace. While that namespace
allowed lookup based on SchemaNodeIdentifier, while
SchemaTreeNamespace follows QName addressing -- i.e. we are changing
the addressing mode and allowing more flexible walks.

This is a strictly speaking API-breaking change, but since it enables
reactor/parser-rfc7950 interactions and is allowed under @Beta API
change rules, we will backport this to otherwise stable branches.

Existence of this namespace allows us to neatly tie it with
OnDemandSchemaTreeStorageNode.

JIRA: YANGTOOLS-1168
Change-Id: I9b1c30d21f7021d4c21f3e5a519f6cd1539871ad
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 6682a8e2a8c02ed7a66bddb8b7a86009ffbbb98d)

3 years agoRemove unused SourceSpecificContext methods 24/93524/1
Robert Varga [Thu, 5 Nov 2020 16:42:29 +0000 (17:42 +0100)]
Remove unused SourceSpecificContext methods

These package-private methods are not used, remove them.

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

3 years agoFix PhaseModificationInNamespacePath effects 10/93610/1
Robert Varga [Thu, 5 Nov 2020 11:53:04 +0000 (12:53 +0100)]
Fix PhaseModificationInNamespacePath effects

PhaseModificationInNamespacePath is a set of requirements, working
along the parent->child axis. As we are resolving individual steps
we have to mark each as being impacted by this mutation, not only
the ultimate target.

This ensures that parent statements are not allowed to complete
until the mutation is resolved one way or another -- thus ensuring
proper parent/child phase completion transitions.

JIRA: YANGTOOLS-1160
Change-Id: I87cd682d32cb9ce3397883f2ac1a61a0bc9c8664
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ac66e993b3b7b00a70feae6fcc7c0c6fbf45cfe6)

3 years agoFix transitive if-feature augments 78/93578/1
Robert Varga [Fri, 9 Mar 2018 00:05:41 +0000 (01:05 +0100)]
Fix transitive if-feature augments

We cannot just ignore augments, as they drive namespace population.
Instead of that, let's populate target nodes, but make sure they
are marked as unsupported.

This allows ChildSchemaNodeNamespace-driven lookups to find the resulting
node, but does not allow it to materialize as an EffectiveStatement.

JIRA: YANGTOOLS-859
Change-Id: Ib817e6e20563005427471098bf6ff2991fb60e01
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit fdfe9c4914bf8a9f9a92cd1ab390e1f17a89b2ce)

3 years agoUse StmtContext.findSubstatementArgument() for isConfiguration() 56/93556/1
miroslav.kovac [Fri, 30 Oct 2020 16:29:28 +0000 (17:29 +0100)]
Use StmtContext.findSubstatementArgument() for isConfiguration()

We are only interested in having the appropriate argument, hence
we can use provided utility to not force the StmtContext to be
materialized.

JIRA: YANGTOOLS-1156
Change-Id: Idf292794225792afd8df1019c9106362a94ed5a4
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4929fb6d63325fcbcbd72c16758a44ba19c3d20d)

3 years agoFix StmtContext.findSubstatementArgument()/hasSubstatement() 55/93555/1
Robert Varga [Mon, 2 Nov 2020 15:37:49 +0000 (16:37 +0100)]
Fix StmtContext.findSubstatementArgument()/hasSubstatement()

When we are searching for a substatement we should also mind that
it can have its effective statement built. If we do not, we can end
up picking a statement which has been disabled by deviate.

Change-Id: I27743b5acbb2f617497d329423b239f363c54258
JIRA: YANGTOOLS-1157
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit b049955b52bcdf654e7b27530105745b0ca77ac0)

3 years agoAdd LazyCollections.lazyAdd for Sets 14/93514/1
Illia [Mon, 26 Oct 2020 16:15:39 +0000 (18:15 +0200)]
Add LazyCollections.lazyAdd for Sets

This will be used for GenerateType field, which is set of specified
getters.

JIRA: MDSAL-426
Change-Id: I691aa13c88147828890e0639441f607515053af8
Signed-off-by: Illia <illia.ihushev@pantheon.tech>
(cherry picked from commit 7caf3d717451ea9a98b19ab58e175281b5029055)

3 years agoRemove check for when being copied 37/93537/1
Robert Varga [Sat, 31 Oct 2020 11:06:21 +0000 (12:06 +0100)]
Remove check for when being copied

We have 'when' explicitly excluded, hence we can never observe
it in validation. Eliminate this dead code.

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

3 years agoAdd StmtContext.findFirstSubstatementArgument() 28/93528/2
miroslav.kovac [Fri, 30 Oct 2020 11:36:14 +0000 (12:36 +0100)]
Add StmtContext.findFirstSubstatementArgument()

Introduce utility methods to StmtContext, so that individual
implementations can provide optimized version, which does not
walk all children.

InferredStatementContext used this facility to defer to protype,
side-stepping the need to materialize substatements.

JIRA: YANGTOOLS-1157
Change-Id: I9e618d3a51f68ed03a76c718b657be38e5cedb5d
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c31a90ed7c04bc622c9404a4a6ef4a39b1b8648d)

3 years agoDefer substatement initialization in InferredStatementContext 27/93527/2
Robert Varga [Sat, 22 Aug 2020 18:27:23 +0000 (20:27 +0200)]
Defer substatement initialization in InferredStatementContext

InferredStatementContext is initializing its substatements rather
eagerly in its constructor. We now have all the tools we need to
defer this instantiation until the substatements are really needed.

JIRA: YANGTOOLS-784
Change-Id: Iafc23c22b15efdf46fde3adfc210c246e8d086bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3f3df266fb8ba0b06ffb6492766e8f49b167b05d)

3 years agoAdd OnDemandSchemaTreeStorageNode 30/93530/1
Robert Varga [Thu, 29 Oct 2020 11:55:55 +0000 (12:55 +0100)]
Add OnDemandSchemaTreeStorageNode

In order to correctly implement schema dependencies, we need to
invoke a callback from namespace prerequisites back to
StatementContextBase and its subclasses.

The conduit here is NamespaceBehavior.getFrom(), which is invoked
with a namespace key. For ChildSchemaNodeNamespace this ends up
the QName matching the argument the corresponding
SchemaTreeEffectiveStatement will end up having.

Introduce OnDemandSchemaTreeStorageNode, which acts as an extension
to normal NamespaceStorageNode behavior -- it allows an
implementation to supply a QName-based child statement to be
returned.

Since StatementContextBase is a NamespaceStorageNode, its subclasses
can now additionally implement this interface to receive the
callback.

JIRA: YANGTOOLS-784
Change-Id: I0e6f621eb39b341af61005b2334174e814c18875
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 5be3107a8f7daca1e3584bace9a684e21315df70)

3 years agoClarify NamespaceStorageSupport.getParentNamespaceStorage() 90/93490/1
Robert Varga [Fri, 30 Oct 2020 09:08:51 +0000 (10:08 +0100)]
Clarify NamespaceStorageSupport.getParentNamespaceStorage()

This override does seemingly nothing, but in fact splits invocation
groups to two -- those going to SourceSpecificContext and those
going to a NamespaceStorageSupport subclass. More specifically, if
a caller knows it is talking to NamespaceStorageSupport, JIT does
will not consider SourceSpecificContext an implementation.

Furthermore, SourceSpecificContext, as an implementation class,
guarantees it will return BuildGlobalContext.

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

3 years agoTighten {Inferred,Substatement}Context.getParentNamespaceStorage() 89/93489/1
Robert Varga [Fri, 30 Oct 2020 09:33:02 +0000 (10:33 +0100)]
Tighten {Inferred,Substatement}Context.getParentNamespaceStorage()

These two methods are guaranteed to return StatementContextBase,
express that in their return type.

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

3 years agoBuildGlobalContext should be final 88/93488/1
Robert Varga [Fri, 30 Oct 2020 08:58:24 +0000 (09:58 +0100)]
BuildGlobalContext should be final

We do not inherit from this class by design, make sure that bit
is captured for JIT to see.

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

3 years agoStorageSpecific.storageType is private and final 87/93487/1
Robert Varga [Fri, 30 Oct 2020 08:10:24 +0000 (09:10 +0100)]
StorageSpecific.storageType is private and final

Somehow this field escaped our usual attention, make sure it's
properly final and private.

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

3 years agoUse coerceStatemntArgument for YinElementStatement 86/93486/1
Robert Varga [Fri, 30 Oct 2020 01:25:28 +0000 (02:25 +0100)]
Use coerceStatemntArgument for YinElementStatement

yin-element requires an argument, it is fair to coerce it and get
rid of a nullness warning.

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

3 years agoRecheck fields when cleaning up listeners 71/93471/1
Robert Varga [Thu, 29 Oct 2020 16:51:17 +0000 (17:51 +0100)]
Recheck fields when cleaning up listeners

We may end up in a situation where we trigger multiple times, in
which case we can end up with mutated state and therefore cannot
rely on fields being non-null.

JIRA: YANGTOOLS-1155
Change-Id: I5607843d1e02483faa387a5630f3c4c06a3be62a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1105cf5bc00628ee6dc2d86dce1ef4225050a5ba)

3 years agoCentralize Abstract{Input,Output}StatementSupport.parseArgumentValue() 69/93469/1
Robert Varga [Thu, 29 Oct 2020 13:19:58 +0000 (14:19 +0100)]
Centralize Abstract{Input,Output}StatementSupport.parseArgumentValue()

As we have reduced the number of implementations of this method,
by introducing the default implementation, we are down to three
possible implementations under BaseSchemaTreeStatementSupport.

Add a level of indirection through Function<QNameModule, QName>, which
allows us to combine the two implementations into a single one residing
in BaseOperationContainerStatementSupport.

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

3 years agoAdd BaseSchemaTreeStatementSupport.parseArgumentValue() 68/93468/1
Robert Varga [Thu, 29 Oct 2020 13:13:12 +0000 (14:13 +0100)]
Add BaseSchemaTreeStatementSupport.parseArgumentValue()

Almost all subclasses of BaseSchemaTreeStatementSupport do the same
thing for parseArgumentValue(). Centralize the default behaviour there,
while allowing input/output statements to do their own thing.

JIRA: YANGTOOLS-1154
Change-Id: I7a3daf3a9c90eefadc1cad8043af3a2e7b9065e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 2ecfbbbba0d6add3664d998cbff940645bbb1428)

3 years agoMove implementation of OnStatementAdded to single class 65/93465/3
miroslav.kovac [Thu, 29 Oct 2020 10:26:47 +0000 (11:26 +0100)]
Move implementation of OnStatementAdded to single class

Create BaseSchemaTreeStatementSupport that implements
onStatementAdded and migrate all the usage from
StatementSupport classes.

JIRA: YANGTOOLS-1154
Change-Id: I3815d69f8621b9559470fea35fa4d427a717acc4
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit ca57ae28c6974bf6c5faa866667e52c8f458e325)

3 years agoAdd faster NormalizedNodes.findNode() alternatives 56/93356/1
Robert Varga [Sun, 25 Oct 2020 20:10:03 +0000 (21:10 +0100)]
Add faster NormalizedNodes.findNode() alternatives

End users are going through iterators needlessly when they want
to touch just a single PathArgument. Add methods which side-step
the intermediate List.

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

3 years agoSpeed up NormalizedNodes.getDirectChild() 55/93355/1
Robert Varga [Sun, 25 Oct 2020 20:05:39 +0000 (21:05 +0100)]
Speed up NormalizedNodes.getDirectChild()

Deal with positive matches first, let ValueNode be dealt with using
the default path.

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

3 years agoBump versions to 5.0.8-SNAPSHOT 12/93012/1
Robert Varga [Sat, 10 Oct 2020 16:07:36 +0000 (18:07 +0200)]
Bump versions to 5.0.8-SNAPSHOT

This starts the next development iteration.

Change-Id: I6943287d118e7e46db909bd9b7cecefe0b63e0a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 7.0.7 09/93009/1
Robert Varga [Fri, 9 Oct 2020 17:12:59 +0000 (19:12 +0200)]
Bump odlparent to 7.0.7

Pick up latest upgrade from upstream.

Change-Id: I84f2fde64259b4b2f3417235f1fd442aea4df30a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake YangNamespaceContextNamespace global 45/92945/1
Robert Varga [Tue, 6 Oct 2020 18:47:55 +0000 (20:47 +0200)]
Make YangNamespaceContextNamespace global

The crux of the problem with not being able to resolve prefixes comes
from the fact we end up reusing the same context for both submodule
and module. Turn the namespace into a global one, keyed by the root
context.

JIRA: YANGTOOLS-1138
Change-Id: Ibdd1b4c2427fcf62a341e9ff15dddbd055ffa6fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cde92d4deb4fcc2446cca0d80fb0450e900aa914)

3 years agoInclude Uint.ZERO in lower saturation bounds 60/92860/2
Robert Varga [Fri, 2 Oct 2020 14:44:13 +0000 (16:44 +0200)]
Include Uint.ZERO in lower saturation bounds

This is a slight performance optimization, use constant zero for
zero values.

Change-Id: I4cc3e2e8656746b8fce7a43ddb42df8865221653
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse Uint constants in base types 00/92700/2
Robert Varga [Fri, 2 Oct 2020 14:13:14 +0000 (16:13 +0200)]
Use Uint constants in base types

Rather than using valueOf(), use exposed ZERO and MAX_VALUE,
improving initialization speed just a little.

Change-Id: Ib6938c039bdf8773d6000f9eb6b56cf8f01ae1d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd Uint saturated converters 57/92757/3
Robert Varga [Mon, 28 Sep 2020 16:57:15 +0000 (18:57 +0200)]
Add Uint saturated converters

There are a number of places where we need to perform a saturated
conversion, i.e. when we have a 'long' count and need to put it into
a Uint32 field. Add methods to deal with that.

JIRA: YANGTOOLS-1135
Change-Id: Ia0bb2e9f0400d975ce1f4b150704dcf526d3bc82
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert uint tests to assertThrows() 55/92855/2
Robert Varga [Fri, 2 Oct 2020 13:28:32 +0000 (15:28 +0200)]
Convert uint tests to assertThrows()

We have a number of tests which can be consolidated, use assertThrows.
This flushes out a bad test case, which is corrected.

Change-Id: I3b0b760cb89a4dbd93ebe44af2ed917b0698fc31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix warnings when we are augmenting-in a list 53/92553/6
Robert Varga [Mon, 21 Sep 2020 10:48:07 +0000 (12:48 +0200)]
Fix warnings when we are augmenting-in a list

When we are targetting a non-configuration list we end up issuing
a warning because the augment content contains the list as well --
and is not suppressed. Add logic to suppress it.

JIRA: YANGTOOLS-1133
Change-Id: I55e43d39949db756634e86e4e570df6bbbce6c1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump versions to 5.0.7-SNAPSHOT 55/92555/1
Robert Varga [Mon, 21 Sep 2020 11:25:52 +0000 (13:25 +0200)]
Bump versions to 5.0.7-SNAPSHOT

This starts the next development iteration.

Change-Id: I36e470faeb2cf74cdfa927fe23583c73a7205f10
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse StandardCharsets 52/92552/1
Robert Varga [Mon, 21 Sep 2020 10:52:12 +0000 (12:52 +0200)]
Use StandardCharsets

Java 10 allows us to use a proper constant for charset.

Change-Id: Ie7706356bf5bcbde05e7632b099901d226f40cf1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 7.0.6 50/92550/1
Robert Varga [Mon, 21 Sep 2020 10:23:20 +0000 (12:23 +0200)]
Bump odlparent to 7.0.6

Pick up latest fixes from upstream.

Change-Id: I7e22867d25864f5f7da312af35a6a8cc7cabeec4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDefine MaxAccess enumeration 96/92496/1
Robert Varga [Fri, 18 Sep 2020 22:06:18 +0000 (00:06 +0200)]
Define MaxAccess enumeration

RFC2578 specifies which strings are actually valid as max-access
arguments. Make sure we properly validate them and use an enum.

JIRA: YANGTOOLS-1134
Change-Id: I9e22dccb115f34ab50aaa8cf84e09d12713c69fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 51d659c364c9b775f50fa5badb7cf986e5ec29ac)

3 years agoFix SubIdStatement/ObjectIdentifier ranges 95/92495/1
Robert Varga [Fri, 18 Sep 2020 22:12:07 +0000 (00:12 +0200)]
Fix SubIdStatement/ObjectIdentifier ranges

RFC2578 makes it clear that each sub-identifier is an uint32 as
well as that there is at most 128 of them present in an ObjectIdentifier.

JIRA: YANGTOOLS-1134
Change-Id: Ic19baf8158c3e291c505c943bf16eae7cfd4ad58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f95dcc02afeddd89c820b0c8357c9747da91e051)

3 years agoRemove IetfYangSmiv2Namespace 90/92490/1
Robert Varga [Fri, 18 Sep 2020 20:49:04 +0000 (22:49 +0200)]
Remove IetfYangSmiv2Namespace

This namespace is useless, remove it.

JIRA: YANGTOOLS-1134
Change-Id: Ic285d7e68daf090b6a024f38a32de0c8e15414c1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 24120d6b7770c2c45e51176f048b98191edd69b7)

3 years agoRemove unneeded overrides 86/92486/1
Robert Varga [Fri, 18 Sep 2020 19:35:14 +0000 (21:35 +0200)]
Remove unneeded overrides

We have a number of overridden methods we do not need, remove them.

JIRA: YANGTOOLS-1134
Change-Id: I657d392f3b11f72bd9f7a51db5a983a759b8c868
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd RFC6643 parser support 83/92483/3
Robert Varga [Fri, 18 Sep 2020 15:54:47 +0000 (17:54 +0200)]
Add RFC6643 parser support

RFC6643 defines a way to map SMIv2 to YANG. This mapping retains
the original SMI details using YANG extensions, so that the resulting
model can be mapped back.

This patch adds semantic support for these extensions, so that the
semantics are supported out of the box.

JIRA: YANGTOOLS-1134
Change-Id: I494b2537e89e5a104debe486a9012d22d5c7b3aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4223bf8c4eae4a003b71554fbcc98b5377ddce2b)

3 years agoFix IRStatement formatting 78/92278/1
Robert Varga [Wed, 9 Sep 2020 12:22:06 +0000 (14:22 +0200)]
Fix IRStatement formatting

We should append a fragment rather than starting a new toString()
chain.

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

3 years agoInitialize IRStatementContext 25/92425/1
Robert Varga [Mon, 7 Sep 2020 19:02:32 +0000 (21:02 +0200)]
Initialize IRStatementContext

For compatibility reasons we may need to provide IRStatement-backed
StatementContext. This patch adds the basic conversion capability.

JIRA: YANGTOOLS-1130
Change-Id: I380d9c0438be60c3c6fef5377ebc674ebfe87f53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoIntroduce IRSchemaSource 16/92416/2
Robert Varga [Thu, 27 Aug 2020 09:51:02 +0000 (11:51 +0200)]
Introduce IRSchemaSource

Rather than using ASTSchemaSource, use a dedicated IRSchemaSource,
which ends up being the replacement for ASTSchemaSource. We are
undoing some work previously done, but it allows easier backporting.

JIRA: YANGTOOLS-1130
Change-Id: Ifdeaa0d053558eda12432264fb768ed0d821468f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 1d4d5d61d5c50661d898b1b184f984d055486fba)

3 years agoDisconnect IRStatement from ANTLR 58/92258/2
Robert Varga [Sun, 23 Aug 2020 10:44:21 +0000 (12:44 +0200)]
Disconnect IRStatement from ANTLR

While we currently allow instantiation only from ANTLR, we may end
up with other ways of instantiating the intermediate form. Make sure
IRStatement does not have a dependency on ANTLR.

JIRA: YANGTOOLS-1130
Change-Id: I4d28f7c4fd8457fe01e7eae967e0917c1a91b4e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd an explicit intermediate YANG representation 47/92247/3
Robert Varga [Fri, 14 Aug 2020 10:55:12 +0000 (12:55 +0200)]
Add an explicit intermediate YANG representation

ANTLR classes are geared towards parsing and raw speed, without much
regards to memory usage. Most notably using ParseTree as our AST ends
up retaining separators and various metadata which we do not really
need.

Add a simplistic intermediate representation for our AST, which where
we pre-process ANTLR trees and de-duplicate strings. This leads to
elimination of 90% of objects, with corresponding reduction of memory
footprint.

JIRA: YANGTOOLS-1130
Change-Id: Idf057bbb1e29280a8e378529401023fb87d18923
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit c4b572cd6d818d23e1d1d8d1883f388b43bb1160)

3 years agoMake sure ASTSchemaSource operates on StatementContext 57/92257/1
Robert Varga [Mon, 24 Aug 2020 10:12:30 +0000 (12:12 +0200)]
Make sure ASTSchemaSource operates on StatementContext

We have external checks which are superfluous, as the implementation
is known to be invariant.

Change-Id: Ib5028b69c950fc940c335d97fee44e4a4deab99e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEliminate DQUOT_START/SQUOT_START tokens 49/92249/1
Robert Varga [Sun, 23 Aug 2020 20:53:39 +0000 (22:53 +0200)]
Eliminate DQUOT_START/SQUOT_START tokens

Quoted strings are naturally terminated by end marker, potentially
preceded by DQUOT_STRING/SQUOT_STRING. This renders the corresponding
start tokens really just a academic completeness, costing us memory
while not bringing anything to the table.

Skip generation of these tokens, reducing memory usage by up to 4.5%.

JIRA: YANGTOOLS-1089
Change-Id: I0b7ce9bf292b0dd8475d63869ddfd8d2b86a387c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEliminate quotedString parser construct 41/92241/3
Robert Varga [Sun, 23 Aug 2020 07:10:02 +0000 (09:10 +0200)]
Eliminate quotedString parser construct

Double-quoted strings are very common and having a separate parser
construct is not giving us much for the memory footprint it incurs.

Inline the recursive definition into argument and adjust parsing
code to cope with the change. This results in memory usage improvement
of up to 3.7%.

JIRA: YANGTOOLS-1089
Change-Id: I9fce7d1ed9f8df4bcc602978c66fcfba7bbd8ed8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFurther optimize YANG statement parsing 02/92102/1
Robert Varga [Sat, 22 Aug 2020 20:26:56 +0000 (22:26 +0200)]
Further optimize YANG statement parsing

Recursive definition of stringPart can easily end up with a large
number of retained objects -- i.e. we get StringPartContext for
each concatenation, with potentially small lists of three tokens.

Furthermore each unquotedString has ends up being typically defined
by a UnquotedStringContext containing a single StringPartContext,
which is clearly wasteful.

The grammar we are looking at is not that complex, hence we can
rewrite it without relying on recursion -- thus improving memory
footprint.

JIRA: YANGTOOLS-1089
Change-Id: I18eb1305d3e024d530552ac5cea0b5a928da0048
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0ca5c81f163ed5a56d42cd8d68302654a9bb8918)

3 years agoDeprecate StmtContext.getSchemaPath() 00/92100/1
Robert Varga [Sat, 22 Aug 2020 17:49:36 +0000 (19:49 +0200)]
Deprecate StmtContext.getSchemaPath()

We want to be identifying everyone who is touching this state,
as it ends up logically referencing the parent node and is going
away.

JIRA: YANGTOOLS-1131
Change-Id: I33a93bec07e6a3a12afc920eb6fe685fa4339f9b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 42c740433dad046caa3e22b84c6f4edccdd58197)

3 years agoSpecial-case identifier lexer token 08/92208/1
Robert Varga [Thu, 20 Aug 2020 14:48:41 +0000 (16:48 +0200)]
Special-case identifier lexer token

An unquoted string can be an IDENTIFIER, which is the most common
case anyway. This token does not have to be further validated and
thus it makes sense to special-case it. This has the neat effect
of reducing the depth of our parse tree, too -- bringing memory
usage down by 6.6% versus the original fix.

JIRA: YANGTOOLS-1089
Change-Id: I63701719e90334558048201d70d8264ab9299efb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 0ec7fd50a8d7768f55d03e2ad1c6156fb6836c67)

3 years agoCorrect (Un)qualifiedQName javadoc 99/92099/1
Robert Varga [Thu, 20 Aug 2020 09:35:23 +0000 (11:35 +0200)]
Correct (Un)qualifiedQName javadoc

This adds a bit of documentation and correcting a mitsaken @return.

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

3 years agoAdd a specialized token factory 00/92200/1
Robert Varga [Mon, 10 Aug 2020 12:07:00 +0000 (14:07 +0200)]
Add a specialized token factory

Our baseline parsing footprint is rather large. We can improve it
by looking at token component sizes and using distinct token classes.

Aside from CommonToken, which are using as fallbacks for text
handling, we introduce 4 specialized classes, three of them seeing
typical use.

Since these classes use smaller fields to hold lazy state, as well
as eliminate typical invariants, we end up saving around 39MiB (12%)
of AST size in a typical case from the field.

JIRA: YANGTOOLS-1128
Change-Id: I600ae6cbe755212e2d1a15ae3e6b369ed0b3b962
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit f65682b440f3a2767a7852c9b1b3f0d0ea25f95d)

3 years agoAdd timing information about local file discovery 99/92199/1
Robert Varga [Thu, 20 Aug 2020 07:41:39 +0000 (09:41 +0200)]
Add timing information about local file discovery

Locating local files actually requires also pasing them to establish
their SourceIdentifier. Add output to establish timing of this step.

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

3 years agoTake advantage of keyword tokenization 52/92152/3
Robert Varga [Fri, 14 Aug 2020 09:09:05 +0000 (11:09 +0200)]
Take advantage of keyword tokenization

Now that the tokenization has been fixed, we can rely on keyword
context to provide us with neatly split prefix and local name --
hence we do not need to perform concat/split.

Change-Id: I5d8e37d2267fefa3c5eafc542e00df33142a0bae
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRework YANG lexer/parser 39/92139/8
Robert Varga [Thu, 13 Aug 2020 18:15:06 +0000 (20:15 +0200)]
Rework YANG lexer/parser

The definitions in the parser and lexer are quite arcane and are
actually wrong, not allowing for a number of edge cases, which are
completely valid.

Furthermore the definition of IDENTIFIER is wrong, as it allows /
and : to appear in it -- effectively ruining the tokenization in
parser.

Refactor the lexer to perform correct tokenization in every situation.
This makes it more complicated, but also much more obvious as to
what is going on -- especially with regard as to what decisions
end up being parser's responsibility.

Refactor the parser so it recognizes YANG tokenization constructs,
notably quoted and unquoted strings, and assemble them from lexer
tokens.

JIRA: YANGTOOLS-1089
Change-Id: I34472bf0a7e262d4f633ce271952bbcd7639ef2f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReplace block comment with a non-greedy rule 37/92137/1
Robert Varga [Thu, 13 Aug 2020 18:09:10 +0000 (20:09 +0200)]
Replace block comment with a non-greedy rule

We do not need an explicit mode here, we can just use a non-greedy
match and move on. This simplifies things a bit.

Change-Id: Ieab6d9cec1b17c8d86cda49cfc46a258a569e5e0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRework keyword parser rule 32/92032/5
Robert Varga [Tue, 11 Aug 2020 09:38:52 +0000 (11:38 +0200)]
Rework keyword parser rule

A keyword is either a plain identifier, or two identifiers concatenated
through a colon. Make this a bit clearer, aiding debugging of issues.

Also push KeywordContext down to
StatementContextVisitor.getValidStatementDefinition(), so that we can
improve efficiency once IDENTIFIER token has been fixed up.

Change-Id: Ic64285255564ae33f8ad208b9a3598ba20cd26fb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor YANG statement parser structure 27/92027/3
Robert Varga [Tue, 11 Aug 2020 08:47:25 +0000 (10:47 +0200)]
Refactor YANG statement parser structure

Current definition leads to leading whitespace being considered
a part of the statement. This leads to misleading line/character
being reported as the start of the statement.

Fix this by introducing a top-level 'file', which encapsulates
at least one statement with its leading/trailing whitespace. The
other parts then come together naturally.

JIRA: YANGTOOLS-1129
Change-Id: I9f725b09eae6f8acf4397c97c60f99caaade798b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix AnyxmlSchemaLocationStatementSupport declaration 15/92015/2
Robert Varga [Mon, 10 Aug 2020 16:17:25 +0000 (18:17 +0200)]
Fix AnyxmlSchemaLocationStatementSupport declaration

We should not be operating on parameterized EffectiveStatement,
but rather of AnyxmlSchemaLocationEffectiveStatement itself.

Change-Id: I9130f57ced47d416d3d7f300e03eacd876bf0a27
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix YangDataStatementSupport declaration 14/92014/2
Robert Varga [Mon, 10 Aug 2020 16:11:57 +0000 (18:11 +0200)]
Fix YangDataStatementSupport declaration

We should not be operating on parameterized EffectiveStatement,
but rather of YangDataEffectiveStatement itself.

Change-Id: I02797816e712b9a484dca694c77f4074ceb2b0da
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix declaration of extension-related supports 11/92011/2
Robert Varga [Mon, 10 Aug 2020 15:13:10 +0000 (17:13 +0200)]
Fix declaration of extension-related supports

We should properly specialize these to UnrecognizedEffectiveStatement,
not just any old statement.

Change-Id: I4a09dd9d25040bf62142444566ca39c61b6c57fc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix yangtools-docs references 34/91634/1
Robert Varga [Fri, 24 Jul 2020 15:12:03 +0000 (17:12 +0200)]
Fix yangtools-docs references

We are pointing at the wrong versions again, fix that up.

Change-Id: I14280df808a8d7d3cc9037dc3d51860f89018d18
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix some util javadoc warnings 15/91615/1
Robert Varga [Fri, 24 Jul 2020 09:17:34 +0000 (11:17 +0200)]
Fix some util javadoc warnings

Clean up some warnings, progressing towards a warning-free build.

Change-Id: Ia199d771f409f25ffa1f8aadfd1814f13ee3806e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup yang-model-api javadoc warnings 12/91612/1
Robert Varga [Fri, 24 Jul 2020 09:05:36 +0000 (11:05 +0200)]
Fixup yang-model-api javadoc warnings

There are a number of issues javadoc is complaining about, fix them
up.

Change-Id: I82e108faca800b80a85e00aab96cb8ec8fdc91e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump versions to 5.0.6-SNAPSHOT 38/91538/2
Robert Varga [Wed, 22 Jul 2020 13:18:32 +0000 (15:18 +0200)]
Bump versions to 5.0.6-SNAPSHOT

This starts the next development iteration.

Change-Id: I8cc0583d3cf9f32a4ebc7cb971fe29d226196ac6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 7.0.5 34/91534/1
Robert Varga [Wed, 22 Jul 2020 12:15:25 +0000 (14:15 +0200)]
Bump odlparent to 7.0.5

Pick up odlparent with netty fix.

Change-Id: I1b469bcb1f34fab8dc82ed39b4d3ffe418d24099
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRevert "Update YANG lexer/parser to accept free-standing '+'" 32/91532/1
Robert Varga [Wed, 22 Jul 2020 11:15:56 +0000 (13:15 +0200)]
Revert "Update YANG lexer/parser to accept free-standing '+'"

This reverts commit 04ed60d275521fd6e6ee57d5b1ce4e6a519d2e35, as it
causes a regression around "foo" +"foo" construct.

JIRA: YANGTOOLS-1089
Change-Id: Ib5af7a994c19bf99fb5cb2a875063d623cc6c3f7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate SchemaNodeIdentifier design a bit 11/91511/3
Robert Varga [Tue, 21 Jul 2020 19:01:20 +0000 (21:01 +0200)]
Update SchemaNodeIdentifier design a bit

Using explicit instanceof checks is not very code friendly, as we
usually end up using either Absolute or Descendant identifier and
forcing an instanceof check is hiding things from the compiler.

Furthermore {first,last}NodeIdentifier are really only useful in
the Absolute case.

Update the design by moving utility methods to Absolute and
add four specialized classes. While this adds a bit of code
duplication and verbosity, the result is a bit better in that we
do not have explicit casts and checks.

Furthermore, in the case of a particular use, for example Absolute,
the code ends up dealing with two concrete implementations, leading
to bimorphic dispatch which is fully visible to JIT.

Change-Id: I2f3b7dc9ac3bf3d038e815f2406bd5c5629f8553
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd SchemaNodeIdentifier.{first,last}Identifer() 08/91508/1
Robert Varga [Tue, 21 Jul 2020 15:29:46 +0000 (17:29 +0200)]
Add SchemaNodeIdentifier.{first,last}Identifer()

A number of operations involving SchemaNodeIdentifier are interested
in either the first or the last part of it. Add methods to efficiently
access them.

Change-Id: I0ecb9ee2d4ce0aba7ca7c302a751c273555456e9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd SchemaNodeIdentifier.Absolute.intern() 02/91502/2
Robert Varga [Tue, 21 Jul 2020 12:02:19 +0000 (14:02 +0200)]
Add SchemaNodeIdentifier.Absolute.intern()

We will be using SchemaNodeIdentifiers in a lot of contexts, some
of which involve dynamic wiring lookups. In these contexts we want
the ability to squash an Absolute schema node identifier into a
JVM-wide single instance -- hence we get benefits of cached hash
code and instance-shortcuts on equals().

Change-Id: I2144ba659a783d585e59103dde3e6d292a63ec48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump versions to 5.0.5-SNAPSHOT 95/91395/1
Robert Varga [Fri, 17 Jul 2020 15:54:52 +0000 (17:54 +0200)]
Bump versions to 5.0.5-SNAPSHOT

This starts the next development iteration.

Change-Id: I35d576671154998adba1643361ce0dc86ad576cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump to odlparent-7.0.4 35/91235/5
Robert Varga [Sat, 11 Jul 2020 14:22:25 +0000 (16:22 +0200)]
Bump to odlparent-7.0.4

Pick up latest upgrades from upstream.

Change-Id: I9843867449ac5f0eaf16d562df493cb13b495f4c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse modifiable List when resolving relative xpath 18/91318/9
Tomas Cere [Tue, 14 Jul 2020 13:05:18 +0000 (15:05 +0200)]
Use modifiable List when resolving relative xpath

When we have split the path into its components, we can end up
compressing them further. Make sure the list is actually mutable.

JIRA: YANGTOOLS-1125
Change-Id: I1d4cd66d2efbb1955bb189763ea09fefeba93d25
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClean up predicates prior to xpath normalization 29/91329/2
Tomas Cere [Wed, 15 Jul 2020 08:43:57 +0000 (10:43 +0200)]
Clean up predicates prior to xpath normalization

Path splitting is not equipped to ignore step predicates, which leads
it to do arrive at the wrong path. Remove any predicates before
embarking on resolving the reference.

JIRA: YANGTOOLS-1126
Change-Id: Ia32836ad1acec0762d9baa7ded5f65fa72f39b93
Signed-off-by: Tomas Cere <tomas.cere@pantheon.tech>