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

Function get_call_from_func_element

code2flow/javascript.py:77–94  ·  view source on GitHub ↗

Given a javascript ast that represents a function call, clear and create our generic Call object. Some calls have no chance at resolution (e.g. array[2](param)) so we return nothing instead. :param func dict: :rtype: Call|None

(func)

Source from the content-addressed store, hash-verified

75
76
77def get_call_from_func_element(func):
78 """
79 Given a javascript ast that represents a function call, clear and create our
80 generic Call object. Some calls have no chance at resolution (e.g. array[2](param))
81 so we return nothing instead.
82
83 :param func dict:
84 :rtype: Call|None
85 """
86 callee = func['callee']
87 if callee['type'] == 'MemberExpression' and 'name' in callee['property']:
88 owner_token = resolve_owner(callee)
89 return Call(token=callee['property']['name'],
90 line_number=lineno(callee),
91 owner_token=owner_token)
92 if callee['type'] == 'Identifier':
93 return Call(token=callee['name'], line_number=lineno(callee))
94 return None
95
96
97def make_calls(body):

Callers 2

make_callsFunction · 0.70
process_assignFunction · 0.70

Calls 3

CallClass · 0.85
resolve_ownerFunction · 0.70
linenoFunction · 0.70

Tested by

no test coverage detected