yangtools.git
3 years agoDo not synchronize around ReactorStmtCtx.schemaPath 51/94951/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>
3 years agoAdd Guava requires 31/94931/1
Robert Varga [Mon, 1 Feb 2021 11:28:48 +0000 (12:28 +0100)]
Add Guava requires

Eclipse is still not happy, take another step.

Change-Id: I0ba5aa38a9d07e87161e917caf3cf0064f2c753d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd @NonNull annotations 30/94930/1
Robert Varga [Mon, 1 Feb 2021 11:27:28 +0000 (12:27 +0100)]
Add @NonNull annotations

Identifier parsing returns always non-null, add corresponding
annotations.

Change-Id: I6b36c89bfe793ac487c434c9c97ab152e48297a7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSimplify SchemaContextUtil.findParentModule() 29/94929/3
Robert Varga [Mon, 1 Feb 2021 10:41:30 +0000 (11:41 +0100)]
Simplify SchemaContextUtil.findParentModule()

We are going through SchemaNode.getPath() only to acquire the last
component -- this is equivalent to SchemaNode.getQName(), so use
that.

Change-Id: I206d9cbdf9932f8ef4eb102eb2fa88660460aca3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use SchemaContext.get{Path,QName}() 28/94928/3
Robert Varga [Mon, 1 Feb 2021 10:30:18 +0000 (11:30 +0100)]
Do not use SchemaContext.get{Path,QName}()

We know the constants that are being used, use them directly rather
than through deprecated methods.

Change-Id: If3a0fcadf63332d97e9c70e8da790da295cc5a76
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd SchemaInfereceStack.schemaPathIterator() 27/94927/2
Robert Varga [Mon, 1 Feb 2021 10:22:10 +0000 (11:22 +0100)]
Add SchemaInfereceStack.schemaPathIterator()

There are a number of cases where inference logic operates on simple
progression of SchemaPath-coded QNames. Add a dedicated iterator to
side-step object creation.

JIRA: YANGTOOLS-1086
Change-Id: Ieda29ffa8b207bce275e6f7884de1c4edd3e3ab3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMinor update to yang-parser-reactor module-info 17/94917/1
Robert Varga [Mon, 1 Feb 2021 07:29:10 +0000 (08:29 +0100)]
Minor update to yang-parser-reactor module-info

Add concepts as suggested by Eclipse.

Change-Id: I4e4013d4896e29dd8e9df72c31eb9a3b65c3ee35
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd EffectiveStmtCtx.Parent documentation 13/94913/1
Robert Varga [Sun, 31 Jan 2021 21:13:10 +0000 (22:13 +0100)]
Add EffectiveStmtCtx.Parent documentation

We have a number of methods related to SchemaPath/QName handling
here, make sure we have correct interface contracts in place.

JIRA: YANGTOOLS-1071
Change-Id: I409390aef53be6556711e8bbbbe74adc7ed05909
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd QNameAwareData{Input,Output} 12/94912/1
Robert Varga [Sun, 31 Jan 2021 20:48:18 +0000 (21:48 +0100)]
Add QNameAwareData{Input,Output}

These interfaces codify what the binfmt codec exposes in a way
more consumable by general audiences. This results in better
(and incompatible) enconding of QName-over-binfmt when the driver
is QName.writeTo().

JIRA: YANGTOOLS-1217
Change-Id: Ic3bee51538df1d51b4dd7663316ce6056590c45c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor EffectiveStmtCtx.Parent.schemaPath() 11/94911/1
Robert Varga [Sun, 31 Jan 2021 19:51:54 +0000 (20:51 +0100)]
Refactor EffectiveStmtCtx.Parent.schemaPath()

A @Nullable return is more suited to our needs, following our
normal imperative speak.

JIRA: YANGTOOLS-1071
Change-Id: I135c10d83ef2a53453f0278779157cdef20d14a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix UnrecognizedStatementSupport.qnameFromArgument() defensiveness 10/94910/1
Robert Varga [Sun, 31 Jan 2021 16:49:35 +0000 (17:49 +0100)]
Fix UnrecognizedStatementSupport.qnameFromArgument() defensiveness

We are trying hard to fudge a QName here. If we encounter something
akin to "foo:foo = bar:'baz = xyzzy'", we will have an obviously
wrong local name. Give up at that point cleanly without throwing
an IAE.

Change-Id: I9b4235706dd39f0b41b73337ab57328c1ae6f515
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix uses-refine statement reference counting 09/94909/1
Robert Varga [Sun, 31 Jan 2021 16:32:16 +0000 (17:32 +0100)]
Fix uses-refine statement reference counting

When a statement is being added as a substatement, it is the caller's
responsibility to ensure proper refcount is kept.

UsesStatementSupport.addOrReplaceNode() failed to create a replica,
which resulted in an InferredStatementContext containing a
SubstatementContext -- which logically should never happen.

This issue has been there for quite some time, but was masked by
eager context instantiation. Fix it by acquiring a replicaAsChildOf(),
just as other callers of addEffectiveSubstatement() do.

JIRA: YANGTOOLS-1208
Change-Id: I88aa1009a64a4fb6df9138f748877836bfddd175
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd CopyPolicy.EXACT_REPLICA 08/94908/2
Robert Varga [Sun, 31 Jan 2021 12:44:02 +0000 (13:44 +0100)]
Add CopyPolicy.EXACT_REPLICA

There is a slight difference in copy handling of 'type' statement
after conversion to CONTEXT_INDEPENDENT -- as that policy ends up
being also affected by substatements, which is not correct.

Add CopyPolicy.EXACT_REPLICA, which forces the reactor do disregard
any substatements' conflicting policy.

JIRA: YANGTOOLS-1208
Change-Id: Ib000edf416b706d0c9f3f4c9f292c9b971092c31
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate SchemaPath.getPath() implementation 07/94907/5
Robert Varga [Sat, 30 Jan 2021 22:13:50 +0000 (23:13 +0100)]
Update SchemaPath.getPath() implementation

SchemaNode implementations are using SchemaPath to hold their QName
as well, hence we cannot just ditch it. Update the wrapping mechanism
to support dual QName/SchemaPath storage.

JIRA: YANGTOOLS-1071
Change-Id: Ide9a6957571ea5933dfb21e4aa4d97e0c9919291
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd statement sharing for leaf statements 96/94896/10
Robert Varga [Sat, 30 Jan 2021 13:29:46 +0000 (14:29 +0100)]
Add statement sharing for leaf statements

Add the basic infrastructure to handle statement copying. This will
allow us to improve type definition sharing in future.

JIRA: YANGTOOLS-1213
Change-Id: I6e10877971902540bb448359baf0444d61993255
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use TypeDefinition copying just yet 06/94906/1
Robert Varga [Sat, 30 Jan 2021 20:38:47 +0000 (21:38 +0100)]
Do not use TypeDefinition copying just yet

The conditions under which it is safe to copy a typedefinition
are not clear. Revert that bit and let's do a simultaneous conversion
with leaf.

JIRA: YANGTOOLS-1208
Change-Id: Ia4178cd621bc739c3ad2870646fdae0b818065a9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRework base type lookup 95/94895/7
Robert Varga [Sat, 30 Jan 2021 12:50:32 +0000 (13:50 +0100)]
Rework base type lookup

Rather than performing two string-based lookups, populate
BaseTypeNamespace with BuiltinEffectiveStatement. This allows
for better expressiveness, as inference-based logic is done
before we build effective statement.

JIRA: YANGTOOLS-1208
Change-Id: I49ff3383da93a7469172bc4ebbb0e7c62b09bb5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix leaf-list statement original propagation 92/94892/4
Robert Varga [Wed, 27 Jan 2021 15:12:47 +0000 (16:12 +0100)]
Fix leaf-list statement original propagation

We must not forget to propagate the statement's original definition
when copying an empty statement. Also take advantage of copy facilities
in leaf statement.

JIRA: YANGTOOLS-1208
Change-Id: I11a84ffe5226951ab34df91b9e9da665cc315c03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix list statement original propagation 93/94893/2
Robert Varga [Sat, 30 Jan 2021 11:19:15 +0000 (12:19 +0100)]
Fix list statement original propagation

We must not forget to propagate the statement's original definition
when copying an empty statement.

JIRA: YANGTOOLS-1208
Change-Id: I0f6b9dbd7a4cc1f5345c76cc0b53d006a7f7561c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd support for rebinding type definitions 43/94843/10
Robert Varga [Wed, 27 Jan 2021 15:12:47 +0000 (16:12 +0100)]
Add support for rebinding type definitions

In order to rebase TypeDefinition efficiently we need a factory
when can just switch the name of a definition. Define a new interface,
TypeDefinitionBinder and implement it by all yang-model-util types.

This allows them to perform an efficient copy instead of a full
rebuild -- a facility used for leaf-lists.

JIRA: YANGTOOLS-1213
Change-Id: I366743dab1faa6f8349fdd0fe8f5d65558ca40e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse instantiatedPolicy() in list statement 89/94889/4
Robert Varga [Fri, 29 Jan 2021 21:03:32 +0000 (22:03 +0100)]
Use instantiatedPolicy() in list statement

This conversion turns out to be quite simple, but don't forget
to add tests.

JIRA: YANGTOOLS-1208
Change-Id: I39071d4147b679dc88d132e37fa65fe5a202e199
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse instantiatedPolicy() for leaf-list statements 88/94888/4
Robert Varga [Fri, 29 Jan 2021 20:49:31 +0000 (21:49 +0100)]
Use instantiatedPolicy() for leaf-list statements

The statements are not bringing much to the table, make sure we
use the appropriate policy.

JIRA: YANGTOOLS-1208
Change-Id: I13351a46ef4ed254465ec6f74c5294e1ff540890
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd proper StatementPolicy for 'augment' 39/94839/6
Robert Varga [Wed, 27 Jan 2021 11:28:51 +0000 (12:28 +0100)]
Add proper StatementPolicy for 'augment'

Augment's behaviour is rather simple, add proper reuse checks.
Also add a test case to check reuse.

JIRA: YANGTOOLS-1208
Change-Id: I65b154a3ca50c26d876066b347b9e722d4f45608
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a proper statement policy for 'mount-point' 84/94884/2
Robert Varga [Fri, 29 Jan 2021 13:34:01 +0000 (14:34 +0100)]
Add a proper statement policy for 'mount-point'

A bit of the policy is dictated by UnknownSchemaNode, but otherwise
this is quite simple.

JIRA: YANGTOOLS-1208
Change-Id: I81f4bb5aac5f530e3fcc293b495e1bc76a6b3f8a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSplit out MountPointEffectiveStatementImpl 83/94883/1
Robert Varga [Fri, 29 Jan 2021 13:24:46 +0000 (14:24 +0100)]
Split out MountPointEffectiveStatementImpl

Moving the effective statement implementation makes it easier to
reason what should be taken care of when. Also reduce reliance on
SchemaPath.

JIRA: YANGTOOLS-1208
Change-Id: I3b96322fb3b0dc4b7283dccd71304a3e28f025f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove ModelDefinedStatementSupport 82/94882/1
Robert Varga [Fri, 29 Jan 2021 13:11:49 +0000 (14:11 +0100)]
Remove ModelDefinedStatementSupport

This is just a forwarder on top of UnrecognizedStatementSupport,
use that directly.

JIRA: YANGTOOLS-1208
Change-Id: I8b9455a5b14e024019ff33496fe3568f6a03c738
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse AbstractStringStatementSupport for type supports 79/94879/2
Robert Varga [Fri, 29 Jan 2021 09:27:08 +0000 (10:27 +0100)]
Use AbstractStringStatementSupport for type supports

We know we are context-independent and we are using the same
argument parsing (non-)logic, hence change the support class we
are basing off of.

JIRA: YANGTOOLS-1208
Change-Id: If1f44b98a6aa9345450e3570c71f30971f3128f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove a stray FIXME 77/94877/1
Robert Varga [Fri, 29 Jan 2021 08:05:09 +0000 (09:05 +0100)]
Remove a stray FIXME

This was noted in code review, remove it.

JIRA: YANGTOOLS-1208
Change-Id: Ic3ec2d2452bd75ed9de0b944da90495f65e4f229
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove original statement access 71/94871/1
Robert Varga [Thu, 28 Jan 2021 21:34:43 +0000 (22:34 +0100)]
Move original statement access

We do not need the reference until we build the statement, move
the declaration for clarity.

Change-Id: I9af9a28423d349d2174bc6944308ae0ea4e7d676
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse instantiatedPolicy() for choice statement 50/94850/6
Robert Varga [Wed, 27 Jan 2021 19:26:51 +0000 (20:26 +0100)]
Use instantiatedPolicy() for choice statement

Choice has some initial value handling, but afterwards it really
boils down to a simple schema tree statement. Convert it to use
a common policy.

JIRA: YANGTOOLS-1208
Change-Id: I213948f1dd5230aa1ce5d7a6becb48bb2815b67a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoYangStmtMapping.TYPEDEF implies StatementPolicy.contextIndependent() 69/94869/2
Robert Varga [Thu, 28 Jan 2021 21:00:15 +0000 (22:00 +0100)]
YangStmtMapping.TYPEDEF implies StatementPolicy.contextIndependent()

As it turns out we have a few legacy filtering places, which use
explicit type mapping. The end effect of these is to render TYPEDEF
context-independent.

JIRA: YANGTOOLS-1208
Change-Id: I73f53ae54221d2911ccfb4b54d5d32f72d158a3a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoYangStmtMapping.TYPE implies StatementPolicy.contextIndependent() 68/94868/2
Robert Varga [Thu, 28 Jan 2021 20:44:33 +0000 (21:44 +0100)]
YangStmtMapping.TYPE implies StatementPolicy.contextIndependent()

InferredStatementContext has an explicit guard to get replicas of
statements which are YangStmtMapping.TYPE. This amounts to those
statements being context-independent. Express that fact in the
policy.

This exposes an issue with 'base' statements, which in fact can
be considered for copying and are really context-indepenent, not
uncopyable.

JIRA: YANGTOOLS-1208
Change-Id: I49f0454ad11a029d217bd7fb70d23e315f37072c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefactor AbstractTypeStatementSupport.typeEffectiveQName() 66/94866/2
Robert Varga [Thu, 28 Jan 2021 18:25:10 +0000 (19:25 +0100)]
Refactor AbstractTypeStatementSupport.typeEffectiveQName()

We are performing a very specific operation at very fishy time.
Isolate the question we are asking away from SchemaPath.

JIRA: YANGTOOLS-1213
Change-Id: Iad0536a8f67d2451b25827707be5a3548b01532b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove Current.argumentAsTypeQName() implementation 59/94859/1
Robert Varga [Thu, 28 Jan 2021 17:50:26 +0000 (18:50 +0100)]
Move Current.argumentAsTypeQName() implementation

This method really is a contract for 'type' statement supports,
let's shortcut it to its basic so that we can factor it out
without the intermediate steps.

JIRA: YANGTOOLS-1216
Change-Id: If7fab18450310f8f873881365fcba24d620eb43b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove SchemaPath from TypeDefinition implementations 57/94857/9
Robert Varga [Thu, 28 Jan 2021 11:09:45 +0000 (12:09 +0100)]
Remove SchemaPath from TypeDefinition implementations

This necessitates disabling string-based PathExpression evaluation,
which is going away anyway.

JIRA: YANGTOOLS-1216
JIRA: YANGTOOLS-1127
Change-Id: Ic033019dfa44b633e23d3a5b90eadc131adb0904
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a simple requires 56/94856/1
Robert Varga [Thu, 28 Jan 2021 11:10:44 +0000 (12:10 +0100)]
Add a simple requires

Eclipse again, yang-model-util obviously needs yang-common.

Change-Id: I431184e502d1a6842b26eae21f13d216ba025f15
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAllow derived context to be reused 29/94829/8
Robert Varga [Tue, 26 Jan 2021 22:45:01 +0000 (23:45 +0100)]
Allow derived context to be reused

Passing the previously-built instance is a boon, as we can skip
re-creation of schema/data tree namespaces and instread just share
the maps.

As a matter of establishing a baseline the following statements are
also converted:
- action
- case
- container
- nofitication
- input
- output

Other statements will be updated in follow-up patches.

JIRA: YANGTOOLS-1213
Change-Id: Ic969fdf32932716ad18761f4da47ec41c3d07f2c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCase statement has instantiated schema tree policy 47/94847/2
Robert Varga [Wed, 27 Jan 2021 17:51:16 +0000 (18:51 +0100)]
Case statement has instantiated schema tree policy

Case statement does not do anything special convert it and add
a reuse test case.

JIRA: YANGTOOLS-1208
Change-Id: I9b4ec0311c14a091896678b39a3f21e260064d97
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a proper grouping statement policy 37/94837/7
Robert Varga [Wed, 27 Jan 2021 10:54:58 +0000 (11:54 +0100)]
Add a proper grouping statement policy

A grouping is very similar to an uninstantiated statement, yet it
is a bit more loose. Add a proper StatementPolicy to cover its
mechanics.

JIRA: YANGTOOLS-1208
Change-Id: I79eb18766be252fd4b163e8a51653621585127a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert leaf statement to instantiatedPolicy() 33/94833/7
Robert Varga [Wed, 27 Jan 2021 08:37:21 +0000 (09:37 +0100)]
Convert leaf statement to instantiatedPolicy()

Leaf statements are not doing anything out of the ordinary, just
the routine instantiated schema three thing. Switch their policy
and add a unit test.

JIRA: YANGTOOLS-1208
Change-Id: I5e38765e76cf8be422f05e6b779ffd54519d6b61
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd Current.equalParentPath() 34/94834/7
Robert Varga [Wed, 27 Jan 2021 09:20:48 +0000 (10:20 +0100)]
Add Current.equalParentPath()

This check needs to be controlled by the reactor, hence move it
from BaseSchemaTreeStatementSupport to EffectiveStmtCtx.Current
as a default equalParentPath() method.

JIRA: YANGTOOLS-1208
Change-Id: I445789e9442db92b8081baad144f269ed14c35af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
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)