Given an ast that represents a send 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_expr ast: :rtype: Call|None
(func_expr)
| 35 | |
| 36 | |
| 37 | def get_call_from_expr(func_expr): |
| 38 | """ |
| 39 | Given an ast that represents a send call, clear and create our |
| 40 | generic Call object. Some calls have no chance at resolution (e.g. array[2](param)) |
| 41 | so we return nothing instead. |
| 42 | |
| 43 | :param func_expr ast: |
| 44 | :rtype: Call|None |
| 45 | """ |
| 46 | if func_expr['nodeType'] == 'Expr_FuncCall': |
| 47 | token = get_name(func_expr) |
| 48 | owner_token = None |
| 49 | elif func_expr['nodeType'] == 'Expr_New' and func_expr['class'].get('parts'): |
| 50 | token = '__construct' |
| 51 | owner_token = get_name(func_expr['class']) |
| 52 | elif func_expr['nodeType'] == 'Expr_MethodCall': |
| 53 | # token = func_expr['name']['name'] |
| 54 | token = get_name(func_expr) |
| 55 | if 'var' in func_expr['var']: |
| 56 | owner_token = OWNER_CONST.UNKNOWN_VAR |
| 57 | else: |
| 58 | owner_token = get_name(func_expr['var']) |
| 59 | elif func_expr['nodeType'] == 'Expr_BinaryOp_Concat' and func_expr['right']['nodeType'] == 'Expr_FuncCall': |
| 60 | token = get_name(func_expr['right']) |
| 61 | if 'class' in func_expr['left']: |
| 62 | owner_token = get_name(func_expr['left']['class']) |
| 63 | else: |
| 64 | owner_token = get_name(func_expr['left']) |
| 65 | elif func_expr['nodeType'] == 'Expr_StaticCall': |
| 66 | token = get_name(func_expr) |
| 67 | owner_token = get_name(func_expr['class']) |
| 68 | else: |
| 69 | return None |
| 70 | |
| 71 | if owner_token and token == '__construct': |
| 72 | # Taking out owner_token for constructors as a little hack to make it work |
| 73 | return Call(token=owner_token, |
| 74 | line_number=lineno(func_expr)) |
| 75 | ret = Call(token=token, |
| 76 | owner_token=owner_token, |
| 77 | line_number=lineno(func_expr)) |
| 78 | return ret |
| 79 | |
| 80 | |
| 81 | def walk(tree): |
no test coverage detected