Robert Varga [Mon, 5 Mar 2018 14:11:45 +0000 (15:11 +0100)]
Validate parsed QName to identity
We need to validate if parsed QName refers to an existing identity,
this fixes up unused AbstractModuleStringIdentityrefCodec to check
Module references.
Change-Id: Iebbb43681e9b384c43bd81607d169294373bdd72
JIRA: YANGTOOLS-846
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 22 Feb 2018 14:01:52 +0000 (15:01 +0100)]
Validate parsed QName to identity
We need to validate if parsed QName refers to an existing identity
before allowing it in Identityref codecs. Introduce IdentityCodecUtil
along with a test suite and migrate users over.
JIRA: YANGTOOLS-846
Change-Id: I673ae6df4406110202b86329121a3ca9673fb0ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 12:27:02 +0000 (13:27 +0100)]
Cleanup resources allocated in @BeforeClass
This cleans up static fields after tests have been run.
Change-Id: Idf48234157b2196fadfdabcffd5628ad397639d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 2 Mar 2018 14:37:12 +0000 (15:37 +0100)]
Intern more arguments
modifier, deviate and max-elements were missed in the original
interning patch, add them.
Change-Id: I9b14f4d84657b10f0fd0e56c0f6a867f5e6c8872
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 23:54:51 +0000 (00:54 +0100)]
Add timing information
This adds timing information around code generation. It also exposes
the number of YANG modules processed, so we have some guidance
to interpret the time taken. Also lowers verbosity of dependency
scanning.
Change-Id: I7b202a388405e755964fe76d6b81bc42fd92b73b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 23:17:56 +0000 (00:17 +0100)]
Fix YangTextSnippetIterator with OpenConfig extensions
Since OC extensions are binding to all revisions, their
StatementSupport's QNameModule (without revision) is presented
by DeclaredStatement. Such a QNameModule does not match the imported
module (which obeys flexible rules) -- which means we cannot readily
look it up from ModuleEffectiveStatement.
Add a workaround to use a loose match until a proper fix is
implemented.
Change-Id: I9393fe7cef7b22014e3c68d69b09f9702dded303
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 23:15:26 +0000 (00:15 +0100)]
Optimize QName.withoutRevision()
This method is used in a few users to implement loose matches. Optimize
it to not check localName, as that has already been checked. Also introduce
a mirror QNameModule method.
Change-Id: Id1045d79677fd4c0aeb5069f6b151530c545c20b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 20:00:40 +0000 (21:00 +0100)]
Cleanup AbstractEffectiveDocumentedDataNodeContainer a bit
Throw colision exception in a short block, allowing logic to be
better in-lined.
Change-Id: I87d056127869d3c2ea7cc2d240b6f6278b57c9c8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 15:54:46 +0000 (16:54 +0100)]
Skip duplicate classpath scanning
Scanning the entire class path for jars is expensive. Do that
only once and capture dependencies so we can do the second pass
in a more direct manner.
JIRA: YANGTOOLS-855
Change-Id: I0763cbac3ea6781ebb400e014837b9f44375de63
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 10:20:50 +0000 (11:20 +0100)]
Allow StatementMap to be resized to correct size
StatementStreamSources typically know the correct sizing for substatement
list even when they do not understand them (and thus have not emitted
them) and pass this hint down when they finish processing the statement.
Take advantage of this information by allocating sufficient capacity to
hold all resolved children.
Change-Id: Ib4a96a8d42bad747d56d92e07846724607346e97
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 12:06:45 +0000 (13:06 +0100)]
Optimize YinStatementStreamSource
This patch converts YinStatementStreamSource to use stateful
StatementWriter interfaces, skipping expensive lookups.
JIRA: YANGTOOLS-854
Change-Id: I4d0931a78f9a08fed3d23045df1763ea4e4a02d9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 08:24:32 +0000 (09:24 +0100)]
Allow StatementWriter to be stateful
This patch adds a stateful protocol betwen SourceSpecificContext
and StatementStreamSources, so they do not need to allocate/lookup
objects for statements defined in previous phases.
JIRA: YANGTOOLS-854
Change-Id: I600208a384776a601967bc7b5719cc6632b226db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 27 Feb 2018 12:27:57 +0000 (13:27 +0100)]
Populate Extension/FeatureEffectiveNamespace
Modules are the primary providers of these namespaces, make sure
ModuleEffectiveStatementImpl populates them correctly.
JIRA: YANGTOOLS-853
Change-Id: I9e0313e36a2b7de2bc258a263ac376dc8bd99dc0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 24 Feb 2018 21:43:04 +0000 (22:43 +0100)]
Add Case/Extension/Feature/IdentityEffectiveStatementNamespace
This patch adds simple RFC7950 namespaces.
JIRA: YANGTOOLS-853
Change-Id: I753a297a782fc3f9f81f9d1659fc12a7c70b8c28
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 23:30:13 +0000 (00:30 +0100)]
Deprecate PrefixToModule.isPreLinkageMap()
This property is only consulted at places which can be inferred
to set it to true. Deprecate this property, as it is a state leak
defying encapsulation.
Change-Id: I1f159214e6487f482c7801ff73bd697bad6d470a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 21:05:16 +0000 (22:05 +0100)]
Turn YangStatementParserListenerImpl into a visitor
Rather than using a listener with two methods, which needs to keep
and re-lookup state, implement such visitStatement(). This allows us
to skip duplicate lookups and will allow us to completely eliminate
all state tracking.
As it turns out we do not need any visitor logic, because we are
always walking statements and descending into their children. Rework
logic to reflect that, eliminating the need for any statekeeping,
as we can track all of the state inline.
JIRA: YANGTOOLS-713
Change-Id: I22a289fdbb2d8ea1501dd4a8eacd7780afbf1c6c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 22:13:02 +0000 (23:13 +0100)]
Mark missed StatementStreamSource methods
We have failed to mark methods in this interface for API movement
before 2.0.0, hence they were left out. Mark them for 3.0.0 so we
do not forget again.
Change-Id: Ic24e12e6f9c984f6d92d53aeb2aa38f542306beb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 20:02:35 +0000 (21:02 +0100)]
Encapsulate YangStatementParserListenerImpl.walk()
As it turns out, the contract between YangStatementStreamSource
is one of walking a tree with a set of parameters. Make sure we
encapsulate this contract, so that it can be efficiently implemented
using a visitor.
This has the benefit of discarding unneeded state more quickly
and not retaining it past errors. It will also allow us to very
simply convert YangStatementParserListenerImpl into a visitor.
JIRA: YANGTOOLS-713
Change-Id: Iac8c4979fb31cb527788837b41d4bbf17ce4b3cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 19:34:18 +0000 (20:34 +0100)]
Privatize YangStatementParserListenerImpl
This class is package-visible, hence public methods should only be
the @Override ones.
JIRA: YANGTOOLS-713
Change-Id: Id092b12cf6f2ad309aaf5920b31ae9fb4ab25b58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 25 Feb 2018 18:43:49 +0000 (19:43 +0100)]
Make QName/QNameModule a WritableObject
Serializing these objects into a stream is useful, make them implement
WritableObject.
Change-Id: I3fbb147b4deb17afb2ead0dedc716e5a9a5cefc6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 24 Feb 2018 21:42:24 +0000 (22:42 +0100)]
QNameModule/QName should implement Identifier
These classes are inherently identifier-like, and hence should be
implementing Identifier concept.
Change-Id: Ic494ec42788a176555c56446105511bc4868fad8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 15:03:39 +0000 (16:03 +0100)]
Expose identities from ModuleEffectiveStatement
Parser has an accurate, indexed view of all identities defined in
a particular module. Expose this namespace to ModuleEffectiveStatement
users.
Change-Id: I9692cb91b23155191545224bceaf436fd0f6c67e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 12:02:55 +0000 (13:02 +0100)]
Eliminate unneeded @BeforeClass
Constructing QNames does not entail exceptions, so we can initialize
them as simple constants.
Change-Id: I84fa394cda4d8478b60a40b8ea7080d4e6b88558
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 11:22:28 +0000 (12:22 +0100)]
Report parent SchemaPath on error
When we fail to find a child node, report the full schemapath
of the parent node, so the input can be properly diagnosed.
Change-Id: Id5cf3f55f3c745b55f2a485746dd995b0f056657
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 23 Feb 2018 11:21:58 +0000 (12:21 +0100)]
Correct error message
Expand "doesn't" to "does not".
Change-Id: I2b530985dd5982d7bcbc95866c1e7e26e52c4b98
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 22 Feb 2018 13:42:48 +0000 (14:42 +0100)]
Optimize QNameModule.equals() a bit
The namespace cannot be null, so we can safely call equals() on it,
skipping checks in Objects.equals().
Change-Id: Ic1b94e2239fb9fd906711c8cbb03dd252a190c49
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 22 Feb 2018 13:02:42 +0000 (14:02 +0100)]
Speed up JSON codec operations
With the improved SchemaContext, we can perform direct lookup
of Module based on QNameModule -- use that instead of iteration.
Change-Id: Ib5c1146b8c13ac3f52a18ed8334b89b66f6ca40c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Feb 2018 19:20:52 +0000 (20:20 +0100)]
Fix maven plugin ignoring import resolution mode
While BasicCodeGenerator has knobs to express required import resolution
mode, the plugin ignores them. This patch reorganizes YangToSourcesProcessor
so that we determine what import resolution mode we need before we start
assembling the SchemaContext.
JIRA: YANGTOOLS-825
Change-Id: Iaec12e3c8ada2173262533cc6d59e54f18095826
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 13:51:03 +0000 (14:51 +0100)]
Do not fake an errorMessage for pattern constraints
Eagerly-formatting a replacement error message is actively hurting
callers of getErrorMessage(), which really expect that method
to return model-defined error message. Fix that.
JIRA: YANGTOOLS-850
Change-Id: Iddb5f9ae529f1ed49eed735a8931ee396334f578
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 14:12:26 +0000 (15:12 +0100)]
Add DeclaredStatementFormatter
Working with downstreams it became apparent they really are using
same YangTextBuilder customizations across multiple statements.
This patch exposes DeclaredStatementFormatter, which acts as
a customization holder off of which YangTextSnippets can be created.
JIRA: MDSAL-301
Change-Id: I4733313dcb98c9b1d244088b5b46d8a197ab2f5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 20 Feb 2018 18:12:19 +0000 (19:12 +0100)]
Encapsulate regexes in a non-capturing group
Regular expressions are pesky, nwo we are being bitten by branches.
Let's just encapsulate the internal pattern into a non-capturing
group and be done with it.
JIRA: YANGTOOLS-798
Change-Id: If3b3b2fb35ecd336bc23fd7acaf29efa48eb9b74
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 21 Feb 2018 09:43:03 +0000 (10:43 +0100)]
Move Bug4079/Bug5410 tests from yang-parser to yang-model-util
This co-locates the unit test with the class tested.
Change-Id: Ib7d044208946be3347e1b1aedbd87a0cfe1e5a23
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 22:49:47 +0000 (23:49 +0100)]
Move yang-model-export unit tests
This will allow us to co-locate within the same package, leading
to better interaction, as we can use package-private methods to look
at state.
Change-Id: I0ab59c32c166505ac44d5f21ae0aa374eaa08aac
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 14 Feb 2018 09:37:11 +0000 (10:37 +0100)]
Add the ability to build effective model
The effective model consists of ModuleEffectiveStatements
which are guaranteed to have unique QNameModules. Express
that in YangParser.
Change-Id: Id094c40cf5dcf49e6289d3b929f4abf2f9cb6436
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 20:08:56 +0000 (21:08 +0100)]
Add submodule lookup namespace
ModuleEffectiveStatement needs to allow looking up which submodules
were included as the effect of include statements. Since submodule
names need to be unique, it is natural to express this as a namespace.
Change-Id: I782caba8dfb9ff4dbea5b81e335f06dc797518d5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 15:22:54 +0000 (16:22 +0100)]
Add YANG/YIN namespace string literals
Interacting with Java XML machinery requires the use of Strings
for namespaces. It is useful to implement javax.xml.NamespaceContext
with switch() statement, which unfortunately can only work on explicit
string literals. Expose these literals, improving the ergonomics.
Change-Id: I534d2a6e13960ba7587bfe77ed581e8593e65a17
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 19 Feb 2018 07:02:52 +0000 (08:02 +0100)]
Export ResourceYangTextSchemaSource
YangTextSchemaSource.forResource() returns this class, which is hidden,
leading to end user confusion, as the return class cannot be imported.
We cannot change the return value, as that would cause ABI breakage,
hence expose ResourceYangTextSchemaSource and mark it for hiding
in next major release.
Change-Id: Ib03e3df73824172dcd80a58fc33f7bdb4e26c6f0
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Feb 2018 19:33:57 +0000 (20:33 +0100)]
Add YangTextSnippet to yang-model-export
This is a simple class generating a sequence of strings, concatenation
of which produces YANG text corresponding to a DeclaredStatement.
The snipped is properly indented, can omit user-specified statements,
and by default omits statements with default values as per RFC6087.
JIRA: MDSAL-301
Change-Id: Ie45e947dccd33b851e23effb827ddc66690451f6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 5 Feb 2018 05:01:34 +0000 (06:01 +0100)]
Add DefaultStatementDefinition
Implementing StatementDefinition contract can be tricky and it is
often misused by using implementation classes. Introduce a utility
default implementation, which enforces statement representations
being interfaces.
Change-Id: Icd2ce998dc8001cfa4a1d44f48017204c6dd02f4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sat, 3 Feb 2018 12:35:24 +0000 (13:35 +0100)]
Expose EffectiveModuleStatement prefix mapping
ModuleEffectiveStatement should expose mapping of prefixes
to imported modules (and self) as well as reverse mapping of
QNameModule to prefix, so that users can map properly map
QNames encountered within a module.
This patch exposes that information via two new namespaces,
which are present only in ModuleEffectiveStatements. Furthermore
EffectiveStatementBase is updated to allow subclasses to contain
namespaces.
JIRA: MDSAL-301
Change-Id: I5139c32eff18c1fa703dd8d3c98882939f82b109
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 4 Feb 2018 15:31:11 +0000 (16:31 +0100)]
Correct double-quoted string whitespace trimming
We need to trim leading and trailing whitespace when it comes from
YANG text, so that the resulting string matches expectations.
This patch adds the required trimming.
JIRA: YANGTOOLS-845
Change-Id: I21777583c5d18819e68c089cd9f2cf51179b0530
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Feb 2018 12:39:17 +0000 (13:39 +0100)]
Switch YangToSourcesProcessor to use YangParser
Rather than going through YangTextSchemaContextResolver, use
YangParser to assemble the SchemaContext. This gives us better
control over the parsing process and also allows us to build
only sources which are required to generate code in local directory.
JIRA: YANGTOOLS-825
Change-Id: Ie3c49517aedd5ae3604ed27dc5bd1f1f1fa7a4d1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 30 Jan 2018 22:48:40 +0000 (23:48 +0100)]
Deprecate CopyableNode at al.
isAddedByUses(), isAugmenting() and similar constructs relate to how
a particular node became effective. This really has not place in the
effective model of the world.
This patch concentrates duplicate methods into an interface hierarchy
and marks them as @deprecated, along with justification. This allows
us to track down users and the semantics they really are after.
Since we are touching SchemaContext, mark its future direction, which
should see it shed a lot of nonsensical methods.
Change-Id: Ibdaf52e45076006e979204ac75e7bae6aeffd29a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Feb 2018 11:27:33 +0000 (12:27 +0100)]
yang-parser-impl supports ASTSchemaSource
yang-parser-rfc7950 supports bridging parsing from ASTSchemaSource,
which is an intermediate product of parsing from YangTextSchemaSource.
Make sure we propagate this capability from YangParserImpl, so that
users can efficiently integrate with it. While we're in the area
teach YangStatementStreamSource how to instantiate itself from
an ASTSchemaSource and add ASTSchemaSource.toString().
Change-Id: I0b6440b6fc4e7522c70261cffcef0afafed8ba53
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 1 Feb 2018 10:09:35 +0000 (11:09 +0100)]
Fix invalid enum definition error string
This is a copy&paste problem, the string should not be referencing
bits but enums.
Change-Id: I5adc98a5db92b88bf7e20dcc6141213347858f58
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 25 Jan 2018 15:17:11 +0000 (16:17 +0100)]
Mark metainf-services
Until we get odlparent-3.0.3 with a fixed declaration, fix our features
by marking metainf-services as provided.
Change-Id: If54a0a89dade4e2a4aed4ddf84d0abae5b11fc24
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 19 Jan 2018 08:50:41 +0000 (09:50 +0100)]
Add checkstyle-logging to yangtools-artifacts
All artifacts should be communicated to downstreams, fix that.
Change-Id: Ida1ca8cfd6162ed7fb54d512b69821df5d666686
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Thu, 18 Jan 2018 18:14:51 +0000 (19:14 +0100)]
Start 2.0.2 release cycle
Bump versions by 0.0.1.
Change-Id: I67e5db2ed702ed53336c7ba207c0c89c4b9fa17a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 16 Jan 2018 16:21:50 +0000 (17:21 +0100)]
YANGTOOLS-844: Filtering/SimpleSchemaContext violate getModules() contract
getModules() is explicit about how the modules should be ordered,
which is not compatible with ModuleDependencySort. As it turns out
ModuleDependencySort is only needed in MD-SAL codegen, where we
already invoke it explicitly.
Explicitly sort modules according to requirements of getModules(),
fulfilling that contract.
This also affects findModule(String) and related functions, which
are sorted, but in inverse order of what is specified. Fix that
by adjusting AbstractSchemaContext.REVISION_COMPARATOR and
introducing NAME_REVISION_COMPARATOR for use in places where modules
are not guaranteed to have a unique name.
Change-Id: Ie91685b830694764158381e4696e3f7d5bb57fba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 16 Jan 2018 16:18:04 +0000 (17:18 +0100)]
Fix a nullness thinko
toRevision cannot reasonably be null, as it already is an Optional,
hence the check here is incorrect and should instead check for
non-presence.
Change-Id: I93658ce5993aed1a02f4ad25121e11b3f31d356a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 8 Jan 2018 19:40:48 +0000 (20:40 +0100)]
Bump odlparent version to 3.0.2
This adopts odlparent 3.0.2 to speed up builds.
Change-Id: If5155e1d070133ccd673efe3d5bb95d97127571a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 2 Jan 2018 10:23:44 +0000 (11:23 +0100)]
YANGTOOLS-841: Fix SchemaContextUtil.findNodeInSchemaContext()
When performing recursive node lookup, consider
{Action,Notification}NodeContainers, so that we correctly resolved
nested actions and notifications -- which are new elements in RFC7950
metamodel.
Also generalized RPC input/output lookup to work on actions, too.
Change-Id: I877061c7f0370caf1ed04eb9420a43af3b2d3915
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
d027a59601cfbbc912e00e351eeb35a27dcc3bc2)
Atul Gosain [Wed, 29 Nov 2017 02:07:08 +0000 (18:07 -0800)]
Handling empty text nodes
This is a fix for an issue seen in the patch 63984 on yangtools.
It handles text nodes which are empty.
Change-Id: I6cf1096c511758154df6121d26bf36184385403f
Signed-off-by: Atul Gosain <agosain@luminanetworks.com>
Robert Varga [Wed, 27 Dec 2017 15:48:01 +0000 (16:48 +0100)]
YANGTOOLS-766: expand test suite
This patch adds explicit tests for serialization/deserialization
of instance identifiers for both JSONCodecFactorySuppliers.
Change-Id: Id1ba4764573bf2bde566c89c28e2ffc55cb982dc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 27 Dec 2017 01:00:26 +0000 (02:00 +0100)]
YANGTOOLS-766: add RFC7951JSONInstanceIdentifierCodec
RFC7951 non-present prefixes result in last argument namespace reuse,
hence refactor AbstractStringInstanceIdentifierCodec to allow for QNames
to be instantiated using a memoized QNameModule.
The default implementation routes to createQName("", localName), which
preserves backwards compatibility. A specialized subclass
of JSONInstanceIdetifierCodec is created to use memoized QNameModule,
and it is wired to RFC7951 codec supplier.
A similar update is done in AbstractNamespaceCodec, where appendQName()
alternative, which is forwarded the last encountered QNameModule is
added -- the default routes to normal appendQName(), with RFC7951
comparing last QNameModule with current QName's and skipping prefix
serialization if they match.
This is sufficient to make related unit test pass, so remove @Ignore
from it and expand it to assert the decoded YangInstanceIdentifier.
Change-Id: Iec7996d0e1d759623c3cabcbaf0164737afa1649
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 26 Dec 2017 10:57:08 +0000 (11:57 +0100)]
YANGTOOLS-766: introduce JSONCodecFactorySupplier
We need two separate instances of JSONCodecFactory factory methods,
each with its own conformance, so that we can properly spin out
codecs compliant to RFC7951 and draft-lhotka-netmod-yang-json-02.
This patch provides a new API entrypoints for specifying these, without
actually providing distinct codecs. It also provides proper JsonParserStream
factory methods which take JSONCodecFactory instead of plain SchemaContext
(and thus assuming JSONCodecFactory implementation).
Change-Id: Ib2b402ed865903432645632e89c9b0e04851a05c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 26 Dec 2017 11:21:29 +0000 (12:21 +0100)]
YANGTOOLS-678: enable empty key verification
Now that we are using a non-null value to represent empty leaves,
empty types are a fair game in codecs. Remove @Ignore from JSON/XML
tests which demonstrate the ability to decode empty keys in
YangInstanceIdentifier, which means proper addressing can be done
and works as expected.
Change-Id: Ib0aee3b99d40868d32e62811c2f82c1c42ef0833
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 18:41:05 +0000 (19:41 +0100)]
Expand yang-parser-spi unit tests
This patch adds a very basic unit test suite to assert various
aspects of the SPI package.
Change-Id: Ifd68fad33bff3b74579202327b28822b8ce5626d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 12:53:37 +0000 (13:53 +0100)]
Implement Uint{8,16}.valueOf(String, int)
This adds a simplistic implementation deferring parsing to
Short/Integer.valueOf(String, int) and performing range checking.
Also expands the test suite to cover Uint{8,16,32,64}, which flushes
out a bug in Uint64's handling of cache slots -- this is fixed, too.
Change-Id: I8fa977028a6f00ee8f25a19fdd2fd5d2b08b4bfa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 11:58:44 +0000 (12:58 +0100)]
Add Decimal64.{int,long,short}ValueExact()
Add alternative methods which prevent loss of precision by throwing
ArithmeticException. Testing has revealed that valueOf(Integer.MIN_VALUE)
does not work correctly due to the fact negation does results in incorrect
bitmask -- which is fixed by widening conversion.
Change-Id: I206ced685d2edb753507f5d45e29bb6b405ff421
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 15:09:48 +0000 (16:09 +0100)]
Add Revision test suite
This adds a simplistic test suite for testing Revision class.
Change-Id: Ibed986f5c53e7f201c3eb16cf448e022b09e6b85
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 14:29:17 +0000 (15:29 +0100)]
Add YangNames test
This adds a simplistic test to ensure YangNames.parseFileName() works
as expected.
Change-Id: Ic619ebdce2a0641418283b4621be4c676341a053
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 25 Dec 2017 14:24:44 +0000 (15:24 +0100)]
Add YangVersion test
Add a simple test suite to ascertain YangVersion works as expected.
Change-Id: I52d4d81f25f35443309dae8c93cbc91e705810ba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Michael Vorburger [Wed, 13 Dec 2017 23:35:14 +0000 (00:35 +0100)]
Fix slf4j usage errors found by checkstyle-logging
Change-Id: Iff0203d373d33a77ebfe2a8da190e6b927913b4e
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Robert Varga [Wed, 20 Dec 2017 13:07:21 +0000 (14:07 +0100)]
YANGTOOLS-838: detect grouping identifier shadowing
RFC7950 sections 5.5 and 6.2.1 explicitly forbid identifier
shadowing. Update grouping support to detect and report this
violation.
This patch also fixes typedef support to correctly detect
forward shadowing, when a nested conflicting typedef shadows
a sibling which occurs later in the model text.
Change-Id: I7c67c93c5f13b24657454e13d8b329338f98d7b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 3 Dec 2017 13:08:50 +0000 (14:08 +0100)]
Fix javadoc typo
Remove a repeated sentence.
Change-Id: I4d5f8faad2c23fe89bdba0f91847cba10dc76ecb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Stephen Kitt [Mon, 27 Nov 2017 17:21:05 +0000 (18:21 +0100)]
Drop obsolete Maven site configuration
See
https://lists.opendaylight.org/pipermail/odlparent-dev/2017-November/001492.html
Change-Id: I2735d334673209dd08b677be7de0c4d368e3a8ca
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Robert Varga [Mon, 27 Nov 2017 18:05:38 +0000 (19:05 +0100)]
Bump versions to next development cycle
Change-Id: I3e243ab59fbaa1ef0662761d03f6ac03db2ce755
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
jenkins-releng [Sat, 25 Nov 2017 01:09:04 +0000 (01:09 +0000)]
Release yangtools
Change-Id: I154e2a2bec3171736675e3ac8d574184ce441d2b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 24 Nov 2017 14:14:44 +0000 (15:14 +0100)]
Bump odlparent to 3.0.1
Pull in 3.0.1, as it fixes karaf distribution build.
Change-Id: I9ef1e93987a58393ebb2d32eb71c81cb872ef265
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 22 Nov 2017 00:20:31 +0000 (01:20 +0100)]
Clarify SchemaContext getModules() API contract
This clarifies the API contract with regards to iteration ordering
and shuffles the methods around a bit. Also creates additional index
for looking up Module by its QNameModule, which is common when
dealing with NormalizedNode encoding.
Change-Id: I76a8f2f24f4a70e0cf4fab544de6d79e1b476103
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Michael Vorburger [Tue, 21 Nov 2017 15:54:08 +0000 (16:54 +0100)]
Remove deprecated methods without loggerIdentity from SpecialExecutors
for https://jira.opendaylight.org/browse/CONTROLLER-1793
in order to force downstream projects (controller & mdsal) to use the
new methods when they upgrade to yangtools 2.0.0. The thing is that we
cannot fix CONTROLLER-1793 in the current controller & mdsal before
switching to yangtools 2.0.0 anyway, because SpecialExecutors didn't
have the (my) previous change adding the loggerIdentity anyway. So we
might as well do this in one round, instead of keeping these deprecated,
then once we are on yangtools 2.0.0 switch them, and then remove them?
Change-Id: I6a401979d71696536f23e1c5d1665149600f9876
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Robert Varga [Tue, 21 Nov 2017 12:31:53 +0000 (13:31 +0100)]
Eliminate use of deprecated checkstyle interfaces
Update constructors to use their non-deprecated equivalents.
Change-Id: Ibbb72e21b74f6a9c7f0ba90af7b3ec7717d68d81
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 21 Nov 2017 11:49:29 +0000 (12:49 +0100)]
Cleanup DataTree interfaces and InMemmoryDataTreeFactory
TipProducingDataTree is a remnant of an API freeze, merge its behavior
into baseline DataTree, adjusting callers.
Also make sure we publish DataTreeFactory properly, so users do not
have to rely on specific implementation -- cleaning up tests in process.
Change-Id: Ic2263a084ba7b8d2c611eb14407e09a78f6d922a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Stephen Kitt [Wed, 15 Nov 2017 20:31:37 +0000 (21:31 +0100)]
Bump odlparent dependencies to 3.0.0
Change-Id: I6efb03faf8913c5f4ad21fa7783ce8b6342447af
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Michael Vorburger [Sat, 4 Nov 2017 03:31:25 +0000 (04:31 +0100)]
Fix FindBugs violations and enable enforcement in utils
Change-Id: I35eff969e51d6ec9b4f4b79b1b8cb2af9b9a8150
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 20 Nov 2017 16:34:07 +0000 (17:34 +0100)]
Rename ChoiceCaseNode to CaseSchemaNode
ChoiceCaseNode is a long-standing misnomer, causing API inconsistency
in yang-model-api. Rename it to CaseSchemaNode, just as all the other
SchemaNodes.
Change-Id: I4f2fa74a69a75ab9b7cd40d27ad756285486a791
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 20 Nov 2017 16:20:22 +0000 (17:20 +0100)]
Fix a few warnings
- potentially static method
- unneeded else statement
- raw RangeConstraint reference
Change-Id: Ic0fb58556f95970bbd06f3716965f97b0ea41e9a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 20 Nov 2017 13:13:31 +0000 (14:13 +0100)]
YANGTOOLS-813: add parent schemapath to error report
It is not immediately clear in what context the search is being
made -- make sure we report parent path, too.
Change-Id: I86a15b409c6241d93f24ee75cc68ff78fc067ebc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 20 Nov 2017 13:31:20 +0000 (14:31 +0100)]
Make EffectiveStatements with @Beta
Newly-introduced EffectiveStatement interfaces are not finalized,
hence mark them with @Beta.
Change-Id: I0bdec482d50d71f367202baef466113e9a0f99bb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Peter Kajsa [Tue, 17 Oct 2017 16:52:05 +0000 (18:52 +0200)]
YANGTOOLS-812: Add SchemaContextFactory control of deviations
This patch adds missing API and implementation for setting supported
deviations in SchemaContextFactory.
In order to avoid passing of numerous arguments into
createSchemaContext(..) method a concept of a
SchemaContextFactoryConfiguration has been introduced in this patch,
which encapsulates all options possible to set.
Change-Id: I8eef54d729b7bfed4cee41ee6758d969fc375dcf
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 20 Nov 2017 12:00:00 +0000 (13:00 +0100)]
XPath evalution should identify result type
When we select a set of NormalizedNodes, we need to also report
their path, so they can be correctly correlated to schema. Fix
XPathNodesetResult to include this information.
Change-Id: I704cf5512caecb7e90c6130ef6a7809ff92d0fc2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 20 Nov 2017 09:06:24 +0000 (10:06 +0100)]
Auto-generate yang-data-jaxen services
Instead of including a static resource, generate it at compile
time.
Change-Id: I079e443668e679f5580d7954161118a99e2032d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 8 Nov 2017 13:36:20 +0000 (14:36 +0100)]
Populate yang-parser-api
This adds a simpistic API to access a pre-configured YANG inference engine,
so its complexities are hidden from users. Both a ServiceLoader and OSGi
loading interface is provided.
Change-Id: Iab444bd1698273c30ac37b8d3ea577ae35db71e7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Stephen Kitt [Thu, 16 Nov 2017 11:14:02 +0000 (12:14 +0100)]
Add bundle packaging for yang-data-transform
This allows the module to build an OSGi bundle instead of a plain
JAR.
Change-Id: I2713fdf0aefcccf589984a7271591f4cb95d1d30
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Stephen Kitt [Thu, 19 Oct 2017 16:52:14 +0000 (18:52 +0200)]
Use version ranges for odlparent dependencies
This allows odlparent version bumps to proceed without requiring
synchronised bumps in integration/distribution.
Change-Id: I123bd83bbd4ed43416bdc1958b111b8964d73dbb
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Robert Varga [Wed, 15 Nov 2017 22:37:33 +0000 (23:37 +0100)]
Turn StatementSupports into singletons
Since we are exposing these for potential reuse, we need to take
into account the possbility these being needed more than once.
Add getInstance() to share instances.
Change-Id: I9765c521ca7b92915b53da2b3e4ab4e15b445c1d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 15 Nov 2017 10:22:48 +0000 (11:22 +0100)]
Document namespace behaviours using singletons
This patch creates constants named BEHAVIOUR to hold the behaviour
for each namespace. This prevents confusion in defining the reactor
and also allows for instance reuse.
Change-Id: Ia03cbd3f8f6aac664895356d9aea89d54e2eb391
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Fri, 3 Nov 2017 22:05:10 +0000 (23:05 +0100)]
Add support for RFC6536 extensions
This patch adds support for parsing RFC6536 extensions and related
concepts for end users.
Change-Id: I41ae3192b74660be409c63bbec82a1a14c7de4af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Wed, 18 Oct 2017 12:30:36 +0000 (14:30 +0200)]
Bump odlparent to 3.0.0-SNAPSHOT and fix breakages
This patch bumps the odlparent version, bringing in changes
in that release. This break checkstyle-logging, which is fixed
here.
Change-Id: Iee8fae0c70c83add3f4e7bade75eb86bf8f4d4bc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Robert Varga [Tue, 14 Nov 2017 01:07:56 +0000 (02:07 +0100)]
YANGTOOLS-833: redefine features
Define both stable/experimental repositories and reorganize
features to have proper scope. Let's not split codecs as
we want to encourage cross-codec support.
Change-Id: I314cbc402af8ccfa35d60cbf9e76afe5f66edd47
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Tue, 14 Nov 2017 00:36:45 +0000 (01:36 +0100)]
YANGTOOLS-833: Eliminate unneeded dependencies
Trim down dependencies to their bare minimum. This is needed
to properly define our features.
Change-Id: Ie97992c4415509206e72556d49a446e48f5d5028
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 12 Nov 2017 20:18:12 +0000 (21:18 +0100)]
YANGTOOLS-706: move odlext parser support
Use composition with a delegator pattern to implement
YangModeledAnyxmlEffectiveStatementImpl. Also adjust the pattern
used to bring in extensions. This forces them to be be aware
of yang-parser-rfc7950, which is fine, as that is the reactor
they can generally expect to be configured.
Change-Id: I91aa95221efb76753d9ea82dc164c1fffc6755c7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 13 Nov 2017 11:51:48 +0000 (12:51 +0100)]
Add support for overriding statement supports
If an extension needs to build a different implementation of a statement,
it needs to be able to override previous definition. Alternative is to
force users to special-case support when building a reactor, which is not
really feasible.
Add overrideSupport(), which performs a replacement operation, but requires
properly-targeted bundle.
Change-Id: Id9b527c115c7a6b815227f8dc796473803bf8a80
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 12 Nov 2017 18:57:58 +0000 (19:57 +0100)]
YANGTOOLS-706: separate out RFC8040 extension support
yang-data support should live in its own artifact, now that it can
(with proper UT), move it out of yang-parser-impl.
Also refactor the way extensions are exposed to be consistent with
yang-parser-rfc7950: each extension needs to expose StatementSupports
and NamespaceBehaviours.
Change-Id: Ia691bd9ab4dd78c076ac7874fc91d9e597a8d2cc
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Mon, 13 Nov 2017 16:08:58 +0000 (17:08 +0100)]
Fix checkstyle issues reported by odlparent-3.0.0's checkstyle
This is a preparatory patch, cleaning up violations which will be
enforced by odlparent-3.0.0.
Change-Id: I0ea6b387c9d3095ff01c8e00d10c6d9d0c29aec9
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Claudio D. Gasparini [Mon, 13 Nov 2017 07:22:50 +0000 (08:22 +0100)]
BGPCEP-717: Reduce log levels
Investigation udner bgp shows that
SubstatementContext is creating 1 GB spam under
tests outputs.
Change-Id: I3fe1f93db57841fca733561ed1efc3b8b4061827
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
Robert Varga [Sun, 12 Nov 2017 18:07:00 +0000 (19:07 +0100)]
Correct YangData{SchemaNode,EffectiveStatement} interfaces
These remain tightly bound, but YangDataEffectiveStatement provides
its proper argument in its parlance.
Change-Id: I7862cb6e594f661edea39ced468f680a869bc437
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 12 Nov 2017 14:18:10 +0000 (15:18 +0100)]
YANGTOOLS-829: Wire extension support into default reactor
Since we have reorganized, we can now safely pull in extension
supports into DefaultReactors without causing dependency cycles.
Change-Id: I6214ec374ba2320aa7fe20c436749a3df4732a57
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
Robert Varga [Sun, 12 Nov 2017 03:26:44 +0000 (04:26 +0100)]
YANGTOOLS-706: Split out yang-parser-rfc7950
With the internal reorganized, we can now safely split off core
rfc7950 parser and turn yang-parser-impl into a wiring artifact,
which pulls in all the bits and pieces and exposes a user-friendly
interface.
Change-Id: Iea3b8f2d76e37c6e0d37620356f7b824f3cfb249
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>