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

Method resolve_variables

code2flow/model.py:378–402  ·  view source on GitHub ↗

For all variables, attempt to resolve the Node/Group on points_to. There is a good chance this will be unsuccessful. :param list[Group] file_groups: :rtype: None

(self, file_groups)

Source from the content-addressed store, hash-verified

376 return ret
377
378 def resolve_variables(self, file_groups):
379 """
380 For all variables, attempt to resolve the Node/Group on points_to.
381 There is a good chance this will be unsuccessful.
382
383 :param list[Group] file_groups:
384 :rtype: None
385 """
386 for variable in self.variables:
387 if isinstance(variable.points_to, str):
388 variable.points_to = _resolve_str_variable(variable, file_groups)
389 elif isinstance(variable.points_to, Call):
390 # else, this is a call variable
391 call = variable.points_to
392 # Only process Class(); Not a.Class()
393 if call.is_attr() and not call.definite_constructor:
394 continue
395 # Else, assume the call is a constructor.
396 # iterate through to find the right group
397 for file_group in file_groups:
398 for group in file_group.all_groups():
399 if group.token == call.token:
400 variable.points_to = group
401 else:
402 assert isinstance(variable.points_to, (Node, Group))
403
404 def to_dot(self):
405 """

Callers 1

map_itFunction · 0.80

Calls 3

_resolve_str_variableFunction · 0.85
all_groupsMethod · 0.80
is_attrMethod · 0.45

Tested by

no test coverage detected