Get the various types of inheritances this class/module can have :param tree ast: :param body_tree list[ast] :rtype: list[str]
(tree, body_tree)
| 166 | |
| 167 | |
| 168 | def get_inherits(tree, body_tree): |
| 169 | """ |
| 170 | Get the various types of inheritances this class/module can have |
| 171 | |
| 172 | :param tree ast: |
| 173 | :param body_tree list[ast] |
| 174 | :rtype: list[str] |
| 175 | """ |
| 176 | inherits = [] |
| 177 | |
| 178 | # extends |
| 179 | if tree[0] == 'class' and tree[2]: |
| 180 | inherits.append(tree[2][2]) |
| 181 | |
| 182 | # module automatically extends same-named modules |
| 183 | if tree[0] == 'module': |
| 184 | inherits.append(tree[1][2]) |
| 185 | |
| 186 | # mixins |
| 187 | for el in body_tree: |
| 188 | if el[0] == 'send' and el[2] == 'include': |
| 189 | inherits.append(el[3][2]) |
| 190 | |
| 191 | return inherits |
| 192 | |
| 193 | |
| 194 | class Ruby(BaseLanguage): |