-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GetOrderedChildren to Entries for Ordering of Dir #80
Open
carlverge
wants to merge
6
commits into
openconfig:master
Choose a base branch
from
carlverge:patch-1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2fc58c7
Add SequenceNum to Entries for Ordering
carlverge f6ef22d
Do not serialize SequenceNum to JSON
carlverge e8eccb3
Add test for sequence number
carlverge a631b5c
Move to using statements to find order of children
carlverge d20c657
Add test for OrderedChildren
carlverge 1d80a50
Remove old change
carlverge File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test; could you please extend it (either another case or modify this case is fine by me) to cover grouping and uses? Ones defined in the same module are fine for the test.
I'm guessing, but a useful test for this would be to define a uses inside of an "rpc" or "action" statement, because that's the (only?) place, where sequence order matters.
So, I imagine something along the lines of;
We'd expect the
SequenceNum
within theinput
statement to be:0 ->
id
1 ->
foo1
2 ->
foo2
3 ->
bar2
4 ->
bar1
5 ->
tail
For extra points, another case to test would be when an
augment
is applied to the*yang.Entry
in question. That's about all the expressions of(*yang.Entry).add()
I can think of.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correction: of course, in the
module sequence
above, the second instance ofgrouping testGroup1
should readgrouping testGroup2
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the uses statement contradicts the expected output. Apologies for the bad example, but I imagine you get the idea; we want to ensure that when the
uses
statement is scanned byToEntry
, we'll see the grouping being injected in the correct ordering.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appreciate the help here, figured it wouldn't be quite so easy. Looks like the biggest problem is group expansion, we lose ordering when that happens (groups are also merged into the parent node before other leaves).
Instead, taking another approach of trying to resolve the groups and recover the ordering from the AST appears to work in the nested group case. This is also possible from external modules:
I know there are corner cases this misses, I'm not sure how to get augments (not sure how to associate entries coming from an augment back to their augment).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the above will miss augments. Don't forget
choice
(and thencase
) statements, also - their children data nodes are naturally part of their parent schema node (aka parent*Entry
) and will be relevant to answering questions about child data definitions at that node.Augments cause direct changes to the
*yang.Entry
in their targets, so once they've been applied there's (currently) no straight-forward way to say that a*yang.Entry
was the result of an augmentation, though you could inspect its.Node
to see where it came from (it's normally but not required to be a different module, so scanning Parent-bound from the augmented Entry's Node will eventually hit an "augment" statement).Other than that, the only "easy" change I can imagine now without major refactoring is to store child entries in an additional slice managed by
(*yang.Entry).add()
. You'd then iterate over the slice, consideringchoice
andcase
statements you found along the way as relevant to your use case.That... may be simple, again the challenge is in the confirmation. Places which would have to be considered include
(*yang.Entry).FixChoice()
and(*yang.Entry).merge()
, in particular, along withadd()
.