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

Improve inheritance printers #162

Merged
merged 1 commit into from
Feb 5, 2019
Merged
Show file tree
Hide file tree
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
20 changes: 15 additions & 5 deletions slither/printers/inheritance/inheritance.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,26 @@ def output(self, filename):
if not self.contracts:
return

info += blue('Child_Contract -> ') + green('Base_Contracts')
info += blue('Child_Contract -> ') + green('Immediate_Base_Contracts')
info += green(' [Not_Immediate_Base_Contracts]')
for child in self.contracts:
info += blue(f'\n+ {child.name}')
if child.inheritance:
info += ' -> ' + green(", ".join(map(str, child.inheritance)))

info += green('\n\nBase_Contract -> ') + blue('Child_Contracts')
immediate = child.immediate_inheritance
not_immediate = [i for i in child.inheritance if i not in immediate]
info += ' -> ' + green(", ".join(map(str, immediate)))
if not_immediate:
info += ", ["+ green(", ".join(map(str, not_immediate))) + "]"

info += green('\n\nBase_Contract -> ') + blue('Immediate_Child_Contracts')
info += blue(' [Not_Immediate_Child_Contracts]')
for base in self.contracts:
info += green(f'\n+ {base.name}')
children = list(self._get_child_contracts(base))
if children:
info += ' -> ' + blue(", ".join(map(str, children)))
immediate = [child for child in children if base in child.immediate_inheritance]
not_immediate = [child for child in children if not child in immediate]
info += ' -> ' + blue(", ".join(map(str, immediate)))
if not_immediate:
info += ', [' + blue(", ".join(map(str, not_immediate))) + ']'
self.info(info)
2 changes: 1 addition & 1 deletion slither/printers/inheritance/inheritance_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _summary(self, contract):
"""
ret = ''
# Add arrows
for i in contract.inheritance:
for i in contract.immediate_inheritance:
ret += '%s -> %s;\n' % (contract.name, i)

# Functions
Expand Down