Skip to content
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

Fixing broken leafref within grouping for UML plugin #852

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions pyang/plugins/uml.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,12 @@ def emit_stmt(self, mod, stmt, fd):
# for s in stmt.substmts:
# emit_stmt(mod, s, fd)

def emit_augmented_children(self, node, fd, augmented = True):
if augmented:
for children in [ch for ch in node.i_children if hasattr(ch, 'i_augment') and ch not in node.substmts]:
self.emit_child_stmt(node, children, fd)

def emit_child_stmt(self, parent, node, fd, cont = True):
def emit_child_stmt(self, parent, node, fd, cont = True, augmented = False):
keysign = ''
keyprefix = ''
uniquesign = ''
Expand All @@ -376,6 +380,7 @@ def emit_child_stmt(self, parent, node, fd, cont = True):
if cont:
for children in node.substmts:
self.emit_child_stmt(node, children, fd)
self.emit_augmented_children(node, fd, augmented)
elif node.keyword == 'grouping' and not self._ctx.opts.uml_inline:
self.emit_grouping(parent, node, fd)

Expand All @@ -384,6 +389,7 @@ def emit_child_stmt(self, parent, node, fd, cont = True):
if cont:
for children in node.substmts:
self.emit_child_stmt(node, children, fd)
self.emit_augmented_children(node, fd, augmented)

elif node.keyword == 'choice':
if not self.ctx_filterfile:
Expand Down Expand Up @@ -412,10 +418,11 @@ def emit_child_stmt(self, parent, node, fd, cont = True):
if grouping_node is not None:
# inline grouping here
# sys.stderr.write('Found target grouping to inline %s %s \n' %(grouping_node.keyword, grouping_node.arg))
for children in grouping_node.substmts:
# make the inlined parent to parent rather then the grouping to make full path unique
children.parent = parent
self.emit_child_stmt(parent, children, fd)
targets = [s.i_target_node for s in node.substmts if s.keyword == 'augment']
children = [ch for ch in parent.i_children if hasattr(ch, 'i_uses') and node in ch.i_uses]
for child in children:
child.parent = parent
self.emit_child_stmt(parent, child, fd, True, child in targets)

# moved stuff below here in order to include annotations for classes-only
elif node.keyword == 'description' and self.ctx_description:
Expand Down