yangtools.git
3 years agoMake CopyHistory implement CopyableNode 35/94835/6
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>
3 years agoRevert "Do not call setFullyDefined() in ReplicateStatementContext" 38/94838/2
Robert Varga [Wed, 27 Jan 2021 11:06:22 +0000 (12:06 +0100)]
Revert "Do not call setFullyDefined() in ReplicateStatementContext"

This reverts commit 5a24e6e2e40ce961f016ee37ab44f5a0a46ec514. As it
turns out this can actually fail.

Change-Id: I3733be139390f959ec451bde76d1ea1b9e1ddced
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix detection of reused substatements 28/94828/3
Robert Varga [Tue, 26 Jan 2021 18:15:50 +0000 (19:15 +0100)]
Fix detection of reused substatements

There is a thinko here, as the comparison check is hidden by
eager copy. This renders complete statement reuse inoperative.
Fix this by explicitly specifying the contract of
asEffectiveChildOf() and properly wrap it.

JIRA: YANGTOOLS-1212
Change-Id: I9c3c3bc73e57854f1c126a5d6862b485c8659d34
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd concepts to parser-spi's requires 30/94830/2
Robert Varga [Wed, 27 Jan 2021 06:49:36 +0000 (07:49 +0100)]
Add concepts to parser-spi's requires

This is another tiny change for Eclipse's sake.

Change-Id: I2d50dedf232d63456f3574bc1f025f92d558a736
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReuse unchanged substatements 27/94827/2
Robert Varga [Tue, 26 Jan 2021 19:00:56 +0000 (20:00 +0100)]
Reuse unchanged substatements

Even when all substatements are not context-independent, they may
end up being insensitive to the copy operation. In that case we
really want to reuse the substatement list.

JIRA: YANGTOOLS-1212
Change-Id: I6616569e32a48af280abe10bed86e4eae9494837
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReuse context-independent substatements 26/94826/2
Robert Varga [Tue, 26 Jan 2021 18:50:16 +0000 (19:50 +0100)]
Reuse context-independent substatements

Isolating tryToReuseSubstatements() allows us to simply bypass
substatements copies when they remain unchanged. We still need to
create their replicas to keep refCount mechanics working.

JIRA: YANGTOOLS-1212
Change-Id: I312979fbf107b6603e019c9daf24620d90bf4e98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSeparate out InferredStatementContext.tryToReuseSubstatements() 25/94825/2
Robert Varga [Tue, 26 Jan 2021 18:23:20 +0000 (19:23 +0100)]
Separate out InferredStatementContext.tryToReuseSubstatements()

This is a major path, separate it out for further development.

JIRA: YANGTOOLS-1212
Change-Id: Ib376d5cf340b2360d11b061d2be1fb19919266a1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCentralize ReactorStmtCtx.replicaAsChildOf() 24/94824/4
Robert Varga [Tue, 26 Jan 2021 16:51:37 +0000 (17:51 +0100)]
Centralize ReactorStmtCtx.replicaAsChildOf()

This allows the implementations to rely on dealing with its peer
constructs.

JIRA: YANGTOOLS-1212
Change-Id: I4065e10e1580bb1324448f05a9f6a3ae6bcdd30c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not call setFullyDefined() in ReplicateStatementContext 10/94810/1
Robert Varga [Tue, 26 Jan 2021 10:51:54 +0000 (11:51 +0100)]
Do not call setFullyDefined() in ReplicateStatementContext

When we are copying statements the source needs to have its effective
model present, hence it needs to be fullyDefined() already.

That makes it a 'true -> true' transition, which we do not need.
Verify that source.fullyDefined() and skip the set operation.

Change-Id: Iff21df88f6c5d35c05e4a165953ee1de586d9c4e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove unneeded setIsSupportedToBuildEffective() 08/94808/1
Robert Varga [Tue, 26 Jan 2021 10:46:07 +0000 (11:46 +0100)]
Remove unneeded setIsSupportedToBuildEffective()

This flag is inherited from source, hence the set operation ends up
being a 'false -> false' transition. Just remove it and mark a FIXME
for future improvement.

Change-Id: I353e7787d9ca08eaeeed27f1100bc74757d8b5bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCache substatement context-independence summary 56/94656/12
Robert Varga [Mon, 25 Jan 2021 12:32:35 +0000 (13:32 +0100)]
Cache substatement context-independence summary

Individual statements expose their statically-known CopyPolicy,
which governs how they react to being copied. This does not account
the statement instance's substatements, as that is a
partially-dynamic property.

Even if a particular statement is affected by the copy operation,
it is quite common for its substatement (tree) to not be affected --
lending itself for reuse of the effective substatement list as well
as any structures which are derived from it.

Whenever a statement completes ModelProcessingPhase.EFFECTIVE_MODEL,
examine all substatements and whether all of them are recursively
context-independent.

Expend our last remaining bit in ReactorStmtCtx.flags to remember
the check's result -- preventing the need to recurse into a
substatement's substatements.

Also add an explicit unit test to show that 'when' with 'description'
and 'reference' gets reused in its entirety.

JIRA: YANGTOOLS-1209
Change-Id: I0fda715da441038a1276678f49718df9bfacfb90
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd explicit test for 'key' statement reuse 80/94780/2
Robert Varga [Mon, 25 Jan 2021 12:11:43 +0000 (13:11 +0100)]
Add explicit test for 'key' statement reuse

Key statements should end up reused as they depend only on target
namespace. Add an explicit test to make sure this does not get lost.

JIRA: YANGTOOLS-1195
Change-Id: Ic33f4ee65122c5c023897fe9bd1e9bd2df4ee1f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdopt odlparent-8.1.0 41/94741/2
Robert Varga [Thu, 21 Jan 2021 13:03:27 +0000 (14:03 +0100)]
Adopt odlparent-8.1.0

Pick up latest version, which introduces OSGi R7 and a few other
relevant updates.

Change-Id: I2ee2bded604ce7a8aedc5dcc9de1b03930c4e70f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert simple SchemaTree statements 23/94723/2
Robert Varga [Thu, 21 Jan 2021 22:14:31 +0000 (23:14 +0100)]
Convert simple SchemaTree statements

The supports for anydata, anyxml and container perform a
straightforward instantiation, making for easy pickings.

JIRA: YANGTOOLS-1208
Change-Id: I1d4c0006d181545dacb821e5e211b086f982c672
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd BaseSchemaTreeStatementSupport statement policies 17/94717/4
Robert Varga [Thu, 21 Jan 2021 19:49:17 +0000 (20:49 +0100)]
Add BaseSchemaTreeStatementSupport statement policies

All current subclasses are using at least two broadly-applicable
policies:

- uninstantiated statements, i.e. action, notification, input, output
  These are always EffectiveConfig.IGNORED anyway.

- instantiated statements, i.e. leaf, container and the like, who
  need to adjust their view of EffectiveConfig.

Introduce these two and convert uninstantiated users.

JIRA: YANGTOOLS-1208
Change-Id: I7847bda9d9b5ef782deda4df40f7c449daafbf4f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUniqueStatementSupport is context-independent 24/94724/2
Robert Varga [Thu, 21 Jan 2021 22:24:35 +0000 (23:24 +0100)]
UniqueStatementSupport is context-independent

Current behavior, while suspicious, is context-independent:
the paths remain in their originally-parsed form. This probably
renders them unusable for actually looking things up.

Drop a FIXME and migrate to contextIndependent().

JIRA: YANGTOOLS-1208
Change-Id: Ic15bd9d5f7c67b1e3154ba393a72b9b3308cf167
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix ReplicaStatementContext.getEffectOfStatement() 75/94675/2
Robert Varga [Wed, 20 Jan 2021 17:41:19 +0000 (18:41 +0100)]
Fix ReplicaStatementContext.getEffectOfStatement()

A replica can be consulted on statement ordering, in which case we
want to return an empty list, as the replica itself does not affect
the outcome of statement order.

JIRA: YANGTOOLS-1195
Change-Id: I9b90bc385a23e1a5eda70675d2f1e68cdfbf3f89
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse StatementPolicy instead of CopyPolicy 89/94089/52
Robert Varga [Tue, 19 Jan 2021 22:16:40 +0000 (23:16 +0100)]
Use StatementPolicy instead of CopyPolicy

All of the outstanding CopyPolicy users need a careful audit,
this patch creates a focal point in
StatementPolicy.legacyDeclaredCopy() and its modern equivalent
in StatementPolicy.alwaysCopyDeclared().

Statements will be gradually migrated away to the appropriate
policy in follow-up patches.

JIRA: YANGTOOLS-1195
Change-Id: I1c97ecb625528971e4ee7493c01d68ab852a03d4
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRPC statement should refuse to get copied 72/94672/2
Robert Varga [Tue, 19 Jan 2021 21:54:59 +0000 (22:54 +0100)]
RPC statement should refuse to get copied

RPCs cannot be defined inside reusable constructs and therefore
they should never be copied. Use the appropriate policy.

JIRA: YANGTOOLS-1195
Change-Id: I4cbf582cac0a4865447bc3782cf1771c96d7cba3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFinish trivial conversions 71/94671/1
Robert Varga [Tue, 19 Jan 2021 19:43:13 +0000 (20:43 +0100)]
Finish trivial conversions

We have a few callers using CopyPolicy instead of StatementPolicy.
This migrates them all, leaving only CopyPolicy.DECLARED_COPY users.

JIRA: YANGTOOLS-1195
Change-Id: Id227c06c8fde05d2b86faef7edd25b3ec141462b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseQNameStatementSupport 70/94670/3
Robert Varga [Tue, 19 Jan 2021 19:17:10 +0000 (20:17 +0100)]
Promote BaseQNameStatementSupport

Promote this class as parser.spi.meta.AbstractQNameStatementSupport,
making it more widely available.

JIRA: YANGTOOLS-1150
Change-Id: I97798d3defdbf58f4d10f0e0419f1dbeccddf76b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove historyAndStatusFlags() 69/94669/2
Robert Varga [Tue, 19 Jan 2021 19:15:46 +0000 (20:15 +0100)]
Move historyAndStatusFlags()

This utility method is very much tied to EffectiveStatementMixins,
move it there, increasing BaseQNameStatementSupport mobility.

JIRA: YANGTOOLS-1150
Change-Id: Ibf5e279f7102293487f2a9278fbe57bf0776753b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseInternedStatementSupport 68/94668/2
Robert Varga [Tue, 19 Jan 2021 19:03:17 +0000 (20:03 +0100)]
Promote BaseInternedStatementSupport

Promote this class as parser.spi.meta.AbstractInternedStatementSupport,
making it more widely available.

JIRA: YANGTOOLS-1150
Change-Id: Ia3466d753a2870ef6432bf6319c78aca61576fc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseStringStatementSupport 67/94667/3
Robert Varga [Tue, 19 Jan 2021 18:48:55 +0000 (19:48 +0100)]
Promote BaseStringStatementSupport

Promote this class as parser.spi.meta.AbstractStringStatementSupport,
making it easier to use.

JIRA: YANGTOOLS-1150
Change-Id: I9ad1fbc637815ffcb1b5763c53dbfdc8944f7098
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseVoidStatementSupport 65/94665/2
Robert Varga [Tue, 19 Jan 2021 18:47:13 +0000 (19:47 +0100)]
Promote BaseVoidStatementSupport

Promote this class as parser.spi.meta.AbstractVoidStatementSupport,
making it easier to use.

JIRA: YANGTOOLS-1150
Change-Id: I552f5aca1ec9004c41b550fcfef78e3febe7d2f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseBooleanStatementSupport 64/94664/1
Robert Varga [Tue, 19 Jan 2021 18:44:44 +0000 (19:44 +0100)]
Promote BaseBooleanStatementSupport

Promote this class as parser.spi.meta.AbstractBooleanStatementSupport,
making it easier to use.

JIRA: YANGTOOLS-1150
Change-Id: I2f6d5c384246aca8b154d28bf8aeea94d19545b7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseStatementSupport to parser.spi.meta 59/94659/5
Robert Varga [Tue, 19 Jan 2021 14:59:01 +0000 (15:59 +0100)]
Promote BaseStatementSupport to parser.spi.meta

Aside from specialist machinations this class is used for statement
implementations -- hence should really live in SPI, as there is
precious little it does which is RFC7950-specific.

JIRA: YANGTOOLS-1150
Change-Id: Iddda14bbb43d6bc94a71d4ff3e532b5af7e861f5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake StatementSupport an abstract class 58/94658/5
Robert Varga [Tue, 19 Jan 2021 14:48:33 +0000 (15:48 +0100)]
Make StatementSupport an abstract class

This interface contract is quite explicit and all implementations
rely on AbstractStatementSupport (except ForwardingStatementSupport).

Turn StatementSupport into an abstract class, absorbing
AbstractStatementSupport in process of doing so. This frees up a
place in which rfc7950.stmt.BaseStatementSupport can land.

JIRA: YANGTOOLS-1150
Change-Id: I99dd54249880ada1fc461a00f3c6b38ebf47f957
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPeel uses/refine getEffectOfStatement() mechanics 61/94661/3
Robert Varga [Tue, 19 Jan 2021 17:11:48 +0000 (18:11 +0100)]
Peel uses/refine getEffectOfStatement() mechanics

Uses and refine communicate refine statement's target context
during uses inference, to be picked up (via caerbannog().

Remove this semantic side-channel for a statement-local namespace,
which leaks this bit between the namespace.

JIRA: YANGTOOLS-1186
Change-Id: I788f937c1f16eeada6889b0eae5d623901b4401c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agomodule-info.java audit, part one 55/94655/2
Robert Varga [Mon, 18 Jan 2021 23:43:16 +0000 (00:43 +0100)]
module-info.java audit, part one

Add explicit requires on upstream dependencies, not relying on their
transitive requires (although they are obvious from functionality
break down perspective).

Change-Id: I70b8c4e4edf7e9f9955922bc6ba5b1c1171be260
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert trivial CopyPolicy users to StatementPolicy 57/94657/4
Robert Varga [Tue, 19 Jan 2021 12:51:03 +0000 (13:51 +0100)]
Convert trivial CopyPolicy users to StatementPolicy

Context-independent and reject-copy statements are trivial to
migrate, do just that. We also introduce migration constructors
to various abstract statement support classes to allow the
policy to pass through.

JIRA: YANGTOOLS-1195
Change-Id: Ib1d4de524e55b81bfaef69886ab8d113651cdb96
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not force materialization when not needed 54/94654/10
Robert Varga [Mon, 18 Jan 2021 06:56:56 +0000 (07:56 +0100)]
Do not force materialization when not needed

When an InferredStatementContext was not forced to materialize
during inference, i.e. there was no movement in its substatements,
we can potentially reuse the same EffectiveStatement instance.

Refactor applyCopyPolicy() to provide the statement-specific
facility to decide which way the semantics goes. Based on this
feedback, the InferredStatementContext is improved to skip
instantiations when instructed to do so by the support.

AbstractStatementSupport is retrofitted to provide this functionality
through EffectiveComparator and its subclasses. Backwards compatibility
is maintained via choosing a conservative comparator based on
copy policy.

KeyStatementSupport is converted to take advantage of these
facilities.

JIRA: YANGTOOLS-1195
Change-Id: Idcea43f5ee121598eba324bac2a2edc70b11eaaa
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSeparate out StatementSupport.applyCopyPolicy() 53/94653/4
Robert Varga [Sun, 17 Jan 2021 09:00:23 +0000 (10:00 +0100)]
Separate out StatementSupport.applyCopyPolicy()

We have two concerns here:
- copying statements for inference purposes and lazily instantiating
  them there
- creating EffectiveStatement copies.

StatementSupport.copyPolicy() and StatementContextBase.copyAsChildOf()
take care of the first part.

StatementSupport.effectiveCopyOf() and
StatementContextBase.asEffectiveChildOf() are responsible for the
second concern. For now they are not wired, but concentrate remaining
FIXMEs for direction we need to in.

JIRA: YANGTOOLS-1195
Change-Id: I3b0a63b4620cf933ce104dc37e9db8678c71aba5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd guava to yang-parser-spi requirements 52/94652/1
Robert Varga [Sun, 17 Jan 2021 13:02:03 +0000 (14:02 +0100)]
Add guava to yang-parser-spi requirements

This is just another edit, we really need to do an audit.

Change-Id: I27dcc75d07d38d9c7e94c70d4cdfeb6d954b4c48
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a missing space 51/94651/1
Robert Varga [Sun, 17 Jan 2021 08:31:53 +0000 (09:31 +0100)]
Add a missing space

Fix the error message that would be produced if we were actually
hitting RootStatementContext.reparent().

Change-Id: Ica8d43617e0ae9183342d21d24c30eda26e969be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove StatementNamespace.TreeScoped.getParentContext() 49/94649/1
Robert Varga [Sat, 16 Jan 2021 12:08:28 +0000 (13:08 +0100)]
Remove StatementNamespace.TreeScoped.getParentContext()

This method is unspecified, unimplemented and unused. Remove it,
as either it was unused since day one, or we stopped using it.

Change-Id: I2ea0d325c80b1ef0f0db2c981c6feea1587ecd7c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove StatementNamespace.TreeBased 48/94648/1
Robert Varga [Sat, 16 Jan 2021 12:06:29 +0000 (13:06 +0100)]
Remove StatementNamespace.TreeBased

This interface was introduced in the initial code drop. It is not
specified and not used. Remove it.

Change-Id: I4458a8095d4e521a8b5744c9bdc9f7ac3607f650
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoQNameToStatementDefinition is not really a ParserNamespace 43/94643/1
Robert Varga [Sat, 16 Jan 2021 07:03:05 +0000 (08:03 +0100)]
QNameToStatementDefinition is not really a ParserNamespace

This interface is not used for inference, but rather loading statements
from a source. As such it is not used in its ParserNamespace capacity,
and therefore we remove this artificial connection.

JIRA: YANGTOOLS-1204
Change-Id: I675bc911fcbba68f139f7055270efc2d35f5746a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd ParserNamespace 42/94642/4
Robert Varga [Fri, 15 Jan 2021 22:28:43 +0000 (23:28 +0100)]
Add ParserNamespace

Parser's use of IdentifierNamespace is really mixing apples and oranges,
as parser has different needs than end users. ParserNamespace acts as
the replacement for IdentifierNamespace where parser internals are
concerned.

JIRA: YANGTOOLS-1204
Change-Id: I3710a610614526983b14289c11ad8e0664ad86a0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAnyxmlSchemaLocationNamespace should be statement-local 33/94633/1
Robert Varga [Thu, 14 Jan 2021 18:15:47 +0000 (19:15 +0100)]
AnyxmlSchemaLocationNamespace should be statement-local

Having this tree-scoped is wrong, correct that mistake.

Change-Id: I7b710a501ca2b564597938b7d32b0be98104b4ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove list/key checks to onStatementAdded() 29/94629/5
Robert Varga [Thu, 14 Jan 2021 12:04:57 +0000 (13:04 +0100)]
Move list/key checks to onStatementAdded()

We do not want to use the rabbit hole to StmtContext during effective
build, but rather perform the check as soon as the statement is added.

Depending on how the model is structured action/notification declaration
might happen before the key's presence is established and therefore
we perform an eager check first, but pay attention to ancestor's state.

If we encounter an ancestor which has not completed FULL_DECLARATION,
we hook an inference check to run just before it does.

JIRA: YANGTOOLS-1186
Change-Id: I8d8871a0eae860ba2327d05c43355a7ee3ffd382
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove parent checks to onStatementAdded() 26/94626/9
Robert Varga [Wed, 13 Jan 2021 22:49:03 +0000 (23:49 +0100)]
Move parent checks to onStatementAdded()

We are performing parent structural checks during buildEffective(),
which can be performed as soon as the statement is added.

A notable exclusion is list-with-key checking, which will be dealt
with in a follow-up patch.

JIRA: YANGTOOLS-1186
Change-Id: Id3e8cf6477765c3f89f657fd770952a7035ec876
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not catch instantiation exceptions during augment 28/94628/5
Robert Varga [Thu, 14 Jan 2021 08:39:33 +0000 (09:39 +0100)]
Do not catch instantiation exceptions during augment

The try/catch block here is overly broad and ill-defined, as it
suppresses failures produced by onStatementAdded().

A number of test cases actually worked around this by checking
either effects of the omission or that the presence of a message
being logged. These are corrected to assert the equivalent failure.

This necessitates splitting Bug8126Test into legal and illegal parts.

JIRA: YANGTOOLS-1186
Change-Id: Icd7c15ed82df38ccbdbd64e635c5a479e5a180aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate module-info.java 21/94621/4
Robert Varga [Wed, 13 Jan 2021 16:03:03 +0000 (17:03 +0100)]
Update module-info.java

Add explicit requires, as Eclipse does not trust these coming from
upstreams.

Change-Id: I8ea7bd2c9b8b930f4069fbece86df40f76dbb370
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSplit StmtContextUtils.hasParentOfType() implementations 24/94624/4
Robert Varga [Wed, 13 Jan 2021 22:00:57 +0000 (23:00 +0100)]
Split StmtContextUtils.hasParentOfType() implementations

EffectiveStmtCtx.Current version on this method is deferring to
the StmtContext version. That is not needed, as EffectiveStmtCtx
gives us everything we need.

JIRA: YANGTOOLS-1186
Change-Id: I8eedc34c6513b8aa6825ba8b63171111379f03ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCleanup YangParserNegativeTest 27/94627/3
Robert Varga [Thu, 14 Jan 2021 06:32:37 +0000 (07:32 +0100)]
Cleanup YangParserNegativeTest

Use assertThrows() and improve cause assertions.

Change-Id: I038c368694b606e45904458501f7949cc7981787
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix a javadoc typo 25/94625/2
Robert Varga [Wed, 13 Jan 2021 22:42:17 +0000 (23:42 +0100)]
Fix a javadoc typo

The word is 'tractable'.

Change-Id: I9ba56cd654948d0014939050cde8e71dbceb3974
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoExpose root QName from EffectiveStmtCtx.Current 22/94622/2
Robert Varga [Wed, 13 Jan 2021 18:26:04 +0000 (19:26 +0100)]
Expose root QName from EffectiveStmtCtx.Current

We are exposing the root here already, expose it in more structured
way, usable from more callsites.

JIRA: YANGTOOLS-1186
Change-Id: Ib9b7deadec31367f88e8391cc7ac31a2b53ce643
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoIntroduce ImportedVersionNamespace 20/94620/1
Robert Varga [Wed, 13 Jan 2021 16:01:00 +0000 (17:01 +0100)]
Introduce ImportedVersionNamespace

ImportStatementSupport is accessing StmtContext during effective
statement build only to perform work that is already done during
linkage. Add a namespace to hold the information required, which
boils down to a SourceIdentifier and pick it up when we need it.

JIRA: YANGTOOLS-1186
Change-Id: Ib17525dbc95c196fa6c4d9f95b3bc3e147fa414b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRelocate UnrecognizedEffectiveStatementImpl QName handling 18/94618/1
Robert Varga [Wed, 13 Jan 2021 11:02:16 +0000 (12:02 +0100)]
Relocate UnrecognizedEffectiveStatementImpl QName handling

We are hunting down StmtContext leaks, as a first step move the code
to UnrecognizedStatementSupport, which is better equipped to deal
with the problem.

JIRA: YANGTOOLS-1186
Change-Id: I90db7d9ed2b41127c01d4f0a05eeb0424e0b57d3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd QNameModuleNamespace 17/94617/3
Robert Varga [Wed, 13 Jan 2021 10:11:00 +0000 (11:11 +0100)]
Add QNameModuleNamespace

ModuleEffectiveStatement needs to know its own QNameModule, for
obvious reasons. Add a dedicated local namespace to carry this
information, so that we do not need to access the caerbannog()
implementation leak.

This also necessitates an update to NamespaceBehavior to treat
STATEMENT_LOCAL specially -- which we do by specializing a
NamespaceBehavior.StatementLocal.

JIRA: YANGTOOLS-1186
Change-Id: I9357c30122d7fe256f386754893c4e6130920d8e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove StmtContext.Mutable.addMutableStmtToSeal() 16/94616/2
Robert Varga [Wed, 13 Jan 2021 09:44:27 +0000 (10:44 +0100)]
Remove StmtContext.Mutable.addMutableStmtToSeal()

This method is used by the statement itself, and only by
SubmoduleEffectiveStatementImpl, which requies the deprecated
caerbannog() method.

Remove the method and shift the functionality down to
StatementContextBase, which operates on checking the type of
the effective statement.

JIRA: YANGTOOLS-1186
Change-Id: Id142bab1e8011af39397b57f783b980725edb4ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoParse yang-data argument during inference 14/94614/1
Robert Varga [Tue, 12 Jan 2021 14:36:27 +0000 (15:36 +0100)]
Parse yang-data argument during inference

We are accessing current StmtContext to parse the QName, which we
can do when we are declared and it is clear we will be building
the statement.

Add a local namespace to hold the QName and parse it on full
definition.

JIRA: YANGTOOLS-1186
Change-Id: Id5cd91acecc8e25c33c2d7c297be85b2b72e1516
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClarify StatementSupport.applyCopyPolicy() contract 92/94592/1
Robert Varga [Mon, 11 Jan 2021 09:49:31 +0000 (10:49 +0100)]
Clarify StatementSupport.applyCopyPolicy() contract

Target module and other parts are not well documented, change
that.

Change-Id: I77fa352ac50dea84bb373d71bf33146d726482a1
JIRA: YANGTOOLS-1163
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate Mockito.when() users 39/94539/1
Robert Varga [Sat, 9 Jan 2021 08:48:36 +0000 (09:48 +0100)]
Migrate Mockito.when() users

Mockito.doReturn() is much better interface, use that instead of
Mockito.when().

Change-Id: I7a0af8b1d4182980d181b96b7839b050ce34b31a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 8.0.3 61/94461/1
Robert Varga [Thu, 7 Jan 2021 10:15:10 +0000 (11:15 +0100)]
Bump odlparent to 8.0.3

Pick up latest fixes from upstream.

Change-Id: Ife5e5f86e79839022a5242182b2491784d4424a5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd ByteBufUtils.writeUint{8,16,32,64} 03/94403/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>
3 years agoImprove NormalizedNodes.toStringTree() 26/94326/2
Robert Varga [Fri, 1 Jan 2021 14:56:54 +0000 (15:56 +0100)]
Improve NormalizedNodes.toStringTree()

Eliminate an unneeded concatenation by passing the StringBuilder
down and performing two appends.

JIRA: YANGTOOLS-1203
Change-Id: Id24c825c28b060fb3c982c0f240d258d3f9cf0fc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBump odlparent to 8.0.2 16/94216/1
Robert Varga [Fri, 11 Dec 2020 13:27:53 +0000 (14:27 +0100)]
Bump odlparent to 8.0.2

Pick up the fixed-up version.

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

3 years agoFix checkstyle 06/94206/1
Robert Varga [Fri, 11 Dec 2020 10:11:53 +0000 (11:11 +0100)]
Fix checkstyle

Upgraded checkstyle is a bit touchier, make sure we comply with it.

Change-Id: I439104952085eb9fe8edc8d5ca71728ff1d5dca4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert yang-data-jaxen to OSGi DS 73/94173/3
Robert Varga [Fri, 11 Dec 2020 00:27:45 +0000 (01:27 +0100)]
Convert yang-data-jaxen to OSGi DS

We do not need a dependency on osgi.core here, just use component
annotations.

Change-Id: If19fd9722e7c09088a5dc8839ef774813a4a217d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix somar complaints in equals methods 75/94175/1
Robert Varga [Fri, 11 Dec 2020 00:56:29 +0000 (01:56 +0100)]
Fix somar complaints in equals methods

Sonar does not like if/else chains, simplify equals to simple
expressions.

Change-Id: I27087e85514a70bd3becde2fb5d41bcc11f6b8e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake sure SmtmtNamespaceContext uses belongs-to prefix 44/94144/3
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>
3 years agoUse correct key-arg splitting 17/94117/2
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>
3 years agoUse simple index for feature/extension/identity 16/94116/3
Robert Varga [Tue, 8 Dec 2020 15:28:01 +0000 (16:28 +0100)]
Use simple index for feature/extension/identity

Modules expose these three contructs in their user-facing namespaces.

While the same is available through inference's view of things, and
it is tempting to reuse those, this is a DTO contract over provided
substatements, hence use a simple filter to construct our own view
of the contents.

This reduces the dependency on NamespaceStmtCtx, making it easier
to separate the logic the DTO logic and the inference logic.

Change-Id: I544dd0d2b7f3cf07ea71f1075571056a0c62682d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUnify NamespaceStmtCtx.localNamespacePortion() 15/94115/2
Robert Varga [Tue, 8 Dec 2020 15:15:20 +0000 (16:15 +0100)]
Unify NamespaceStmtCtx.localNamespacePortion()

We have two under-documented methods, localNamespace() and
getAllFromCurrentStmtCtxNamespace(). Unify them and add proper
documentation.

Change-Id: I743c63d44c7127f58cea1b207539abb71a6d78ac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoInline AugmentInferenceAction.needToCopyByAugment() 13/94113/2
Robert Varga [Tue, 8 Dec 2020 14:25:17 +0000 (15:25 +0100)]
Inline AugmentInferenceAction.needToCopyByAugment()

There is a single caller of this simplistic method, just inline it
for clarity.

Change-Id: I2dddf1a6eaa22f8a7c1bf73888734fc2a3eafa37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge SubmoduleStatementSupport 12/94112/2
Robert Varga [Tue, 8 Dec 2020 14:22:33 +0000 (15:22 +0100)]
Merge SubmoduleStatementSupport

The two subclasses differ only in their statement validator,
merge them together, reducing the number of classes we have.

Change-Id: I474004ed988e6c2dd3ac5c607b95067afc6e3be7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge ListStatementSupport 11/94111/2
Robert Varga [Tue, 8 Dec 2020 15:02:31 +0000 (16:02 +0100)]
Merge ListStatementSupport

The two subclasses differ only in their statement validator,
merge them together, reducing the number of classes we have.

Change-Id: I8c07d438ff20a572f44b4e6498630d125f9054c9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge PatternStatementSupport 10/94110/3
Robert Varga [Tue, 8 Dec 2020 14:14:02 +0000 (15:14 +0100)]
Merge PatternStatementSupport

The two subclasses differ only in their statement validator,
merge them together, reducing the number of classes we have.

Change-Id: I91b8903b025e7cc341be87d44a494e1afee8177a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge ImportStatementSupport 09/94109/1
Robert Varga [Tue, 8 Dec 2020 14:10:12 +0000 (15:10 +0100)]
Merge ImportStatementSupport

The two subclasses differ only in their statement validator,
merge them together, reducing the number of classes we have.

Change-Id: Idde95d74ba9675c4fd1655588b443cc46aaea47c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge LeafListStatementSupport 08/94108/1
Robert Varga [Tue, 8 Dec 2020 14:05:39 +0000 (15:05 +0100)]
Merge LeafListStatementSupport

The two subclasses differ only in their implicit input/output,
merge them together, reducing the number of classes we have.

Change-Id: Icc8d4e4e37fdb013deae11b98d5f9d93d6e0d607
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge RpcStatementSupport 07/94107/2
Robert Varga [Tue, 8 Dec 2020 12:10:37 +0000 (13:10 +0100)]
Merge RpcStatementSupport

The two subclasses differ only in their implicit input/output,
merge them together, reducing the number of classes we have.

Change-Id: Ic6c99a243f01bc23bae5d72e9e3ad45855fd8fec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge Input/OutputStatementSupport 06/94106/2
Robert Varga [Tue, 8 Dec 2020 11:59:25 +0000 (12:59 +0100)]
Merge Input/OutputStatementSupport

The four subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I29478a515c0593d63b406ca3a70ea364d868c6ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge IncludeStatementSupport 05/94105/2
Robert Varga [Tue, 8 Dec 2020 11:40:42 +0000 (12:40 +0100)]
Merge IncludeStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I496ddce2f145c3731bc03e095609a41648f69551
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove URIStringToImportPrefix 98/94098/4
Robert Varga [Tue, 8 Dec 2020 10:27:50 +0000 (11:27 +0100)]
Remove URIStringToImportPrefix

This namespace has been deprecated and replaced by ModuleQNameToPrefix.
Since there are no users left, remove it.

Change-Id: I203d03a582ef3ad58fe2b6d693cc16df3dab13b1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge GroupingStatementSupport 04/94104/3
Robert Varga [Tue, 8 Dec 2020 11:33:38 +0000 (12:33 +0100)]
Merge GroupingStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I97dd358a284d3105538bfd324c30abc82ca17501
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge EnumStatementSupport 03/94103/3
Robert Varga [Tue, 8 Dec 2020 11:28:49 +0000 (12:28 +0100)]
Merge EnumStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I0b8cf53e97f9e95de5ea137f3e2c1937b6bc670f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge ContainerStatementSupport 02/94102/4
Robert Varga [Tue, 8 Dec 2020 10:58:06 +0000 (11:58 +0100)]
Merge ContainerStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: Ie740c816edcc2454f712f47ce08e658ae9f6739c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge ChoiceStatementSupport 01/94101/4
Robert Varga [Tue, 8 Dec 2020 10:49:46 +0000 (11:49 +0100)]
Merge ChoiceStatementSupport

The two subclasses differ only in validator and implicit case,
merge them together, reducing the number of classes we have.

Change-Id: I444bb493c2d423beb71ddf0438f3774ed01299cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge CaseStatementSupport 00/94100/4
Robert Varga [Tue, 8 Dec 2020 10:36:47 +0000 (11:36 +0100)]
Merge CaseStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I6f545fbdc721f1a83e9515d73b32c886e988b172
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge BitStatementSupport 99/94099/3
Robert Varga [Tue, 8 Dec 2020 10:32:35 +0000 (11:32 +0100)]
Merge BitStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I33ab01f5edfc5b7510e6ea381e31dbd6e052d45e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge IdentityStatementSupport 97/94097/2
Robert Varga [Tue, 8 Dec 2020 10:24:48 +0000 (11:24 +0100)]
Merge IdentityStatementSupport

The two subclasses differ only in validator, merge them together,
reducing the number of classes we have.

Change-Id: I74d83ddf81258bd9d5d5ba914e10fb63a6bd4adb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge ModuleStatementSupport 95/94095/1
Robert Varga [Mon, 7 Dec 2020 20:22:43 +0000 (21:22 +0100)]
Merge ModuleStatementSupport

The two subclasses differ only in validator, merge them into a
single one, reducting the number of classes we have.

Change-Id: Ia29775058017a9961b2c99c12bd058aaa59a030d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMerge RefineStatementSupport 94/94094/1
Robert Varga [Mon, 7 Dec 2020 20:10:53 +0000 (21:10 +0100)]
Merge RefineStatementSupport

RFC6020 and RFC7950 supports differ only in their substatement
validator. Fold the three classes into one, reducing the number of
classes we have.

Change-Id: Id678595129f4832374c1dea556101be479fc8b1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPick units from effective substatements 93/94093/1
Robert Varga [Mon, 7 Dec 2020 16:52:22 +0000 (17:52 +0100)]
Pick units from effective substatements

Use of StmtContext is completely unnecessary, as we already have access
to effective substatements, hence search those instead of the context.

JIRA: YANGTOOLS-1186
Change-Id: I10b6b97f83de28a22dd9b1c4637e28ab3f7ca4f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRepurpose DataNodeContainer.getDataChildByName() 87/94087/6
Robert Varga [Mon, 7 Dec 2020 09:41:59 +0000 (10:41 +0100)]
Repurpose DataNodeContainer.getDataChildByName()

Repurpose this method to return @NonNull and verify the child is
present. Also migrate tests to not assert the now-invariant.

JIRA: YANGTOOLS-1183
Change-Id: I7740af8fb8b57db5d840c0a758326a9cb44f635c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate getDataChildByName() users 86/94086/5
Robert Varga [Mon, 7 Dec 2020 09:24:48 +0000 (10:24 +0100)]
Migrate getDataChildByName() users

These users are using getDataChildByName() in its nullable capacity,
migrate them to dataChildByName().

JIRA: YANGTOOLS-1183
Change-Id: Id2cdf95804b1faf6189863de9f96253ab459ed6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRework NormalizedNode type hierarchy 13/93813/49
Robert Varga [Thu, 12 Nov 2020 18:01:30 +0000 (19:01 +0100)]
Rework NormalizedNode type hierarchy

Rework the NormalizedNode model to split identifier and value,
using overrides rather than generics. This cuts down complexity
quite a bit and makes the interface much more friendly.

This allows us to fix some of the sins in the overall NormalizedNode
hierarchy:

0) Use to generics is minimized:
- NormalizedNode, DataNodeContainer are no longer generic
- other constructs either gained or lost an argument, with losses
  being more prevalent.

1) yang.data.api.OrderingAware provides an explicit tie to order-by
   statement

2) NormalizedNodeContainer is split into two concepts:
- DistinctNodeContainer, allowing PathArgument lookups
- OrderedNodeContainer, allowing offset-based lookups and implying
  OrderingAware.User

3) MapNode is likewise split into two nodes based on Ordering:
- UserMapNode, which both DistinctNodeContainer and
  OrderedNodeContainer
- SystemMapNode, which is a plain OrderingAware.System
  DistinctNodeContainer

3) LeafSet follow the same split as MapNode

JIRA: YANGTOOLS-1022
Change-Id: I49c58850f565182826f5a8e1fc5b58cffb4a7d47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSelect copyPolicy for each StatementSupport class 50/94050/5
miroslav.kovac [Fri, 4 Dec 2020 14:54:14 +0000 (15:54 +0100)]
Select copyPolicy for each StatementSupport class

Since we want to minimaze amount of copping that we do
we need to set the appropriate copyPolicy for each
StatementSupport class separately

JIRA: YANGTOOLS-1164
Change-Id: I128bfb44a1dffb4620b2f8aec4fef6a953d85c89
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove findSubstatementArgument()/hasSubstatement() to BoundStmtCtx 78/94078/4
Robert Varga [Sun, 6 Dec 2020 12:49:28 +0000 (13:49 +0100)]
Move findSubstatementArgument()/hasSubstatement() to BoundStmtCtx

Since we have StmtContext and BoundStmtCtx unified, move
hasSubstatement() into BoundStmtCtx and implement it in
ReactorStmtCtx. This allows better access to this functionality.

JIRA: YANGTOOLS-1157
Change-Id: I33eaba254c82e4b8e0152c03d8da91fef4453f63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd UnqualifiedQName.tryCreate() 85/94085/2
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 agoMake DataNodeContainer.dataChildByName() non-default 81/94081/5
Robert Varga [Sun, 6 Dec 2020 16:19:41 +0000 (17:19 +0100)]
Make DataNodeContainer.dataChildByName() non-default

Switch implementations, so that we provide findDataChildByName()
as a default method and require a nullable lookup.

JIRA: YANGTOOLS-1183
Change-Id: I0e5ba2373b4ec6a4e1d6c8e7923e05954b2275c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCreate all effective statements path Nullable 20/94020/6
miroslav.kovac [Thu, 3 Dec 2020 13:36:10 +0000 (14:36 +0100)]
Create all effective statements path Nullable

Every effective statement that is saving path
may have this variable set to null if the
system property is set to forbid path.

JIRA: YANGTOOLS-1071
Change-Id: I7726f40f63f1bd2cf25cf2f8f85bf02826eb375e
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
3 years agoAdd DataNodeContainer.dataChildByName() 80/94080/2
Robert Varga [Sun, 6 Dec 2020 13:05:18 +0000 (14:05 +0100)]
Add DataNodeContainer.dataChildByName()

This is a non-deprecated equivalent of getDataChildByName(), allowing
easy migration of nullable users.

JIRA: YANGTOOLS-1183`
Change-Id: Iaf2336fdbfb6533fe759ea4a359b7458e20c79fe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix implementation nullness guarantees 79/94079/1
Robert Varga [Sun, 6 Dec 2020 16:16:39 +0000 (17:16 +0100)]
Fix implementation nullness guarantees

We are promising @NonNull in the contract, make sure implementations
do the same.

Change-Id: Ib895ffedc48c221ab4a98a4a318101bc3df46bc4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use StmtContext for ThirdPartyNamespace 75/94075/1
Robert Varga [Sat, 5 Dec 2020 16:14:13 +0000 (17:14 +0100)]
Do not use StmtContext for ThirdPartyNamespace

This is a simple demo/test, use the typical inference/build
argument passing pattern, eliminating the need to deal with nasty
rabbits.

Change-Id: I3783da94e110bac94a17f6e7db0d2086c1630d37
JIRA: YANGTOOLS-1186
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix AugmentImplicitHandlingNamespace 74/94074/1
Robert Varga [Sat, 5 Dec 2020 14:54:35 +0000 (15:54 +0100)]
Fix AugmentImplicitHandlingNamespace

We are dropping a simple marker for ourselves, hence make the namespace
keyed by Empty and only statementLocal.

JIRA: YANGTOOLS-1186
Change-Id: Ifd14cbe5f8ca22c29fad7efd039a73d4697441aa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not access TypeNamespace during build 73/94073/2
Robert Varga [Sat, 5 Dec 2020 13:31:04 +0000 (14:31 +0100)]
Do not access TypeNamespace during build

Rather than accessing TypeNamespace use a statement-local namespace
to store the reference to the type (which we ignored so far). This
allows us to wipe TypeNamespace when RootStatementContext is done.

JIRA: YANGTOOLS-1198
Change-Id: I017673ae6314f86ea4e9562a5072a7e7b2865649
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor YT838Test 72/94072/1
Robert Varga [Sat, 5 Dec 2020 13:34:30 +0000 (14:34 +0100)]
Refactor YT838Test

We are checking for thrown exceptions here, make use of assertThrows()
and hamcrest to make the reports more understandable.

Change-Id: Ia44be0835897300b86e7896cd7b441f7ccb8fb5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>