[YANGTOOLS-1372] Add support for purely-effective substatements Created: 30/Nov/21 Updated: 26/Oct/23 Resolved: 16/Dec/21 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | parser |
| Affects Version/s: | None |
| Fix Version/s: | 8.0.0 |
| Type: | New Feature | Priority: | High |
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Σ Remaining Estimate: | Not Specified | Remaining Estimate: | Not Specified |
| Σ Time Spent: | Not Specified | Time Spent: | Not Specified |
| Σ Original Estimate: | Not Specified | Original Estimate: | Not Specified |
| Issue Links: |
|
|||||||||||||||
| Sub-Tasks: |
|
|||||||||||||||
| Description |
|
StmtContext.Mutable does not expose the ability to conjure purely-effective statements, i.e. those which are truly inferred from overall context and do not have a DeclaredStatement counterpart. There are two use cases: implicit input/output statements in RPCs and Actions, which we cover through a rather ugly hack called StatementContextBase.appendImplicitSubstatement(). That part does still ends up creating a DeclaredStatement and also does not cover ModelStatement.argument() completely – for example it does not work for Expose a new method StmtContext.Mutable, which will create a truly effective-only statements. The argument should be an ImplicitStatementAwareSubstatementContext (or similar, as that is a mouthful), which is an additional interface implemented by things like InputStatementSupport and can work without a DeclaredStatement instance. |
| Comments |
| Comment by Robert Varga [ 12/Dec/21 ] |
|
The current infra actually does something different – it is adding implicit statements, i.e. those still have a DeclaredStatement, but that declared statement shows up as being StatementOrigin.DECLARATION. In the reactor this is implied by the use of SubstatementContext for these statements. In individual statements supports (which support this) it shows up as special-casing in createDeclared(). In yang-model-ri this manifests as ImplicitStatements – which end up recognized in factory methods and ignored. This needs to work quite differently:
The be-all end-all reason is that we do not have a reliable raw argument String, required for DeclaredStatements. The other is quick consistency checks to an opt-in behaviour – i.e. RpcStatementSupport can only use implicit input statements because InputStatementSupport knows how to deal with them – and that capability is not exposed as a trait (such as UndeclaredStatementFactory ), it is just an implementation detail. The third, minor one, is that we create bogus objects to dance around StatementContextBase's requirement of having a DeclaredStatement instance. |
| Comment by Robert Varga [ 13/Dec/21 ] |
|
Okay, this is a bit more complicated and boils down to ModelStatement.statementOrigin() and its interpretation in DeclaredStatement vs EffectiveStatement. Part of this is an implementation quirk of statement loading, where we end up inserting UndeclaredCaseStatement into DeclaredChoiceStatement: choice foo {
case bar;
container baz;
}
ends up looking like this: ChoiceStatement foo
DeclaredCaseStatement bar
UndeclaredCaseStatement baz
Container baz
The difference between Declared and Undeclared CaseStatements is only statementOrigin(). We have to account for this in yang-model-export and inline StatementOrigin.CONTEXT statements' substatements. We therefore need to perform a bit of house cleaning:
Once that is done, we can roll out proper specialized implementations. |