yangtools.git
3 years agoImprove SchemaInferenceStack.enterSchemaTree() 24/95124/2
Robert Varga [Wed, 10 Feb 2021 16:40:41 +0000 (17:40 +0100)]
Improve SchemaInferenceStack.enterSchemaTree()

We can guarantee a return of SchemaTreeEffectiveStatement, make
sure we show that to the users, allowing their dispatch to be
more neatly bracketed.

JIRA: YANGTOOLS-1231
Change-Id: If805a2a612c23157422bea717f9dfada9ac0f093
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse SchemaContextUtils replacements in yang-data-codec-xml 23/95123/1
Robert Varga [Wed, 10 Feb 2021 16:27:26 +0000 (17:27 +0100)]
Use SchemaContextUtils replacements in yang-data-codec-xml

We are performing rather simple searches, use the functionality
built into DataNodeContainer. Also modernize assertions while we
are in the area.

JIRA: YANGTOOLS-1052
Change-Id: Id3a9a49b80946db4d03f13ecf6fe19e46660e479
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCleanup MultipleRevImportBug6875Test 22/95122/1
Robert Varga [Wed, 10 Feb 2021 16:12:17 +0000 (17:12 +0100)]
Cleanup MultipleRevImportBug6875Test

Do not use SchemaContextUtils for simple lookups and also update
assertions.

JIRA: YANGTOOLS-1052
Change-Id: I236664815b322510852c2c2721b15525d18e4065
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClean up SchemaContextFactoryDeviationsTest 21/95121/1
Robert Varga [Wed, 10 Feb 2021 16:02:37 +0000 (17:02 +0100)]
Clean up SchemaContextFactoryDeviationsTest

We are being overly verbose here and use SchemaContextUtil for
functionality readily available. Clean up the test, removing yet
another user of SchemaContextUtil.

JIRA: YANGTOOLS-1052
Change-Id: I4145e3d715cd1a2f524a892c178719f178d96e07
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClean up Bug3874ExtensionTest 20/95120/1
Robert Varga [Wed, 10 Feb 2021 15:49:45 +0000 (16:49 +0100)]
Clean up Bug3874ExtensionTest

We are using SchemaContextUtil for no good reason, migrate away
and cleanup assertions.

JIRA: YANGTOOLS-1052
Change-Id: Ib2d56d5155d66a974cc92415a18627bdde3518d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove Bug5437Test to yang-model-util-ut 19/95119/1
Robert Varga [Wed, 10 Feb 2021 15:44:09 +0000 (16:44 +0100)]
Move Bug5437Test to yang-model-util-ut

This is pure UT for yang-model-util, rehost it and rename it to
new parlance -- YT588Test.

JIRA: YANGTOOLS-1052
Change-Id: I517ea393005d6ba16d5bcf6c4fc9ffe95b6a7e20
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClean up yang-parser-rfc7950 tests 17/95117/3
miroslav.kovac [Wed, 10 Feb 2021 12:05:56 +0000 (13:05 +0100)]
Clean up yang-parser-rfc7950 tests

Refactor using newer asserts and concepts, eliminating the use
of SchemaContextUtil.

JIRA: YANGTOOLS-1052
Change-Id: I6918a95fd4d1aec964cd5f80796305e73654345a
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
3 years agoDo not use SchemaNode.getPath() in XmlParserStream 15/95115/3
Robert Varga [Wed, 10 Feb 2021 13:56:19 +0000 (14:56 +0100)]
Do not use SchemaNode.getPath() in XmlParserStream

We are using getPath() only for diagnostic purposes. Log/append
only parentSchema instead.

JIRA: YANGTOOLS-1228
Change-Id: I304424ad419dee4d3ff2167eeece325cfd5745fc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix missing location in error reports 14/95114/3
Robert Varga [Wed, 10 Feb 2021 13:51:13 +0000 (14:51 +0100)]
Fix missing location in error reports

There are two places where we fail to propagate location:
- one is a pure omission
- one is a case of bad format
Fix both sites, improving our error reporting.

Change-Id: I65b52c69a6d6d7bb0fd8a9bc3956a2dab51d81c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove SchemaUtils.findParentSchemaNodesOnPath() 13/95113/2
Robert Varga [Wed, 10 Feb 2021 13:03:07 +0000 (14:03 +0100)]
Remove SchemaUtils.findParentSchemaNodesOnPath()

These methods are not used anywhere except tests, remove them now.

JIRA: YANGTOOLS-1230
Change-Id: I3ca3d7bd7bf1e6f27fea634ee138d3f1769e5666
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse SchemaInferenceStack in SchemaOrderedNormalizedNodeWriter 12/95112/2
Robert Varga [Wed, 10 Feb 2021 12:53:43 +0000 (13:53 +0100)]
Use SchemaInferenceStack in SchemaOrderedNormalizedNodeWriter

SchemaOrderedNormalizedNodeWriter's use of SchemaUtils is rather
straightforward, let's migrate it to SchemaInferenceStack.

JIRA: YANGTOOLS-1230
Change-Id: I9b17d0f9f737df7127a48d7cd60dae0a2b2b594f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConvert SchemaTracker to use SchemaInferenceStack 11/95111/4
Robert Varga [Wed, 10 Feb 2021 10:43:47 +0000 (11:43 +0100)]
Convert SchemaTracker to use SchemaInferenceStack

SchemaTracker's users always expect an instantiated path, for which
SchemaInferenceStack is much more efficient than SchemaNodeUtils.

JIRA: YANGTOOLS-1230
Change-Id: I24edb3595b5dab936790d4f5d77ecdcded1a1b1e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd SchemaInferenceStack utility factory methods 08/95108/1
Robert Varga [Wed, 10 Feb 2021 10:07:39 +0000 (11:07 +0100)]
Add SchemaInferenceStack utility factory methods

A number of users of yang.model.api use some form of addressing,
this is related either to SchemaNodeIdentifier or SchemaPath. These
users can benefit from SchemaInferenceStack -- but would have to
duplicate code to correctly initialize it.

Add two factory methods to create a new SchemaInferenceStack.

JIRA: YANGTOOLS-1086
Change-Id: I3006e5d74d239eb6bc96e148521148c579fb5811
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRevert "Add support for rebinding type definitions" 04/95104/1
Robert Varga [Wed, 10 Feb 2021 07:09:56 +0000 (08:09 +0100)]
Revert "Add support for rebinding type definitions"

This reverts commit ad603ee9df18aee0e58d83ae207846c8b9bd0d58, as
the rules for how copying needs to work are not clear and this
facility is not used.

JIRA: YANGTOOLS-1213
Change-Id: Ibbcc2a1ca40ceaaf0baaf58b07b275a359fad8bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove model.spi.type.CompatUtils 03/95103/2
Robert Varga [Wed, 10 Feb 2021 07:06:57 +0000 (08:06 +0100)]
Remove model.spi.type.CompatUtils

Minute differences between how TypeDefinitions work are interesting
only for MD-SAL's binding. Remove CompatUtils and let MD-SAL do its
own thing.

JIRA: YANGTOOLS-1216
Change-Id: I9d956f53e877a5e2306f831142467f30db296233
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove ContactStatement implementations 01/95101/1
Robert Varga [Tue, 9 Feb 2021 21:44:05 +0000 (22:44 +0100)]
Move ContactStatement implementations

These have been missed in the previous mass migration, correct
that mistake.

JIRA: YANGTOOLS-1052
Change-Id: Ibb36b7373b2db198eea2fcb2c791523ec6eadaa2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove declared statements to their own package 00/95100/1
Robert Varga [Tue, 9 Feb 2021 20:56:52 +0000 (21:56 +0100)]
Move declared statements to their own package

Add model.spi.stmt.impl.decl, which is an unexported package, and
host declared statement implementations.

JIRA: YANGTOOLS-1052
Change-Id: Ia8894ff9c81cc28db81ff1caa015237d35f4d1fc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove model.util.RegexUtils 91/95091/4
Robert Varga [Tue, 9 Feb 2021 13:33:30 +0000 (14:33 +0100)]
Move model.util.RegexUtils

These utilities are used only by PatternStatementSupport, move them
there to reduce yang-parser-rfc7950 dependencies.

JIRA: YANGTOOLS-1052
Change-Id: I3a039c4d96b296e8fd3f71c248221ff9b815997e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove yang-data-jaxen 95/95095/2
Robert Varga [Tue, 9 Feb 2021 17:14:12 +0000 (18:14 +0100)]
Remove yang-data-jaxen

This has been a prototype, whose API and performance characteristics
that are not acceptable. Remove it and we will start from scratch
around yang-xpath-api.

JIRA: YANGTOOLS-1227
Change-Id: I5c2a7f427d165a390eff4291eefc3130f9841997
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCleanup more tests 93/95093/2
Robert Varga [Tue, 9 Feb 2021 15:36:22 +0000 (16:36 +0100)]
Cleanup more tests

Bug6876Test, Bug6884Test and Bug6335Test are very simple,
modernize them, eliminating dependencies on SchemaContextUtil.

JIRA: YANGTOOLS-1052
Change-Id: If16de321a712996728df0236795d1d62ee6edd8b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoModernize Bug6869Test, Bug6880Test 92/95092/2
Robert Varga [Tue, 9 Feb 2021 14:25:39 +0000 (15:25 +0100)]
Modernize Bug6869Test, Bug6880Test

Refactor using newer asserts and concepts, eliminating the use
of SchemaContextUtil.

JIRA: YANGTOOLS-1052
Change-Id: I34a66ae98cb64e499c844d11d9edb27a1552e08c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove an unneeded yang-model-util dependency 90/95090/2
Robert Varga [Tue, 9 Feb 2021 13:06:31 +0000 (14:06 +0100)]
Remove an unneeded yang-model-util dependency

yang-model-export only requires yang-model-api, nothing else.

JIRA: YANGTOOLS-1052
Change-Id: Id4b983c9882e8bc98b0cc1995f1b0523e22f0156
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove AbstractPathExpression to yang-model-spi 89/95089/2
Robert Varga [Tue, 9 Feb 2021 13:04:09 +0000 (14:04 +0100)]
Move AbstractPathExpression to yang-model-spi

A very simplistic base class for implementations. It should not
live in yang-model-util.

JIRA: YANGTOOLS-1052
Change-Id: I8794b64d8ad3572c898c8b944354c99d8ba63aa3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove BaseConstraints 88/95088/3
Robert Varga [Tue, 9 Feb 2021 12:13:17 +0000 (13:13 +0100)]
Remove BaseConstraints

This utility is not used anywhere, remove it.

JIRA: YANGTOOLS-1052
Change-Id: Idfd4ece09d329f5bc14e12f9b192fe765206e824
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove more implementation classes to yang-model-spi 87/95087/4
Robert Varga [Tue, 9 Feb 2021 11:47:21 +0000 (12:47 +0100)]
Move more implementation classes to yang-model-spi

AbstractSchemaContext as well as AbstractEffectiveModelContextProvider
are really baseline implementation classes, move them.

JIRA: YANGTOOLS-1052
Change-Id: I2e68cd53fff00c2ee322a6045bf029b46921c2a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFinish declared statement migration 85/95085/2
Robert Varga [Tue, 9 Feb 2021 01:05:59 +0000 (02:05 +0100)]
Finish declared statement migration

This is final step of getting declared statements out of
yang-parser-rfc7950.

JIRA: YANGTOOLS-1226
Change-Id: Id6212df2def83a856b55d8199e133bf8839bde5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote more declared statements to yang-parser-spi 84/95084/1
Robert Varga [Tue, 9 Feb 2021 00:25:24 +0000 (01:25 +0100)]
Promote more declared statements to yang-parser-spi

Declared statements are extremely simplistic, move their RFC7950
implementations to yang-model-spi. This is the second batch of
conversion, with more to follow.

JIRA: YANGTOOLS-1226
Change-Id: I9ca7a8af5c4a98fc1a6afc09e5b8b65434f9f1c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote declared statements to yang-parser-spi 83/95083/2
Robert Varga [Mon, 8 Feb 2021 21:24:05 +0000 (22:24 +0100)]
Promote declared statements to yang-parser-spi

Declared statements are extremely simplistic, move their RFC7950
implementations to yang-model-spi. This is the first batch of
conversion, with more to follow.

JIRA: YANGTOOLS-1226
Change-Id: I49b7840cfa6395496db3475853230c527bd252ec
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote AbstractDeclaredEffectiveStatement 82/95082/2
Robert Varga [Mon, 8 Feb 2021 20:54:10 +0000 (21:54 +0100)]
Promote AbstractDeclaredEffectiveStatement

This is a useful implementation base class. Make it more widely
available in yang-model-spi. This also allows us to hide
AbstractEffectiveStatement, as it should never be subclassed
directly.

JIRA: YANGTOOLS-1225
Change-Id: I68103d63ea1b73dfadf2f1eb98cfeba022053260
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSplit out AbstractDataNodeContainer 81/95081/1
Robert Varga [Mon, 8 Feb 2021 20:42:04 +0000 (21:42 +0100)]
Split out AbstractDataNodeContainer

This class is an outlier as it is really only subclassed once and
relies on Mixins. Let's split it out first and deal with it later.
Its use of Mixins certainly makes is special enough to make it a
non-nested class.

JIRA: YANGTOOLS-1225
Change-Id: I6badd7a19ad6bd7c66a36043420e2e20d0c5ff25
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote AbstractUndeclaredEffectiveStatement 80/95080/2
Robert Varga [Mon, 8 Feb 2021 20:29:27 +0000 (21:29 +0100)]
Promote AbstractUndeclaredEffectiveStatement

This is a useful implementation base class. Make it more widely
available in yang-model-spi.

JIRA: YANGTOOLS-1225
Change-Id: Ib450286a5fe8c90bbbaf26247feb3093982ba39a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUnrecognizedEffectiStatement is declared 79/95079/1
Robert Varga [Mon, 8 Feb 2021 20:23:56 +0000 (21:23 +0100)]
UnrecognizedEffectiStatement is declared

While we never instantiate this statement, it is clearly always
declared, hence use a better superclass.

JIRA: YANGTOOLS-1225
Change-Id: I4679066d809874b28082b29f61856bd3687c42cd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote AbstractEffectiveStatement to model-spi 78/95078/1
Robert Varga [Mon, 8 Feb 2021 20:19:06 +0000 (21:19 +0100)]
Promote AbstractEffectiveStatement to model-spi

This is a useful common implementation class, make it more widely
accessible.

JIRA: YANGTOOLS-1225
Change-Id: Ie2f7ccdf787dc1b7c0283c11ddbbfd910bac5da1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove yang.parser.spi.meta.AbstractDeclaredStatement 77/95077/1
Robert Varga [Mon, 8 Feb 2021 20:03:00 +0000 (21:03 +0100)]
Remove yang.parser.spi.meta.AbstractDeclaredStatement

A lower-footprint competitor was promoted to yang-model-spi, rendering
this class useless. Remove it to make yang-parser-spi split up simpler
and prevent potential confusion.

JIRA: YANGTOOLS-1150
Change-Id: If67ac9e5b378583ab1446f62e0b0028e86b499d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote AbstractDeclaredStatement to model-spi 76/95076/1
Robert Varga [Mon, 8 Feb 2021 20:01:15 +0000 (21:01 +0100)]
Promote AbstractDeclaredStatement to model-spi

This is a useful common implementation class, make it more widely
accessible.

JIRA: YANGTOOLS-1225
Change-Id: I7b92dcd1608c57b7b63ba8036a2db5c4a82d9859
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote AbstractModelStatement to model-spi 75/95075/1
Robert Varga [Mon, 8 Feb 2021 19:53:03 +0000 (20:53 +0100)]
Promote AbstractModelStatement to model-spi

This is a useful common implementation class, make it more widely
accessible.

JIRA: YANGTOOLS-1225
Change-Id: I4f04df2063545e7f20fa0d4a0795c4bf5d2a2ebd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoModernize MoreRevisionsTest 74/95074/1
Robert Varga [Mon, 8 Feb 2021 19:34:12 +0000 (20:34 +0100)]
Modernize MoreRevisionsTest

Refactor using newer asserts and concepts, eliminating the use
of SchemaContextUtil.

JIRA: YANGTOOLS-1052
Change-Id: Ia446b596a0cdec4b6e466a395184aa7ecbfb6443
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoModernize Bug6870Test 72/95072/2
Robert Varga [Mon, 8 Feb 2021 19:19:05 +0000 (20:19 +0100)]
Modernize Bug6870Test

Perform a long-overdue cleanup, improving assertions and eliminating
the need for SchemaContextUtil.

JIRA: YANGTOOLS-1052
Change-Id: I24e8bfe62509e12a4158a99c673ff182bd5c2240
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSeed yang-model-spi with model.util.type 70/95070/2
Robert Varga [Mon, 8 Feb 2021 16:26:15 +0000 (17:26 +0100)]
Seed yang-model-spi with model.util.type

Move TypeDefinition implementation into a newly-created artifact,
yang-model-spi. This is the second step if untangling the
parser-rfc7950/model-util dependency conundrum.

JIRA: YANGTOOLS-1052
Change-Id: I3282d730ae2517efb8edc3f46bdc39d135677790
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove yang.model.util.BaseTypes 71/95071/3
Robert Varga [Mon, 8 Feb 2021 17:06:40 +0000 (18:06 +0100)]
Remove yang.model.util.BaseTypes

The only thing used from this class are the QName constants. Disperse
them among their respective TypeDefinition specialications, eliminating
the need for a centralized place. This is the first step in resolving
model-util/parser-rfc7950 dependency conundrum.

JIRA: YANGTOOLS-1052
Change-Id: Ib69814bb872ccd327e577e1efe83e9510288c025
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate xpath-api/model-util module-info.java 67/95067/1
Robert Varga [Mon, 8 Feb 2021 13:32:02 +0000 (14:32 +0100)]
Update xpath-api/model-util module-info.java

We are using spotbugs, make sure we depend on them.

Change-Id: Icf82f74e83ae2406c125ad4df9b28020d3ce999b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoShort-circuit statement reuse 35/94735/17
Robert Varga [Tue, 26 Jan 2021 20:52:13 +0000 (21:52 +0100)]
Short-circuit statement reuse

When all substatements end up being context-independent and we do
not have an incoming reference, we can effieciently side-step creation
of replicas.

JIRA: YANGTOOLS-1223
Change-Id: Ic50e21e793d16d35170ce95561ec4e3f68cc6ef1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd XMLNamespace 64/95064/7
Robert Varga [Sun, 7 Feb 2021 17:56:28 +0000 (18:56 +0100)]
Add XMLNamespace

java.net.URI is a rather bad fit our purposes. We really need a
simplistic String container, without the need to have it parsed out
into a complex structure.

Introduce XMLNamespace and mass-migrate all users of URI.

JIRA: YANGTOOLS-1141
Change-Id: I87d9fa85f078aa0fa0d29d1e1b118094d51cfc5e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd derived statement cache 18/94918/24
Robert Varga [Mon, 1 Feb 2021 07:29:49 +0000 (08:29 +0100)]
Add derived statement cache

A single ReactorStmtCtx may have multiple derived
InferredStatementContexts from it, each resulting in a statement
which is different from the statement produced by the original,
while also being the same among themselves.

This happens actually quite often, since typical schema tree
participants record their copy history as well as well as
effectiveConfig, which is different between defining grouping
and instantiation place.

This mechanics is driven via individual implementation opt-ins,
with SchemaTree being the most significant user.

JIRA: YANGTOOLS-1214
Change-Id: Ie3163e5a7fa8c5cfdfb670102deca7cb22b0d935
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoIntern contact/organization/reference arguments 62/95062/3
Robert Varga [Sun, 7 Feb 2021 15:16:28 +0000 (16:16 +0100)]
Intern contact/organization/reference arguments

These tend to repeat with multiple models, make sure we deduplicate
them if possible.

JIRA: YANGTOOLS-652
Change-Id: Ieed8acb9fa12e4302e44b9fc32ed1f96bedab57b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove an unneede throws 61/95061/1
Robert Varga [Sun, 7 Feb 2021 15:03:37 +0000 (16:03 +0100)]
Remove an unneede throws

We are not throwing ExecutionException, let's not mention it.

Change-Id: I12c334396d6fbd8819d2dca6e7082aabb81a4e3b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not instantiate transient replicas 60/95060/3
Robert Varga [Sun, 7 Feb 2021 12:23:26 +0000 (13:23 +0100)]
Do not instantiate transient replicas

Refactor ReactorStmtCtx.haveRef() into an accurate noRefs(), taking
parents into account. If we do not have such a reference, use a new
substatement sentinel instead of a full list.

JIRA: YANGTOOLS-1223
Change-Id: I4ed132d36b1006bfe3ee650cbef6efb4c88cb8d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRedirect BoundStmtCtx search methods to effective instances 59/95059/1
Robert Varga [Sun, 7 Feb 2021 13:16:42 +0000 (14:16 +0100)]
Redirect BoundStmtCtx search methods to effective instances

BoundStmtCtx.{findSubstatementArgument,hasSubstatement}() methods
have the same sematics as
EffectiveStatement.findSubstatement(Argument)() provide.

Bridge to these methods if we have an effective instance, is it has
the most accurate view of things.

JIRA: YANGTOOLS-1222
Change-Id: Ic9ec79422ed340692241ce1514b40b9d1b918409
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove unnecessary check 58/95058/2
Robert Varga [Sun, 7 Feb 2021 12:19:25 +0000 (13:19 +0100)]
Remove unnecessary check

ensureEffectiveSubstatements() already performs an access check,
hence streamEffective() does not need to do so before calling it.

Change-Id: I407e56dd36f695aeb6204869a5e446df26e1449f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use BigInteger in 'range' argument 56/95056/1
Robert Varga [Sun, 7 Feb 2021 11:04:23 +0000 (12:04 +0100)]
Do not use BigInteger in 'range' argument

The only production allowed here is 'integer-value', which is
logically clamped to int64/uint64 range. Use Long/Uint64 to represent
these, so that we lower our memory footprint.

JIRA: YANGTOOLS-1206
Change-Id: I1d186d0ed0211ac0fa996fe93d6cd7aa28442520
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse Uint64 for 'length' argument 55/95055/1
Robert Varga [Sun, 7 Feb 2021 10:20:21 +0000 (11:20 +0100)]
Use Uint64 for 'length' argument

RFC6020/7950 place an upper bound on the integral size of length
argument -- explictly calling out that an implementation does not
have to support size beyond unsigned 64bit.

Take advantage of this to lower our memory footprint, by using our
yang.common.Uint64 class instead of java.math.BigInteger. Also
use Uint64.intern() to minimize the number of actual instances we
create.

JIRA: YANGTOOLS-1206
Change-Id: Id112279eb9632d06a80e444d16bd5c825e4ba4ff
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoImprove UnresolvedNumber a bit 54/95054/1
Robert Varga [Sun, 7 Feb 2021 10:04:17 +0000 (11:04 +0100)]
Improve UnresolvedNumber a bit

This class should not be externally subclassed and should promise
non-null instances.

JIRA: YANGTOOLS-1206
Change-Id: Ib2e6a1d285326793d5c45ac61bf1c299b28e6bcd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUpdate SchemaPathSupport output objects 51/95051/5
Robert Varga [Sat, 6 Feb 2021 18:34:14 +0000 (19:34 +0100)]
Update SchemaPathSupport output objects

We can guarantee the returned object will be Immutable, express that
in our APIs.

JIRA: YANGTOOLS-1071
Change-Id: Ib32a11346afe912ffd70267f1a5b2d927cffc8ce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd a missing @return 52/95052/1
Robert Varga [Sat, 6 Feb 2021 18:42:48 +0000 (19:42 +0100)]
Add a missing @return

Just a slight correction of javadoc.

Change-Id: I9723ce92997e22b947d79df362f81136247b9079
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoImprove StmtContext.buildEffective() documentation 47/95047/1
Robert Varga [Fri, 5 Feb 2021 13:10:36 +0000 (14:10 +0100)]
Improve StmtContext.buildEffective() documentation

This method's contract is a bit under-specified in terms of expected
implementation behaviour and as to how nulls are treated. Improve that
a bit.

JIRA: YANGTOOLS-1214
Change-Id: Ie2043d8af803376077b10bba6a53a1959c0a6ed3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove an obsolete comment 46/95046/1
Robert Varga [Fri, 5 Feb 2021 13:02:36 +0000 (14:02 +0100)]
Remove an obsolete comment

The caller codepaths have evolved to the point where copySubstatement()
is again always called only when we are truly materializing statements.
This renders the comment obsolete, remove it.

JIRA: YANGTOOLS-1195
Change-Id: I913a6685b712b008ea21597e2341d8c7c96c24d6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoConcentrate SchemaNode.getPath() checking 42/95042/2
Robert Varga [Fri, 5 Feb 2021 10:38:09 +0000 (11:38 +0100)]
Concentrate SchemaNode.getPath() checking

We have a large number of test cases which examine getPath(). Add
a assertPathEquals() which isolates this checking in a single place.
It is cognizant that SchemaNode.getPath() may throw UOE, in which
case it falls back to checking SchemaNode.getQName(), which is always
available.

JIRA: YANGTOOLS-1071
Change-Id: Ia869c0b2e2cd9ed06901286c058e21384ddd092e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not mention SchemaNode#getPath() in toString() 41/95041/1
Robert Varga [Fri, 5 Feb 2021 10:37:01 +0000 (11:37 +0100)]
Do not mention SchemaNode#getPath() in toString()

We cannot rely on the SchemaPath being generally available, do not
mention it in toString().

JIRA: YANGTOOLS-1071
Change-Id: If43d3a572bf2638d742da8e3f4bc77ffce13655a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not include path in anydata/anyxml toString() 40/95040/1
Robert Varga [Fri, 5 Feb 2021 10:08:25 +0000 (11:08 +0100)]
Do not include path in anydata/anyxml toString()

Trim down toString() of these statements so as not to include
SchemaNode.getPath().

JIRA: YANGTOOLS-1071
Change-Id: I3539049a18b0e4312a00bb27e0f4497d3d828fd5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix ReplicateStatementContext reference handling 39/95039/1
Robert Varga [Fri, 5 Feb 2021 09:53:43 +0000 (10:53 +0100)]
Fix ReplicateStatementContext reference handling

Source statement can be fully defined and not supported to build
effective model -- hence we need to properly setup our flags.

JIRA: YANGTOOLS-1196
Change-Id: I367a206cc69304f24362344f6e40bb8e4f407812
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClarify Unknown/Unrecognized statement semantics 35/95035/1
Robert Varga [Fri, 5 Feb 2021 08:29:49 +0000 (09:29 +0100)]
Clarify Unknown/Unrecognized statement semantics

Unknown(Effective)Statement is really a remnant of the SchemaNode
approach to statement categorization. It is useful for bridging
from UnknownSchemaNode, but has not other use and we should
eventually be removing it.

UnrecognizedStatement, on the other hand, is here to stay as it
provides a DeclaredStatement anchor for use of extensions we do not
recognize.

JIRA: YANGTOOLS-1196
Change-Id: I54a8412d4ee0c60ee2cc6108973566e08121c201
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use RecursiveObjectLeaker 24/95024/5
Robert Varga [Thu, 4 Feb 2021 10:21:44 +0000 (11:21 +0100)]
Do not use RecursiveObjectLeaker

Since unrecognized extension statements are not built into their
effective form, we no longer encounter a recursive attempt to build
ExtensionEffectiveStatement. Remove use of RecursiveObjectLeaker.

JIRA: YANGTOOLS-1196
Change-Id: I8d3714f225c1eb628131ac7ebe5588ccf94d1897
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not build unrecognized extension statements 08/95008/21
Robert Varga [Wed, 3 Feb 2021 10:36:54 +0000 (11:36 +0100)]
Do not build unrecognized extension statements

Attempting to build EffectiveStatements for extensions we do not
recognize is an exercise in futility: we have to make assumptions
about arguments (like whether they can form a QName), about copy
policy (how does the extension propagate through uses?).

We also need to deal with extensions being used recursively, for
which we use a mighty object leaking machinery.

This patch changes the policy by explicitly taking out
UnrecognizedEffectiveStatement as something we normally produce
and making sure that if we do not have a StatementSupport registered
for a statement, it will not propagate into the Effective world.

Any extensions encountered are still retained in DeclaredStatement
form, as we can understand that definition well enough.

JIRA: YANGTOOLS-1196
Change-Id: If4e2292a977f8be82de7dae98671f025b79a836e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix return types 31/95031/1
Robert Varga [Fri, 5 Feb 2021 07:36:20 +0000 (08:36 +0100)]
Fix return types

The prototype requires nonnull results, make sure implementations
promise the same thing.

JIRA: YANGTOOLS-1150
Change-Id: I1a98ddde1443786fe74b0d8928fb752e0ef98fc5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMigrate test suite 09/95009/13
Robert Varga [Wed, 3 Feb 2021 12:20:35 +0000 (13:20 +0100)]
Migrate test suite

We are about to switch off propagation of unrecognized statements
into effective world. Update the test suite to look at declared things
to find the extension uses it asserts.

JIRA: YANGTOOLS-1196
Change-Id: I39789d0b3271bda590e033ba384e7fd567183bbb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFilter unsuported statements from getEffectOfStatement() 23/95023/2
Robert Varga [Thu, 4 Feb 2021 08:02:39 +0000 (09:02 +0100)]
Filter unsuported statements from getEffectOfStatement()

While a particular statement may be supported, not all of its
effects also are supported. Make sure we filter them out before
passing them on.

JIRA: YANGTOOLS-1196
Change-Id: Ied2ecafc3ea4b843a2151f5d8170f5536c53da6f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoBridge UnknownSchemaNode to UnknownEffectiveStatement 07/95007/10
Robert Varga [Wed, 3 Feb 2021 10:38:59 +0000 (11:38 +0100)]
Bridge UnknownSchemaNode to UnknownEffectiveStatement

We are missing this critical bridge, so that users can jump directly
without making assumptions what the statement actually is.

Change-Id: Ice955c1535cb487337a7f3b0aff19a9ce8d286d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse Empty instead of Void for argument 21/95021/5
Robert Varga [Wed, 3 Feb 2021 19:49:08 +0000 (20:49 +0100)]
Use Empty instead of Void for argument

@NonNull is an extremely important property. Using yang.common.Empty
instead of java.lang.Void allows us to ensure ModelStatement.argument()
is non-null.

This renders a number of utility methods completely superfluous, and
we end up removing them.

JIRA: YANGTOOLS-1220
Change-Id: I86c80dfd32d3a5f377effc62c00ad12c8ca61fd6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoClarify StatementFactory.createEffective() 20/95020/1
Robert Varga [Wed, 3 Feb 2021 18:41:15 +0000 (19:41 +0100)]
Clarify StatementFactory.createEffective()

There is a wide-scale confusion about declared/effective and what
it means where. Document StatementFactory to use different
terminology.

This flushes out the need to document
StatementContextBase.stream{Declared,Effective}, which is updated
with the logical requirement to support buildEffective().

JIRA: YANGTOOLS-1150
Change-Id: I2d455fd9c328f97995d88e37b903145b2e45f793
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoExpand EffectiveModelContext methods 17/95017/2
Robert Varga [Wed, 3 Feb 2021 15:44:27 +0000 (16:44 +0100)]
Expand EffectiveModelContext methods

There are some convenience methods we can add defaults, add them
to improve user experience.

Change-Id: Idf8fa1f97ba071bc5a12edd98aa79b04dbefc9a3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup substatement cast 11/95011/2
Robert Varga [Wed, 3 Feb 2021 14:46:59 +0000 (15:46 +0100)]
Fixup substatement cast

This cast is problematic: ReactorStmtCtx is the baseline implementation,
not StatementContextBase (as it used to be).

JIRA: YANGTOOLS-1184
Change-Id: I53943e08f32653310ea4e5819814399cda28af75
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoONE: yang-data validation is an inference action 70/94970/1
Robert Varga [Tue, 2 Feb 2021 18:47:25 +0000 (19:47 +0100)]
ONE: yang-data validation is an inference action

We are accessing inference state during effective build, which is
a no-no, with all sorts of potential rabbits -- and we have
a continent which can tell a tale or two about that.

So realize that we just need to perform a simple substatement check
and be done with it.

This implementationallows other data nodes being there -- which is
in keeping with the spec. If somebody complains, the flip side
of yang-data is that it is only its sole container statement which
is accessed. In other words users are fully expected to ignore
other statements and treat that container as schema tree root.

JIRA: YANGTOOLS-1186
Change-Id: I802193d75d914216ce565f51c042547abb97caba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove YangModeledAnyxmlSchemaNode 67/94967/3
Robert Varga [Tue, 2 Feb 2021 15:53:06 +0000 (16:53 +0100)]
Remove YangModeledAnyxmlSchemaNode

This construct was never adopted, nor made fully functional nor
required. Remove along with any other API elements which relate to
it.

JIRA: YANGTOOLS-1219
Change-Id: I7ebbd3038cebcffb3d24664e1f6141439689f0d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoTest SchemaNodeIdentifier instead of SchemaPath 68/94968/1
Robert Varga [Tue, 2 Feb 2021 18:09:10 +0000 (19:09 +0100)]
Test SchemaNodeIdentifier instead of SchemaPath

The SchemaNodeIdentifier path is not tested, whereas SchemaPath is.
Deprecation situation points the other way around. Rather than
duplicating tests, simply change the objects being tested.

Change-Id: Idded0df5d21d8aa756c28e223c77a2ebec1a08af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEliminate StatementPolicy.legacyDeclaredCopy() 66/94966/2
Robert Varga [Tue, 2 Feb 2021 15:38:23 +0000 (16:38 +0100)]
Eliminate StatementPolicy.legacyDeclaredCopy()

There is only two callers, one of which is going away anyway. Migrate
it to alwaysCopyDeclared() and remove legacyDeclaredCopy().

JIRA: YANGTOOLS-1208
Change-Id: Iad100c4f827e08421bc0d8a5f920032d2a6b7361
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRefineStatementSupport should use StatementPolicy.reject() 65/94965/1
Robert Varga [Tue, 2 Feb 2021 15:26:24 +0000 (16:26 +0100)]
RefineStatementSupport should use StatementPolicy.reject()

'refine' can only ever be used inside 'uses', which in turn uses
exactReplica(). This implies that 'refine' cannot be copied, hence
use StatementPolicy.reject().

JIRA: YANGTOOLS-1208
Change-Id: I7ad489c4ca68b8f39c5dc1fc0b94e587a079d4d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUsesStatentSupport should use StatementPolicy.exactReplica() 70/94870/9
Robert Varga [Thu, 28 Jan 2021 21:15:28 +0000 (22:15 +0100)]
UsesStatentSupport should use StatementPolicy.exactReplica()

This is the final bit of the InferredStatementContext.REUSED_DEF_SET,
eliminating that special case in policy-driven way, just as it was
done for 'type' and 'typedef'.

JIRA: YANGTOOLS-1208
Change-Id: Id240c8f7a28108e3ae8a2cf6e629aef44f1c1cf5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd OpenConfig pattern-related statement definitions 73/92973/5
Martin Bobak [Wed, 7 Oct 2020 16:03:22 +0000 (18:03 +0200)]
Add OpenConfig pattern-related statement definitions

OpenConfig defines two extensions to deal with pattern statements.

The first is a semantic marker to tell the parser that OpenConfig's
interpretation of what is 'pattern' is used within that source file,
i.e. patterns are some variant of POSIX regular expression.

The second one is a properly-defined YANG extension which carries
the POSIX RE. This extension is a sibling to pattern statement,
whose argument is a YANG-compliant XSD regular expression.

JIRA: YANGTOOLS-1132
Change-Id: I6bd1c074eda2a02eea59913c939b9c236fdf8e8c
Signed-off-by: Martin Bobak <martin.bobak@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFixup openconfig-model-api JPMS 59/94959/1
Robert Varga [Mon, 1 Feb 2021 23:05:20 +0000 (00:05 +0100)]
Fixup openconfig-model-api JPMS

We are using @SuppressFBWarnings, we should be requiring its module.

Change-Id: Ibda029ac96a8ce35a05364d3d99107134ef8d33c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoPromote BaseSchemaTreeStatementSupport 54/94954/1
Robert Varga [Mon, 1 Feb 2021 21:51:13 +0000 (22:51 +0100)]
Promote BaseSchemaTreeStatementSupport

This abstract class forms a foundation contract with reactor around
how SchemaTreeNamespace operates. Publish it into yang-parser-spi,
it can be better reused and more closely integrated.

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