Add the ability to retain DeclarationReference 60/95160/19
authorRobert Varga <robert.varga@pantheon.tech>
Sat, 13 Feb 2021 15:12:19 +0000 (16:12 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 21 Apr 2021 06:26:07 +0000 (08:26 +0200)
commite4d18a98a261c277589f1270676c03233c79a4a6
tree2c0dd110574e1e880e8c17835ecf63af93f9a682
parenta10cb9551ddd43dac64c00fc4d8d55fb10e4011c
Add the ability to retain DeclarationReference

There are use cases where we would like to retain information about
where a statement was originally declared -- for example for use in
IDEs.

We already have a parser-internal representation of most of this
information in the form of StatementSourceReference, but that is not
retained in DeclaredStatements nor is it a public API.

Introduce DeclarationReference and its two specializations,
DeclarationInText and DeclarationInFile. These can be acquired via
DeclaredStatement.declarationReference().

Also provide integration between DeclarationReference and
StatementSourceReference, which will allow yang-parser-reactor to turn a
source reference into a declaration reference.

Finally add the basic substrate needed for forwarding decorators
that attach DeclarationReference to a delegate.

JIRA: YANGTOOLS-1193
Change-Id: I4e4d9567c83c08aab9de2a2685470835fadcd0d7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/DeclarationInFile.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/DeclarationInText.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/DeclarationReference.java [new file with mode: 0644]
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/DeclaredStatement.java
yang/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/meta/AbstractRefStatement.java [new file with mode: 0644]
yang/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/meta/ForwardingDeclaredStatement.java [new file with mode: 0644]
yang/yang-model-spi/src/main/java/org/opendaylight/yangtools/yang/model/spi/meta/ForwardingModelStatement.java [new file with mode: 0644]
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/StatementContextVisitor.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/StatementSourceReferenceHandler.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/DeclarationInTextSource.java [deleted file]
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ExplicitStatement.java [new file with mode: 0644]
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImplicitSubstatement.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/StatementSourceReference.java
yang/yang-parser-spi/src/test/java/org/opendaylight/yangtools/yang/parser/spi/source/ExplicitStatementTest.java [moved from yang/yang-parser-spi/src/test/java/org/opendaylight/yangtools/yang/parser/spi/source/DeclarationInTextSourceTest.java with 60% similarity]