yangtools.git
3 years agomodule-info.java audit, part one 55/94655/2
Robert Varga [Mon, 18 Jan 2021 23:43:16 +0000 (00:43 +0100)]
module-info.java audit, part one

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

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

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

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

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

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

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

KeyStatementSupport is converted to take advantage of these
facilities.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This necessitates splitting Bug8126Test into legal and illegal parts.

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

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

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

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

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

Use assertThrows() and improve cause assertions.

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

The word is 'tractable'.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Pick up latest fixes from upstream.

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

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

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

Change-Id: I26e14048b4d4d44ea5044ff852650b18ca90012f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoImprove NormalizedNodes.toStringTree() 26/94326/2
Robert Varga [Fri, 1 Jan 2021 14:56:54 +0000 (15:56 +0100)]
Improve NormalizedNodes.toStringTree()

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

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

Pick up the fixed-up version.

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

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

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

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

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

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

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

Change-Id: I27087e85514a70bd3becde2fb5d41bcc11f6b8e3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake sure SmtmtNamespaceContext uses belongs-to prefix 44/94144/3
Robert Varga [Thu, 10 Dec 2020 11:48:16 +0000 (12:48 +0100)]
Make sure SmtmtNamespaceContext uses belongs-to prefix

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

JIRA: YANGTOOLS-1201
Change-Id: Id38d76443d23eecef09f1f927c44218363a3a1d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse correct key-arg splitting 17/94117/2
Robert Varga [Tue, 8 Dec 2020 21:27:30 +0000 (22:27 +0100)]
Use correct key-arg splitting

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

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

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

JIRA: YANGTOOLS-1200
Change-Id: Ifa3085fffcbbe24204e9d6c0d86ed8c41bd61065
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse simple index for feature/extension/identity 16/94116/3
Robert Varga [Tue, 8 Dec 2020 15:28:01 +0000 (16:28 +0100)]
Use simple index for feature/extension/identity

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

3) LeafSet follow the same split as MapNode

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

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

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

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

JIRA: YANGTOOLS-1157
Change-Id: I33eaba254c82e4b8e0152c03d8da91fef4453f63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd UnqualifiedQName.tryCreate() 85/94085/2
Robert Varga [Sun, 6 Dec 2020 12:37:39 +0000 (13:37 +0100)]
Add UnqualifiedQName.tryCreate()

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

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

3 years agoMake DataNodeContainer.dataChildByName() non-default 81/94081/5
Robert Varga [Sun, 6 Dec 2020 16:19:41 +0000 (17:19 +0100)]
Make DataNodeContainer.dataChildByName() non-default

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Change-Id: Ia44be0835897300b86e7896cd7b441f7ccb8fb5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not access TypeNamespace during declared build 71/94071/1
Robert Varga [Sat, 5 Dec 2020 13:27:37 +0000 (14:27 +0100)]
Do not access TypeNamespace during declared build

We have a shadowing check here which is being executed at
buildDeclared() time. Move the check into an inference action,
so that we do not even go to statement build if it is violated.

JIRA: YANGTOOLS-1198
Change-Id: Ibb5d121862bc2d822c5919a3233ae790412e53f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not access GroupingNamespace during effective build 53/94053/4
Robert Varga [Fri, 4 Dec 2020 17:02:36 +0000 (18:02 +0100)]
Do not access GroupingNamespace during effective build

There are two places which are accessing GroupingNamespace during
statement build:

AbstractGroupingStatementSupport.buildDeclared() performs a check
for namespace conflict. This is better done through an inference
action in FULL_DECLARATION of root model, when we can check whether
there is a conflict -- before we ever get to build statements.

UsesStatementSupport is searching namespaces to locate its source
to build its effective model -- to satisfy
UsesNode.getSourceGrouping(). This is better done by remembering
the source grouping's context in a statement-local namespace
and then pick it up when needed.

The two changes together allow us to sweep GroupingNamespace at
the end of RootStatementContext's build.

JIRA: YANGTOOLS-1197
Change-Id: I3a75ad92aeffeeed279466fffcf4402b17ee1d09
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd TypeNamespace cleaning FIXMEs 52/94052/1
Robert Varga [Fri, 4 Dec 2020 16:31:23 +0000 (17:31 +0100)]
Add TypeNamespace cleaning FIXMEs

Place FIXMEs that need to be addressed to resolve this issue.

JIRA: YANGTOOLS-1198
Change-Id: Ib77ca7f6acc3dba6389bba01428e7fbd0b290a2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd GroupingNamespace cleaning FIXMEs 51/94051/1
Robert Varga [Fri, 4 Dec 2020 16:28:46 +0000 (17:28 +0100)]
Add GroupingNamespace cleaning FIXMEs

Drop FIXMEs that need to be addressed.

JIRA: YANGTOOLS-1197
Change-Id: I24e7e9c5ebedf41c22a102782a1d3bfe9b63f1d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd DataSchemaNode.effectiveConfig() 00/86900/8
Robert Varga [Fri, 4 Dec 2020 11:48:42 +0000 (12:48 +0100)]
Add DataSchemaNode.effectiveConfig()

DataSchemaNode.isConfiguration()'s boolean return is inaccurate
modeling: a DataSchemaNode can be inside a top-level grouping, in
which case it does not have its 'config' defined.

Add effectiveConfig() which accurately reflects whether there is
a 'config' statement in effect or not.

JIRA: YANGTOOLS-1063
Change-Id: I2314aaa169a591cce419b925a965cbed118f249e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake EffectiveStmtCtx.effectiveConfig() accurate 23/94023/4
Robert Varga [Fri, 4 Dec 2020 10:27:34 +0000 (11:27 +0100)]
Make EffectiveStmtCtx.effectiveConfig() accurate

There are four (rather than two) states effectiveConfig() can be in
and statement implementations need to account for this. Capture the
possibilities in EffectiveConfig enumeration and adjust users.

JIRA: YANGTOOLS-1063
Change-Id: I724a8bd65ca836ddc48e3579d985afc6baf271f2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoFix YangModeledAnyxmlEffectiveStatementImpl.isMandatory() 47/94047/2
Robert Varga [Fri, 4 Dec 2020 13:27:21 +0000 (14:27 +0100)]
Fix YangModeledAnyxmlEffectiveStatementImpl.isMandatory()

We have a bug in forwarding here, fix that.

Change-Id: I6f71c2df71b4922a45edc41ac19a8fdb71122b3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoLower NamespaceStorageSupport logging 22/94022/1
Robert Varga [Fri, 4 Dec 2020 10:20:28 +0000 (11:20 +0100)]
Lower NamespaceStorageSupport logging

We really do not need to flood tests with information about namespaces
being swept, silence those logs.

Change-Id: Ie4bd751851e8c3cb458c348e0cad30fd1be9037a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRequire SchemaTreeEffectiveStatement in OnDemandSchemaTreeStorageNode 89/93789/8
Robert Varga [Thu, 5 Nov 2020 16:16:01 +0000 (17:16 +0100)]
Require SchemaTreeEffectiveStatement in OnDemandSchemaTreeStorageNode

This storage concept is inherently tied to schema tree. Let's express
that in its API.

Change-Id: I5cb736c7752437fa53003e7f98a11be14a415cc2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd parent refcount cache 88/93988/18
Robert Varga [Wed, 2 Dec 2020 07:58:55 +0000 (08:58 +0100)]
Add parent refcount cache

The idea here is that we check with references towards root quite
often. Since we have a one-byte gap in StatementContextBase, we can
use it to track knowledge of what parent refs look like -- and
side-step a lot of pointer chasing on our way to root.

JIRA: YANGTOOLS-1184
Change-Id: I6342292d8f6675ef446dca8410bb859e2d6f230c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoIntegrate {Inference,Source}Exception with CommonStmtCtx 15/94015/7
Robert Varga [Thu, 3 Dec 2020 02:16:12 +0000 (03:16 +0100)]
Integrate {Inference,Source}Exception with CommonStmtCtx

We rarely need StatementSourceReference and we already define
a CommonStmtCtx which can provide it at almost any moment. Migrate
users, so that the reference is accessed only when needed.

This changes the balance of access, so that we may get away with
forwarding this through InferredStatementContext's prototype.

JIRA: YANGTOOLS-1194
Change-Id: I24e97cf10c68415caaa913014a9b6620f43cd94d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoTrim down ReplicaStatementContext 94/93994/8
Robert Varga [Wed, 2 Dec 2020 14:43:35 +0000 (15:43 +0100)]
Trim down ReplicaStatementContext

Shuffle around the code and class hierarchy to make
ReplicaStatementContext inherit only ReactorStmtCtx. This reduces
the size of the instance by about one half.

JIRA: YANGTOOLS-1184
Change-Id: Ibefc13a6302dd5799839af45bf47e26d232fb563
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCentralize SchemaNode.getPath() dispatch 35/93935/15
Michal Banik [Thu, 26 Nov 2020 12:21:50 +0000 (13:21 +0100)]
Centralize SchemaNode.getPath() dispatch

Our handling of SchemaPath is quite scattered. This patch makes
it easier to reason about what is going on where.

JIRA: YANGTOOLS-1071
Change-Id: Ia90976635223d2347861554e9a59c35f190b7a5d
Signed-off-by: Michal Banik <michal.banik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake SchemaNode.getPath() a default method 10/94010/2
Robert Varga [Wed, 2 Dec 2020 22:26:30 +0000 (23:26 +0100)]
Make SchemaNode.getPath() a default method

Make sure implementations do not have to implement getPath() as we
can just have a default method throwing UnsupportedOperationException.

Change-Id: I3490d6d706113ea14ee3f4181a7ba827380c8181
JIRA: YANGTOOLS-1071
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoReduce StmtCtx proliferation 14/94014/1
Robert Varga [Thu, 3 Dec 2020 01:49:40 +0000 (02:49 +0100)]
Reduce StmtCtx proliferation

We only need a CommonStmtCtx, make sure we start the migration.

Change-Id: Ib9ea845fa25d19f761600eaab28a636f17e0b852
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse EffectiveStmtCtx.Current in ExtensionStatementSupport 13/94013/1
Robert Varga [Thu, 3 Dec 2020 01:47:00 +0000 (02:47 +0100)]
Use EffectiveStmtCtx.Current in ExtensionStatementSupport

Now that identity works again, we can safely ditch the escape
hatch and operate on EffectiveStmtCtx.

JIRA: YANGTOOLS-1185
Change-Id: I60a2eb98136faabe1a73b51b4f4f5a8556b56e7e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoUse statementContextBase when creating effecive 02/94002/6
miroslav.kovac [Wed, 2 Dec 2020 10:21:42 +0000 (11:21 +0100)]
Use statementContextBase when creating effecive

StatementContextBase is now implementing EffectiveStmtCtx.Current
and hence it can be used in createEffective. This saves us an object
allocation during buildEffective() time.

JIRA: YANGTOOLS-1185
Change-Id: Iffc02f7aa222070d750dbb9628894a891fb17a0c
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoAdd BoundStmtCtxCompat 87/93987/13
miroslav.kovac [Tue, 1 Dec 2020 14:20:53 +0000 (15:20 +0100)]
Add BoundStmtCtxCompat

This is a compatibility interface between StmtContext and
EffectiveStmtCtx.Current, hosting the declared instance (for now).

JIRA: YANGTOOLS-1185
Change-Id: Ie1526b7447d9935c8f21910cd4aff298a385103f
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
3 years agoIntroduce NamespaceStmtCtx 86/93986/11
miroslav.kovac [Tue, 1 Dec 2020 13:55:34 +0000 (14:55 +0100)]
Introduce NamespaceStmtCtx

We have a few namespace access methods, make sure we encapsulate
them into a NamespaceStmtCtx and expose them from both
StmtContext and EffectiveStmtCtx.Current.

JIRA: YANGTOOLS-1185
Change-Id: I5c13406b96ab3735761749b900c244ad555f8730
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoCopyHistory and yangVersion merge 84/93984/6
miroslav.kovac [Tue, 1 Dec 2020 13:16:34 +0000 (14:16 +0100)]
CopyHistory and yangVersion merge

history and getCopyHistory together with yangVersion and
getRootVersion can be merged since it is used in both
StmtContext and EffectuveStmtCtx.Current.

Since a few methods still do not have a proper new name,
introduce StmtContextCompat to host these.

JIRA: YANGTOOLS-1185
Change-Id: I7b63a96e6d00ef3378544ce9bd0970f3857e7358
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoEliminate ReplicaStatementContext.haveRef 09/94009/2
Robert Varga [Wed, 2 Dec 2020 14:10:51 +0000 (15:10 +0100)]
Eliminate ReplicaStatementContext.haveRef

This is a very costly boolean, costing us on alignment in the range
of 4-16 bytes. As it turns out we can reuse the boolean used for
fullyDefined(), so do that and reduce instance size.

JIRA: YANGTOOLS-1184
Change-Id: I59a6227c1715549472358e3ca8f003d800377322
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemost StatementContextBase.schemaPath() 08/94008/2
Robert Varga [Wed, 2 Dec 2020 13:39:02 +0000 (14:39 +0100)]
Remost StatementContextBase.schemaPath()

We are still suporting this mechanics, hence move it to
ReactorStmtCtx, allowing it to be reused without StatementContextBase.

JIRA: YANGTOOLS-1184
Change-Id: Ife7fd573e14415e78fd45663a40c904d702a05b1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoDo not use exceptions for branching 76/93976/4
Robert Varga [Mon, 30 Nov 2020 16:30:24 +0000 (17:30 +0100)]
Do not use exceptions for branching

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

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

JIRA: YANGTOOLS-1191
Change-Id: Iecea9f446730e4e7840b962a95844ce5128dfb9e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove flags to ReactorStmtCtx 07/94007/1
Robert Varga [Wed, 2 Dec 2020 13:28:30 +0000 (14:28 +0100)]
Move flags to ReactorStmtCtx

We have a bunch of bitwise flags we are using for various
inference details. Unfortunately them being placed in
StatementContextBase and ReactorStmtCtx layout result in 8 bytes
being lost on 64bit w\o compressed oops.

Move the flags and their methods to ReactorStmtCtx, reducing
InferredStatementContext footprint from 160 bytes to 152 bytes
(i.e. 5%).

JIRA: YANGTOOLS-1184
Change-Id: I0c9787795fc67c1e979132f9244f06a7a7e3dc3e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove more StatementContextBase methods 06/94006/1
Robert Varga [Wed, 2 Dec 2020 12:57:45 +0000 (13:57 +0100)]
Move more StatementContextBase methods

ReactStmtCtx is overtaking the role of baseline implementation,
hence we move forwarder final methods there.

JIRA: YANGTOOLS-1184
Change-Id: I4ac8b13b29ddd5db7b7960ae6e271fcd223a09d2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMove effectiveInstance to ReactorStmtCtx 05/94005/1
Robert Varga [Wed, 2 Dec 2020 12:47:14 +0000 (13:47 +0100)]
Move effectiveInstance to ReactorStmtCtx

This is part of our common mechanics which integrates with refcounts.
Move the field down to ReactorStmtCtx, simplifying interactions a bit.

JIRA: YANGTOOLS-1184
Change-Id: Ibf48b4fbf47d710ed642ef525fceefe5f14719c5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoRemove ReactorStmtCtx.parentStmtCtx() 04/94004/1
Robert Varga [Wed, 2 Dec 2020 12:36:59 +0000 (13:36 +0100)]
Remove ReactorStmtCtx.parentStmtCtx()

We have the same facility in StatementContextBase.getParentContext(),
hence we can directly reuse it.

JIRA: YANGTOOLS-1184
Change-Id: Ie0d13fc86e50764a5e27ed0cb3d1d5731ddf6116
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoMake sweep-on-decrement more aggressive 01/94001/2
Robert Varga [Wed, 2 Dec 2020 09:38:43 +0000 (10:38 +0100)]
Make sweep-on-decrement more aggressive

We are holding off on cleaning if we have a parent, which effectively
means we not start sweeping children until that process is initiated
from parent.

This is needlessly conservative: we should actually be checking parent
refcount and trigger cleanup as soon as we observe no explicit
references.

JIRA: YANGTOOLS-1184
Change-Id: Ief30aa03b760116540d77038fb8c78fd5b0daf5a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
3 years agoSweep child->parent relationships more quickly 98/93998/7
Robert Varga [Tue, 1 Dec 2020 22:33:10 +0000 (23:33 +0100)]
Sweep child->parent relationships more quickly

Sweep logic currently does not kick in until the root statement of
a particular source is completely built. This leads to us retaining
all of the state until that moment, at which point we mass-release
everything.

This is caused by us being needlessly conservative in deciding when
to start sweeping our parents.

Replace ReactorStmtCtx.noParentRefs() with noParentRefcount(), which
disregards noImplicitRef(). This allows us to start sweeping as
soon as we buildEffective() any child of a subtree, propagating
towards parent -- which is safe, since there can be no new incoming
explicit references.

JIRA: YANGTOOLS-1184
Change-Id: I97feeb65c270b1e7abceb99b94938593cf2e9abc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>