yangtools.git
8 years agoCleanup a few warnings 90/27490/3
Robert Varga [Sat, 26 Sep 2015 12:38:28 +0000 (14:38 +0200)]
Cleanup a few warnings

Import ordering, methods which can be made static.

Change-Id: I0448e21fde4d54f264429ebbd0928b408d29af65
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove unused imports 41/27941/5
Robert Varga [Sun, 4 Oct 2015 22:21:22 +0000 (00:21 +0200)]
Remove unused imports

Just a drive-by cleanup job.

Change-Id: I2b6620ee970e1bdaf0c2f99a61f089f46817c03f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoLeafRefUtils is a utility class 65/27565/4
Robert Varga [Tue, 29 Sep 2015 05:34:48 +0000 (07:34 +0200)]
LeafRefUtils is a utility class

Should be final with a private constructor.

Change-Id: I5c45da74cc3cefc51094e3663beba690c08eef9d
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 4349: Allowed UnkeyedListItem to be start event in Writer. 16/28316/2
Tony Tkacik [Tue, 13 Oct 2015 08:13:58 +0000 (10:13 +0200)]
Bug 4349: Allowed UnkeyedListItem to be start event in Writer.

Change-Id: I42fd224974e6fcc691c548978beebce9a6828257
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBug 4412: New yang parser effective statements cleanup 44/27744/6
Filip Gregor [Fri, 9 Oct 2015 12:43:44 +0000 (14:43 +0200)]
Bug 4412: New yang parser effective statements cleanup

- improved classes hierarchy and reduced source code duplicity
- fixed some major sonar issues

Change-Id: Ibec3da63b0a3ab0616402b52798e9450df7feb70
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Filip Gregor <filip.gregor@pantheon.sk>
8 years agoBUG-4322: Leafref should not have a default value 53/28253/2
Robert Varga [Sat, 10 Oct 2015 18:05:18 +0000 (20:05 +0200)]
BUG-4322: Leafref should not have a default value

RFC6020 does not mention anything about the default value for leaf
references.

Change-Id: I0edcfe286aa6ac6fd93bb5f0074a51aeb18627d8
Signed-off-by: Robert Varga <nite@hq.sk>
8 years agoBUG-4261: convert JSON parser to pass down SchemaNode information 48/28248/3
Robert Varga [Fri, 9 Oct 2015 17:14:51 +0000 (19:14 +0200)]
BUG-4261: convert JSON parser to pass down SchemaNode information

Change-Id: I2519e3b77d88394c425e79610208a7c8d4a98b9f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261: make ImmutableNormalizedNodeStreamWriter DataSchemaNodeAware 47/28247/3
Robert Varga [Fri, 9 Oct 2015 17:56:47 +0000 (19:56 +0200)]
BUG-4261: make ImmutableNormalizedNodeStreamWriter DataSchemaNodeAware

ImmutableNormalizedNodeStreamWriter can perform leaf node interning when
it knows what the schema is. Turn it into a DataSchemaNodeAware, so
users can pass down this information and make use of it when adding
leaves.

Change-Id: I7566a8705c0a05ea3cfa1335c7335021de6edccc
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261: introduce DataSchemaNodeAware NormalizedNodeStreamWriter 46/28246/3
Robert Varga [Fri, 9 Oct 2015 16:31:02 +0000 (18:31 +0200)]
BUG-4261: introduce DataSchemaNodeAware NormalizedNodeStreamWriter

This variant allows passing a DataSchemaNode from the user.
Implementations can take advantage of this information to optimize their
result. Utility no-op adaptors are provided, too.

Change-Id: I990197baf3a80f9826cd35d3bb3155d1b7a10cc3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4261; split NormalizedNodeInterners 45/28245/3
Robert Varga [Sat, 10 Oct 2015 11:46:55 +0000 (13:46 +0200)]
BUG-4261; split NormalizedNodeInterners

As it turns out, having separate classes is easier for users.
LeafsetEntryInterner can be used to check the type once and then rely on
this check. LeafInterner returns a no-op instance for convenience if the
schema is not available.

Change-Id: Iec2117be2f91114943d2896a6bfb273f683ea042
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse StringBuilder instead of StringWriter 44/28244/2
Robert Varga [Fri, 9 Oct 2015 16:59:31 +0000 (18:59 +0200)]
Use StringBuilder instead of StringWriter

We do not need a Writer interface, as we are simply compositing a
String.

Change-Id: Ied863fe0bf39e99dffe83c2520c56e735d4102d4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSuppress Version.nextVersion() warning 43/28243/2
Robert Varga [Fri, 9 Oct 2015 16:31:27 +0000 (18:31 +0200)]
Suppress Version.nextVersion() warning

The method could be static based on the currect implementation, but we
want to keep it an instance-method.

Change-Id: Ibb604f1038e6df9a6731504af67dc7d960dee6bf
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4407: Fix a typo in Decimal64 range tables 49/28249/3
Robert Varga [Sat, 10 Oct 2015 13:47:30 +0000 (15:47 +0200)]
BUG-4407: Fix a typo in Decimal64 range tables

Simple typo results in both wrong range enforcement and an out-of-bounds
error with fraction-digits == 18.

Change-Id: I3e9916940e80fbeedadfdc9e8db35b584ea3e859
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
8 years agoBug 4314: maven plugin: switch logging 54/27354/3
Igor Foltin [Tue, 6 Oct 2015 11:43:45 +0000 (13:43 +0200)]
Bug 4314: maven plugin: switch logging
          to slf4j

Cleaned up use of maven Log in
yang-maven-plugin and switched to
slf4j.

Cleaned up use of static method
Util.message.

Change-Id: I6bf77b761facabfec5ba3a64b193e41b4dfc870f
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
8 years agoBug 3899: Increase test coverage for YangTools 45/28045/2
Filip Gregor [Thu, 8 Oct 2015 08:31:10 +0000 (10:31 +0200)]
Bug 3899: Increase test coverage for YangTools
yang-parser rfc6020 effective type test coverage

Change-Id: I2cfc8eab9d52070907d53a8dacd376ffa2a1a170
Signed-off-by: Filip Gregor <filip.gregor@pantheon.sk>
8 years agoBUG-4359: use WRITE-implied metadata 24/27924/3
Robert Varga [Mon, 5 Oct 2015 17:30:13 +0000 (19:30 +0200)]
BUG-4359: use WRITE-implied metadata

When we apply an operation under a WRITE node, we need to look up the
metadata based on that write to correctly understand what the effect of
this operation is.

This is important when we modify data introduced by the WRITE node, as
without this lookup a WRITE/DELETE combination on the child will result
in a NONE logical operation, which means data introduced in the WRITE
node will not be modified and seemingly reappear.

Change-Id: I5a5a67470f1f8baafc7a71069341dead073ba84a
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4407: Fix Decimal64 range enforcement 81/27881/4
Robert Varga [Sun, 4 Oct 2015 02:32:00 +0000 (04:32 +0200)]
BUG-4407: Fix Decimal64 range enforcement

Baseline ranges did not take into account the number of fraction digits,
but rather instantiated the most permissive range. Fix this by
pre-calculating all ranges specified in RFC6020 Section 9.3.4.

Also enforce SchemaPath presence, as that is the unique identifier of
the type.

Change-Id: I5e8799da618398ba458606226e71e434f5214f33
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSpeed-up look up of namespace listeners. 68/27968/1
Tony Tkacik [Tue, 6 Oct 2015 13:55:25 +0000 (15:55 +0200)]
Speed-up look up of namespace listeners.

Change-Id: Ie704318ddabc94cf87ee7902c0185812e721da43
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoFixed shared state in stateless ModuleStatementSupport. 90/27890/3
Tony Tkacik [Mon, 5 Oct 2015 08:42:27 +0000 (10:42 +0200)]
Fixed shared state in stateless ModuleStatementSupport.

Change-Id: I613e71b61038e7354db6a34559b5745baaeb7d09
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoSpeeded up ANTLR tree walk for statement parser. 83/27883/1
Tony Tkacik [Sun, 4 Oct 2015 16:36:32 +0000 (18:36 +0200)]
Speeded up ANTLR tree walk for statement parser.

Change-Id: I49b28a3cb97bb2bb4f0f133d2ed6c97293cf59bd
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoDeprecate InstanceIdentifierTypeDefinition.getRevisionAwareXPath() 82/27882/2
Robert Varga [Sun, 4 Oct 2015 05:14:55 +0000 (07:14 +0200)]
Deprecate InstanceIdentifierTypeDefinition.getRevisionAwareXPath()

This method has been added due to mis-reading of RFC6020. YANG actually
does not define this property, but rather specifies how
instance-identifier types are to be interpreted.

Change-Id: I484b655475f2817277b62dae5fc7462442ebf874
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse a proper NamespaceContext for XPaths 58/27858/6
Robert Varga [Fri, 2 Oct 2015 22:43:19 +0000 (00:43 +0200)]
Use a proper NamespaceContext for XPaths

Parsing an XPath which contains namespace prefixes requires a
NamespaceContext. Create a StmtContext-backed implementation and pass it
to XPath before we attempt to parse an XPath string.

Change-Id: Ib28cac2525ffcb6b8e3026e19e431cb9dc86c14b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRevert "Revert "Updated SchemaNodeIdentifier namespace handling."" 71/27871/2
Tony Tkacik [Sat, 3 Oct 2015 12:22:49 +0000 (12:22 +0000)]
Revert "Revert "Updated SchemaNodeIdentifier namespace handling.""

Bringing back updated augment lookup and validation code
which turned out to be correct, but unfortunatelly original
implementation of parser (from Hydrogen) accepted incorrect
values and "normalized" them to probably what user really intented.

New code is stricter and did not accept that input, since
it really was unclear what user intented.

Change-Id: I187c3479fd7bbb986f414805401e8b54f6b49ee0
Release-Note: Incompatible-Behaviour
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoCentralize RevisionAwareXPath creation 65/27865/5
Robert Varga [Sat, 3 Oct 2015 01:54:57 +0000 (03:54 +0200)]
Centralize RevisionAwareXPath creation

Three call sites are performing the same thing, create a common method.

Change-Id: I274f23b1785210cef96465e4db944c3b923886a8
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not compile augment/refine/deviate paths 64/27864/6
Robert Varga [Sat, 3 Oct 2015 01:41:35 +0000 (03:41 +0200)]
Do not compile augment/refine/deviate paths

These paths are not full XPaths, but rather SchemaNodeIdentifier paths.
Do not attempt to compile them, as we validate them by splitting and
look up of individual components.

Change-Id: If472ff6a2c795ce810794ad64dc643bf10a24199
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse a ThreadLocal XPathFactory 59/27859/8
Robert Varga [Sat, 3 Oct 2015 00:23:18 +0000 (02:23 +0200)]
Use a ThreadLocal XPathFactory

XPathFactory is documented to be non-threadsafe. While we could use
single shared instance, accessing it would require synchronization. Use
a ThreadLocal, so each thread gets its own instance.

Change-Id: I3f6a722df94d261c0680b30b9b65b73566350794
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoSplit keys into an ImmutableSet 57/27857/7
Robert Varga [Fri, 2 Oct 2015 23:36:12 +0000 (01:36 +0200)]
Split keys into an ImmutableSet

This simplifies building the set and results in memory-optimal set.

Change-Id: I16cde5188b7c473c8cac2943e587ff553cb31c05
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoExpose LIST_KEY_SPLITTER 56/27856/2
Robert Varga [Fri, 2 Oct 2015 23:06:22 +0000 (01:06 +0200)]
Expose LIST_KEY_SPLITTER

LIST_KEY_SEPARATOR is only ever used to instantiate a splitter, which is
what we already have a constant for. Remove LIST_KEY_SEPARATOR and make
its external user call LIST_KEY_SPLITTER, speeding it up.

Change-Id: I7144bd07903be4b2982f5341c5cdeb6956af5187
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoAdd @SafeVargs 55/27855/2
Robert Varga [Fri, 2 Oct 2015 22:55:46 +0000 (00:55 +0200)]
Add @SafeVargs

findFirstDeclaredSubstatement() gets an array of type-restricted Classes
and iterates over them. This is safe usage, hence the anotation is
appropriate.

Change-Id: Ie57f191623e723a34b76e8ea5fe39e3b04df4cb2
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 3876: Introduce support for XPath / XQuery queries on YANG Data 15/27815/2
Filip Gregor [Fri, 2 Oct 2015 13:28:21 +0000 (15:28 +0200)]
Bug 3876: Introduce support for XPath / XQuery queries on YANG Data
- unit test coverage increase 60%
- fixed broken xpath with predicates

Change-Id: I853772a28370cdf5901ec8b01ca3ad1d105bb854
Signed-off-by: Filip Gregor <filip.gregor@pantheon.sk>
8 years agoRevert "Updated SchemaNodeIdentifier namespace handling." 50/27850/1
Tony Tkacik [Fri, 2 Oct 2015 22:33:46 +0000 (22:33 +0000)]
Revert "Updated SchemaNodeIdentifier namespace handling."

This reverts commit b6e9bb9ff439eb0e905d8ccf61e15a5a3b2bf444.

Change-Id: I927dc1a9973ab36e7bc54c823e93fd00b240d123
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoUpdated SchemaNodeIdentifier namespace handling. 57/27757/8
Tony Tkacik [Thu, 1 Oct 2015 17:23:11 +0000 (19:23 +0200)]
Updated SchemaNodeIdentifier namespace handling.

Introduced notion of derived namespaces and SchemaNodeIdentifier
namespace for lookups of refine / augment and other statements

- Fixed AugmentUtils and AugmentStatementImpl, UsesStatementImpl
  to use declarative way to get needed artefacts instead of
  manual search in statement context.
- Removed utility methods, which are not needed anymore.

Change-Id: Ifb9c6dffa948cf265f81f2d8cd8615318b1447d0
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoAvoid NPEs in LoggerMustBeSlf4jCheck 31/27731/2
Stephen Kitt [Fri, 18 Sep 2015 16:15:35 +0000 (18:15 +0200)]
Avoid NPEs in LoggerMustBeSlf4jCheck

aAST.getFirstChild().findFirstToken(TokenTypes.IDENT) is often null in
ODL builds, so check it before retrieving the text.

Change-Id: Ic9905f72d1b2ac9bd902e8eb30b8f48f1b8930d2
Signed-off-by: Stephen Kitt <skitt@redhat.com>
8 years agoBUG-865: Deprecate ExtendedType 36/27836/2
Robert Varga [Fri, 2 Oct 2015 11:33:25 +0000 (13:33 +0200)]
BUG-865: Deprecate ExtendedType

This thing has been replaced with the more semantically correct (and
less confusing) DerivedType.

Change-Id: I4491a9c47f43b18a7d4d8a7edc08e201856ec7cc
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4400: make sure we retain input ordering 32/27832/1
Robert Varga [Fri, 2 Oct 2015 16:32:12 +0000 (18:32 +0200)]
BUG-4400: make sure we retain input ordering

For key statements we must retain the definition order, so use a
LinkedHashSet instead of a regular HashSet.

Change-Id: I9d327e571b895ee4b9dadeb5c5d0817e81a4906c
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFixed ordering of keys in key statement. 11/27811/1
Tony Tkacik [Fri, 2 Oct 2015 12:38:04 +0000 (14:38 +0200)]
Fixed ordering of keys in key statement.

Change-Id: I2a02ce7f9507ae292dac8b2173d3fb24e5fe00e5
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBaseTypes should reference into YangConstants 53/27753/5
Robert Varga [Thu, 1 Oct 2015 13:46:47 +0000 (15:46 +0200)]
BaseTypes should reference into YangConstants

We should not be duplicating namespace/module definitions.

Change-Id: Idc76a9caae2b78112b3c6ead4ac6772ea4d13222
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse shared Splitter instance 37/27737/6
Robert Varga [Thu, 1 Oct 2015 11:13:48 +0000 (13:13 +0200)]
Use shared Splitter instance

Do not instantiate a temporary splitter, but reuse the global one.

Change-Id: Ida0d6a725aab4731cd787ca6719e33c002422b5e
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFixed allModuleIdentifiers 96/27796/3
Tony Tkacik [Fri, 2 Oct 2015 09:28:57 +0000 (11:28 +0200)]
Fixed allModuleIdentifiers

allModuleIdentifiers was incorrectly populated from optional
part of API instead of required part of API,
which leaded to misrepporting identifiers to users.

Change-Id: I6e2d4b84137211fef1446b047cb6e5d3cea3101f
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoGeneral issue: In case of uncompilable XPathExpression, 30/27730/5
Martin Ciglan [Thu, 1 Oct 2015 09:33:20 +0000 (11:33 +0200)]
General issue: In case of uncompilable XPathExpression,
log warning rather than throwing exception.

Change-Id: I16b45cf57b9cf57e21221101cf66335059718982
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoUse a pre-compiled pattern in SchemaContextUtil 36/27736/3
Robert Varga [Thu, 1 Oct 2015 11:07:24 +0000 (13:07 +0200)]
Use a pre-compiled pattern in SchemaContextUtil

String.replaceAll() performs an implicit compilation -- use a
pre-compiled pattern instead.

Change-Id: I5323d19d8b6c009d837a14e32d91ba711cd4d486
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse explicit ImmutableList instead of FluentIterable 35/27735/3
Robert Varga [Thu, 1 Oct 2015 10:50:56 +0000 (12:50 +0200)]
Use explicit ImmutableList instead of FluentIterable

FluentIterable.transform() creates a temporary object which we do not
need -- just perform an ecplicit copy.

Change-Id: Ie599c1b0b7c4eb81fbfd5ab8a5a4c16389cb2fb7
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse odlparent-lite for artifacts pom 05/27705/2
Thanh Ha [Wed, 30 Sep 2015 21:50:25 +0000 (17:50 -0400)]
Use odlparent-lite for artifacts pom

Change-Id: I663bd08a28c4e7abc39e5b8eef8b9f1ab6664bf9
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
8 years agoCleanup AugmentUtils 51/27151/12
Robert Varga [Fri, 18 Sep 2015 09:39:42 +0000 (11:39 +0200)]
Cleanup AugmentUtils

Du no copy collections, user preconditions, use pre-instantiated sets
and similar.

Change-Id: I1fadd465650323504515e3df9393d42c8593c1e8
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoCleanup imports 18/27718/3
Robert Varga [Thu, 1 Oct 2015 06:44:16 +0000 (08:44 +0200)]
Cleanup imports

Unused imports should be removed. Also remove unused isMap local
variable.

Change-Id: I4c45aebe0538f84b87828ac9725cfe121d3befa3
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoCleanup TypeUtils 17/27717/3
Robert Varga [Thu, 1 Oct 2015 06:43:20 +0000 (08:43 +0200)]
Cleanup TypeUtils

Preconditions, Immutable{Map,Set}, comparator speed up.

Change-Id: Ib4a1673aa0c3bf11ec7c69b3b3fcf1352d7c4e56
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix performance issue in EffectiveStatementBase 20/27720/3
Tom Pantelis [Thu, 1 Oct 2015 07:11:28 +0000 (03:11 -0400)]
Fix performance issue in EffectiveStatementBase

While running some feature tests I took some thread dumps and noticed
the following stack trace in each:

java.lang.Thread.State: RUNNABLE
        at java.lang.Throwable.fillInStackTrace(Native Method)
        at java.lang.Throwable.fillInStackTrace(Throwable.java:783)
        - locked <0x00000000e5aff880> (a
          java.util.NoSuchElementException)
        at java.lang.Throwable.<init>(Throwable.java:250)
        at java.lang.Exception.<init>(Exception.java:41)
        at java.lang.RuntimeException.<init>(RuntimeException.java:51)
        at
java.util.NoSuchElementException.<init>(NoSuchElementException.java:47)
        at
com.google.common.collect.AbstractIterator.next(AbstractIterator.java:154)
        at com.google.common.collect.Iterators.find(Iterators.java:717)
        at com.google.common.collect.Iterables.find(Iterables.java:646)
        at
org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveStatementBase.firstEffective(EffectiveStatementBase.java:105)

The problem is that Iterables.find throws NoSuchElementException if not
found which is expensive when called many times. I changed it to call
tryFind instead which returns an Optional and this significantly
improved performance. The test time went from 15 min to 3 min.

There may be other classes that call Iterables.find - I didn't check.
If so they can be fixed in subsequent patches.

Change-Id: I0b3d02979b6d7fc97752c4b2429720b0807b853b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
8 years agoEnforce SchemaPath correctness 03/27203/4
Robert Varga [Thu, 28 May 2015 11:43:12 +0000 (13:43 +0200)]
Enforce SchemaPath correctness

SchemaPath must never contain a null element unless it is ROOT or SAME.
Current implementation allows that to happen by checking for null items
in the collections/lists it gets from the user.

Change-Id: Ibb85f84f54ad9c9049ac2ce8bb88371942b16880
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoCleanup yang-parser-impl Utils 52/27152/10
Robert Varga [Fri, 18 Sep 2015 09:52:45 +0000 (11:52 +0200)]
Cleanup yang-parser-impl Utils

Pre-compiled paterns, reused splitters and similar.

Change-Id: Ia8b6aebb0d3d1922018078b3e33ebba7e9740769
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoIntroduced ChildSchemaNodes namespace to parser 85/27685/2
Tony Tkacik [Wed, 30 Sep 2015 20:00:50 +0000 (22:00 +0200)]
Introduced ChildSchemaNodes namespace to parser

Use of purpose-built namespaces in new parser
simplifies code and speed ups search.

Introduced ChildSchemaNodes namespace in order
to speed up search for refines and uses.

Change-Id: Ie716b5798a3cca77dff3e3799383f82649273f97
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoFixed parser failing to continue parsing on '\n\n \n\n '" 79/27679/1
Tony Tkacik [Wed, 30 Sep 2015 16:56:43 +0000 (18:56 +0200)]
Fixed parser failing to continue parsing on '\n\n  \n\n  '"

Statement grammar used hidden tokens to skip comments
which in some cases when there was emtpy line, comment, empty
line ended up emitting two SEP tokens, but parser rules
were written expecting only zero or one SEP tokens.

Changing parser rules to expect multiple SEP tokens,
fixed that issue.

Change-Id: Ic3ea43f520582863681740534aa42739069056a3
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoFixed Enum statement not accepting allowed symbols. 58/27658/2
Tony Tkacik [Wed, 30 Sep 2015 13:40:20 +0000 (15:40 +0200)]
Fixed Enum statement not accepting allowed symbols.

Change-Id: I267e4f70d96d459f068553a7c265c9bc24d43006
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBug 4376: Fixed incorrect assumption about QName in extensions 50/27650/2
Tony Tkacik [Wed, 30 Sep 2015 13:11:41 +0000 (15:11 +0200)]
Bug 4376: Fixed incorrect assumption about QName in extensions

Original parser contained incorrect proactive code, which tried
to parse extension argument as QName even if it semantics was
not specified, this was carried to new parser as requirement
for argument which was incorrect.

Changed type of such statement to string and made QName parsing
optional.

Change-Id: I782390113b549b76c90a94604605e8bf2f4896bc
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBug 4378: New parser can't handle "}}" sequence 41/27641/1
Martin Ciglan [Wed, 30 Sep 2015 11:37:05 +0000 (13:37 +0200)]
Bug 4378: New parser can't handle "}}" sequence

Two and more subsequent occurences of right brace "}" shoudln't
be recognized by lexer as STRING.

Change-Id: Ic033e923b380f86cba424dec2fceae432d65c6e0
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoFixed some major sonar issues 88/27188/5
Igor Foltin [Mon, 21 Sep 2015 08:33:00 +0000 (10:33 +0200)]
Fixed some major sonar issues
in yang-parser-impl.

Change-Id: I056ae4effa76ffdd91407d61f80426c8c88f6ff4
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoBug 3670: Replaced YANG parser for new statement parser 26/25526/9
Peter Kajsa [Mon, 21 Sep 2015 11:05:48 +0000 (13:05 +0200)]
Bug 3670: Replaced YANG parser for new statement parser

Parser switch in yangtools:
- yang-maven-plugin switch to new parser
- repo and related classes e.g. SharedSchemaContextFactory, YangModelDependencyInfo, TextToASTTransformer
- parser switch in yangtools benchmarks

Yangtools retest:
- yang-maven-plugin-it test fix
- model-export SimpleModuleTest bug fix
- yang data unit tests fix
- yang-maven-plugin yang models from dependencies resolution fix
- additional unit tests switch to new statement parser
- extension definition fix in test models

Change-Id: I75c8b67af01212a8ac5b832625f9405bb0108455
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoMake initRanges() private 64/27564/2
Robert Varga [Tue, 29 Sep 2015 05:33:25 +0000 (07:33 +0200)]
Make initRanges() private

Sonar warngs about the method being overridable.

Change-Id: Ie804bd50d71b0935a87cffc2a0f0bc1e79de2ed0
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix sonar naming warnings 63/27563/2
Robert Varga [Tue, 29 Sep 2015 05:25:33 +0000 (07:25 +0200)]
Fix sonar naming warnings

Fields/constants should comply with naming conventions.

Change-Id: I8955e0408e508e7eba7cb90bab78218885b12d0a
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not instantiate QNameModules needlessly 39/27539/1
Robert Varga [Mon, 28 Sep 2015 15:09:31 +0000 (17:09 +0200)]
Do not instantiate QNameModules needlessly

Rather than using URL-based QName constructor, use a QNameModule-based
one, which saves object instantiation and results in potential reuse.

Change-Id: Ia0bd87743b062ed71c32d4d2ed2563525e681ce8
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not instantiate a temporary list 27/27527/1
Robert Varga [Mon, 28 Sep 2015 11:34:00 +0000 (13:34 +0200)]
Do not instantiate a temporary list

There is no need for a collection, use just the iterable.

Change-Id: I1a3587f74e3eac2ee249c31832623f63242b0839
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoIntroduce SchemaNodeIdentifier.asSchemaPath() 23/27523/3
Robert Varga [Mon, 28 Sep 2015 09:33:26 +0000 (11:33 +0200)]
Introduce SchemaNodeIdentifier.asSchemaPath()

Converting SchemaNodeIdentifier to a SchemaPath needs to be efficient,
reuse the fact the two classes are organized in the same way.

Change-Id: Ifa18f4378b66a94aa9f8e9d45fd274be9a517005
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse SchemaPath.getParent() 22/27522/1
Robert Varga [Mon, 28 Sep 2015 08:39:06 +0000 (10:39 +0200)]
Use SchemaPath.getParent()

Creating a parent SchemaPath is simple, no need to fork them.

Change-Id: I6c93e6a913fa582f8cd615deb992738f22afe0e0
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove YangInstanceIdentifierBuilder.toInstance() 46/22546/8
Robert Varga [Sun, 6 Sep 2015 08:24:55 +0000 (10:24 +0200)]
Remove YangInstanceIdentifierBuilder.toInstance()

This method has been renamed to build(), remove the old name.

Change-Id: I93ba014e8dc598d4e04b4278d750c76c6ce6232b
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse Objects.equals() in yang-model-util 09/27509/2
Robert Varga [Sun, 27 Sep 2015 16:25:33 +0000 (18:25 +0200)]
Use Objects.equals() in yang-model-util

Simplifies implementations of equals() considerably.

Change-Id: I1d86308156abdca36ad9c770621a82e852ad56ab
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse Objects.equals() in yang-data-impl 08/27508/2
Robert Varga [Sun, 27 Sep 2015 16:29:09 +0000 (18:29 +0200)]
Use Objects.equals() in yang-data-impl

Simplifies implementation of equals().

Change-Id: I4b69eba21c775a25c89a3ff0696dd5c2cb4e4696
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse Objects.equals() in yang-model-api 07/27507/2
Robert Varga [Sun, 27 Sep 2015 16:25:06 +0000 (18:25 +0200)]
Use Objects.equals() in yang-model-api

Simplifies and clarifies the code.

Change-Id: I1dba9eeeb9ce69be6de9f0fd4088ac6afa7d0e25
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse Objects.equals() in QName.equals() 06/27506/2
Robert Varga [Sun, 27 Sep 2015 16:24:38 +0000 (18:24 +0200)]
Use Objects.equals() in QName.equals()

Simplifies the code.

Change-Id: Ibac465c5bbc5a5ab8b5b3b40b5c57a042c93d095
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse Objects.equals() in effective statements 03/27503/3
Robert Varga [Sun, 27 Sep 2015 15:34:02 +0000 (17:34 +0200)]
Use Objects.equals() in effective statements

This simplifies equals() method implementations and performs various
obvious cleanups:
- boolean assignement via trigraph
- explicit isEmpty() before ImmutableList.copyOf()
- private fields

And adds a couple of FIXMEs for follow-up.

Change-Id: Id591cef7f777efaa02e0cb77d47245762a103363
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse SimpleImmutableEntry in ValueWithQName 01/27501/1
Robert Varga [Sun, 27 Sep 2015 12:22:09 +0000 (14:22 +0200)]
Use SimpleImmutableEntry in ValueWithQName

SimpleImmutableEntry gives us everything we need, there is no need for
duplicate (and incorrect from Entry interface definition) code.

Change-Id: I4490d9b5fc06547ee30fd05d31495a9a7005956e
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse Objects.hashCode() 00/27500/1
Robert Varga [Sun, 27 Sep 2015 12:15:29 +0000 (14:15 +0200)]
Use Objects.hashCode()

Use JRE-provided Objects.hashCode(), lowering the number of branches in
our code.

Change-Id: I90e8dc80253c6bed49d8d561faced71729cc62f4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix a few sonar warnings 99/27499/1
Robert Varga [Sun, 27 Sep 2015 11:48:00 +0000 (13:48 +0200)]
Fix a few sonar warnings

- redundant and misordered modifiers
- use java.util.Objects instead of Guava

Change-Id: Idfa45254bb30b4f308c51869b50b2883a56a85ed
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 3876: unit test coverage increase 42/27442/4
Filip Gregor [Fri, 25 Sep 2015 14:44:29 +0000 (16:44 +0200)]
Bug 3876: unit test coverage increase

Add a simple test suite, cleanup pom.xml and fix a couple of typos.

Change-Id: Ib40f1344bea339bcf89c6f7981ba2888b1fe255e
Signed-off-by: Filip Gregor <filip.gregor@pantheon.sk>
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoUse YangInstanceIdentifier.getAncestor() 89/27389/2
Robert Varga [Thu, 24 Sep 2015 09:05:23 +0000 (11:05 +0200)]
Use YangInstanceIdentifier.getAncestor()

Instead of limiting the path arguments, get the appropriate ancestor,
which results in consistent instance identifier formatting.

Change-Id: I2fc3447f8786c8d7a9ada68d8bf6fc0915591382
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 4321: Misconfigured input parameters in yang-maven-plugin (YangToSourcesMojo... 13/27113/2
Martin Ciglan [Thu, 17 Sep 2015 11:23:42 +0000 (13:23 +0200)]
Bug 4321: Misconfigured input parameters in yang-maven-plugin (YangToSourcesMojo.java)

Use of default values for 'required' & 'readOnly' elements of inspectDependencies
annotation type Parameter to not to disturb pom.xml files.
This has been discovered in IntelliJ IDEA environment.

Change-Id: I440c62b692001971ee60145203d6931aff0e0db3
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
8 years agoBug4231 - Yang tools failing to parse Augmentations under "uses" clause. 29/26329/4
Peter Kajsa [Wed, 2 Sep 2015 11:49:20 +0000 (13:49 +0200)]
Bug4231 - Yang tools failing to parse Augmentations under "uses" clause.

The problem occurs when uses-augment is nested in another Augment statement.
In this case the parent node of uses node is not subclass of SchemaNode
but it is AugmentationSchemaNode (it is not subclass of SchemaNode) and in
consequence class cast exception occurs.

Change-Id: I674392889e561f357297fa220051e8c3728f537d
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
8 years agoFixed some major sonar issues in yang-data-codec-json. 59/27159/6
Igor Foltin [Fri, 18 Sep 2015 12:55:47 +0000 (14:55 +0200)]
Fixed some major sonar issues in yang-data-codec-json.

Change-Id: I31f2342a226fc68742f9f892d7e9fff712fef282
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoFixed some major sonar issues in yang-data-api, yang-data-operations 09/27109/5
Igor Foltin [Thu, 17 Sep 2015 10:35:08 +0000 (12:35 +0200)]
Fixed some major sonar issues in yang-data-api, yang-data-operations

Change-Id: Ic099300378a864e119c10958f721efdfde81599d
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoFixed some major sonar issues 42/27042/6
Igor Foltin [Wed, 16 Sep 2015 10:58:27 +0000 (12:58 +0200)]
Fixed some major sonar issues
in checkstyle-logging and
yang-data-util.

Change-Id: Ie2e9753964c5e39d0288861e6f4301cd03d59de0
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoRemoval of migrated or obsolute artifacts. 49/26449/7
Tony Tkacik [Thu, 3 Sep 2015 09:52:59 +0000 (11:52 +0200)]
Removal of migrated or obsolute artifacts.

Removed artifacts which are obsolute or were
splitted off into MD-SAL projects.

Change-Id: I8238a67676f25c11388ad94d276252a8a67df535
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoFixed some major sonar issues in yang-validation-tool 02/26902/9
Igor Foltin [Mon, 14 Sep 2015 08:25:36 +0000 (10:25 +0200)]
Fixed some major sonar issues in  yang-validation-tool

Change-Id: Ifba514ef314df1829f8e1497238cfc3a7705bd0f
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoFixed some major sonar issues 41/26841/8
Igor Foltin [Fri, 11 Sep 2015 13:03:56 +0000 (15:03 +0200)]
Fixed some major sonar issues

- mockito-configuration
- websocket-client
- yang-common
- concepts

Change-Id: I5a418919e09ce7e423d31a64759349b9e05be5ad
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoFixed some blocker sonar issues in yang-data-impl 34/26834/7
Igor Foltin [Fri, 11 Sep 2015 11:30:23 +0000 (13:30 +0200)]
Fixed some blocker sonar issues in yang-data-impl

Change-Id: I0e8351ebd08b54cce8613c5628409249f5a042cb
Signed-off-by: Igor Foltin <igor.foltin@pantheon.sk>
8 years agoCleanup GroupingUtils 48/27148/4
Robert Varga [Fri, 18 Sep 2015 08:14:19 +0000 (10:14 +0200)]
Cleanup GroupingUtils

Use ImmutableSets to keep things efficient.

Change-Id: I3ba4b106908f28a0ad195c2619e1758350284345
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBug 3875: Introduced transforming stream writer 74/26274/7
Tony Tkacik [Tue, 1 Sep 2015 14:06:54 +0000 (16:06 +0200)]
Bug 3875: Introduced transforming stream writer

Introduced simple QName transforming stream writer
which could be used to re-stream and rebuild
YANG Data with replacement of QNames.

QNameTransformingStreamWriter currently supports
custom mapping, replacement of specified QNameModules
and replacement of specified QNames

Change-Id: I98b253a0f184e1996d78b99fa8cfb20a7d588b96
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
8 years agoBUG-4300: adjust unit tests 56/27156/1
Robert Varga [Fri, 18 Sep 2015 12:03:55 +0000 (14:03 +0200)]
BUG-4300: adjust unit tests

Previous patch has renamed classes and was not rebased on top of the UT
expansion, leading to unit tests being broken. Adjust checks to reflect
new class names.

Change-Id: I6ff782984527d0d81402746b85c2732f2ecd4660
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRefactor URLSchemaContextResolver 95/26995/3
Robert Varga [Tue, 15 Sep 2015 04:47:45 +0000 (06:47 +0200)]
Refactor URLSchemaContextResolver

For use with the yang-maven-plugin, we need the ability to register
different sources than URL. Since the internal machinery of
URLSchemaContextResolver already handles the tasks, factor it out to a
separate class.

Change-Id: Ie310f7ce4633b3f2fb7755bf4b0e3aa8e60c51a4
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoDo not instantiate a ByteSource 86/26986/3
Robert Varga [Tue, 15 Sep 2015 01:08:52 +0000 (03:08 +0200)]
Do not instantiate a ByteSource

YangTextSchemaSource is already a ByteSource, no need to wrap it again.

Change-Id: I938704862c44d7eef6fdc55996580026a4b755bb
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-865: Migrate tests to non-deprecated API 80/26980/5
Robert Varga [Mon, 14 Sep 2015 21:23:50 +0000 (23:23 +0200)]
BUG-865: Migrate tests to non-deprecated API

Prepare for the deprecated methods being removed

Change-Id: I0cbf84b4bda3535e70cd8dbe24e1708d6127e5de
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4300: Make Lazy*ContainerNode really lazy 96/26896/6
Robert Varga [Sun, 13 Sep 2015 20:27:03 +0000 (22:27 +0200)]
BUG-4300: Make Lazy*ContainerNode really lazy

Our LazyContainerNode/MaterializedContainerNode combo meant that a
TreeNode was either non-materialized (Lazy) or fully-materialized (after
it was touched again). This meant we could end up stalling for
significant amount of time (when a large map was materialized), or ended
up materializing leaves which can never be modified -- like key leaves
in a list.

This patch fixes the problem by introducing a middle stage, where only
children which were modified are tracked and requests to non-modified
children are served from the data portion. This means materialization
occurs gradually as needed -- preventing stalls and improving memory
efficiency.

Change-Id: I480f675423f8e1f0e999ad609e40093e3f4a267e
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoCleanup GroupingUtils 21/27121/4
Robert Varga [Fri, 18 Sep 2015 08:14:19 +0000 (10:14 +0200)]
Cleanup GroupingUtils

Reformat and use ImmutableSets to keep things efficient.

Change-Id: Ia6cb9befdd18995272b2f6510eb5d8b16476e6d9
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoRemove redundant final modifiers 27/27127/2
Robert Varga [Thu, 17 Sep 2015 15:11:00 +0000 (17:11 +0200)]
Remove redundant final modifiers

These were missed in previous conversion to final classes, remove them
to silence sonar.

Change-Id: I886b39b43842cedecddf8e018197751c2488b0be
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4309: include iana-afn-safi in model features 99/27099/3
Robert Varga [Thu, 17 Sep 2015 01:37:08 +0000 (03:37 +0200)]
BUG-4309: include iana-afn-safi in model features

This fixes a failure to package iana-afn-safi.

Change-Id: I68d53a9c30041da0196d9513872c1a05a661b18f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-2399: Introduce ModificationType.(DIS)APPEARED 24/26924/2
Robert Varga [Mon, 14 Sep 2015 07:34:11 +0000 (09:34 +0200)]
BUG-2399: Introduce ModificationType.(DIS)APPEARED

In order to support automatic container lifecycle, we need to expose new
semantics so users can understand their creation/deletion. This is
needed because no current type match the semantics without introducing
special-cases.

Change-Id: I733ff39b97fcdcb5677dd179d2bed87975b95b4f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-865: Remove ModificationType.MERGE 23/26923/2
Robert Varga [Mon, 14 Sep 2015 07:18:38 +0000 (09:18 +0200)]
BUG-865: Remove ModificationType.MERGE

MERGE type has been deprecated in Lithium and has not been emitted
anywhere.

Change-Id: I91584ce6ac75bedab2fec257ec4ac2e80cbdc895
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4109: Correct checkstyle dependency and avoid a couple of NPEs 54/26854/3
Stephen Kitt [Fri, 11 Sep 2015 14:39:39 +0000 (16:39 +0200)]
BUG-4109: Correct checkstyle dependency and avoid a couple of NPEs

We need to ensure that the version of checkstyle used to build the
plugin extension is the same as that used when running the
maven-checkstyle-plugin. (Otherwise, ABI changes break the checks,
notably changes in type values.) To do this, depend on the
maven-checkstyle-plugin; it's not particularly elegant but it gets the
job done.

Also fix a couple of places where a type or variable name is retrieved
before further checks which could be done beforehand. By doing the
risk-free checks before calculating the type or variable name, we
avoid NPEs.

Clean up an "if () { return true; } else { return false; }".

Change-Id: Iec696a7486e43f52db69befe12c6a053903c879d
Signed-off-by: Stephen Kitt <skitt@redhat.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-4288: check for existing child modification 81/26781/8
Robert Varga [Thu, 10 Sep 2015 17:48:26 +0000 (19:48 +0200)]
BUG-4288: check for existing child modification

When we are issuing a merge on a previously-written node we need to make
sure the written node's data is pushed down to child nodes. This could
have ended up overwriting nodes which have occured under and after the
write being replaced. Guard against this mishap with an explicit check.

Change-Id: I2425dc758b8099de349641cd3bef9949cfccf57c
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoBUG-3876: Add jaxen-based XPath evaluation component 21/23221/14
Robert Varga [Wed, 26 Nov 2014 21:09:10 +0000 (22:09 +0100)]
BUG-3876: Add jaxen-based XPath evaluation component

This the basic infrastructure needed to bridge NormalizedNodes with
jaxen. Given a SchemaContext and a NormalizedNode tree, users of this
component are able to evaluate XPath expressions.

Change-Id: Idbd0a7a954f725e84581fe63399ddf44df8e1333
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix checkstyle warnings in concepts 04/26904/3
Robert Varga [Mon, 14 Sep 2015 11:08:08 +0000 (13:08 +0200)]
Fix checkstyle warnings in concepts

This is just grooming various minor code layout things. Also deprecates
OrderedSet, as it is impossible to implement.

Change-Id: I94e0547644d8cfa4023103912758a7083c84ac8f
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoExpand yang-data-api test suite 61/27061/2
Robert Varga [Wed, 16 Sep 2015 16:02:29 +0000 (18:02 +0200)]
Expand yang-data-api test suite

This adds some trivial tests.

Change-Id: I76b2ed6d76657f9687d7ab1b449857f44ea22d67
Signed-off-by: Robert Varga <rovarga@cisco.com>
8 years agoFix sonar warnings is yang-parser-impl 70/27070/2
Robert Varga [Wed, 16 Sep 2015 18:50:24 +0000 (20:50 +0200)]
Fix sonar warnings is yang-parser-impl

Comments, boolean expressions at al.

Change-Id: Idad65cb6c001cd1d42cf99771c94468e7a87b5f0
Signed-off-by: Robert Varga <rovarga@cisco.com>