MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / separate_namespaces

Method separate_namespaces

code2flow/ruby.py:230–251  ·  view source on GitHub ↗

Given a tree element, recursively separate that AST into lists of ASTs for the subgroups, nodes, and body. This is an intermediate step to allow for cleaner processing downstream :param tree ast: :returns: tuple of group, node, and body trees. These are proc

(tree)

Source from the content-addressed store, hash-verified

228
229 @staticmethod
230 def separate_namespaces(tree):
231 """
232 Given a tree element, recursively separate that AST into lists of ASTs for the
233 subgroups, nodes, and body. This is an intermediate step to allow for
234 cleaner processing downstream
235
236 :param tree ast:
237 :returns: tuple of group, node, and body trees. These are processed
238 downstream into real Groups and Nodes.
239 :rtype: (list[ast], list[ast], list[ast])
240 """
241 groups = []
242 nodes = []
243 body = []
244 for el in as_lines(tree):
245 if el[0] in ('def', 'defs'):
246 nodes.append(el)
247 elif el[0] in ('class', 'module'):
248 groups.append(el)
249 else:
250 body.append(el)
251 return groups, nodes, body
252
253 @staticmethod
254 def make_nodes(tree, parent):

Callers 2

make_nodesMethod · 0.45
make_class_groupMethod · 0.45

Calls 1

as_linesFunction · 0.85

Tested by

no test coverage detected