Extract the function/method name being called.
(self, node, language: str, source: bytes)
| 6416 | return imports |
| 6417 | |
| 6418 | def _get_call_name(self, node, language: str, source: bytes) -> Optional[str]: |
| 6419 | """Extract the function/method name being called.""" |
| 6420 | if not node.children: |
| 6421 | return None |
| 6422 | |
| 6423 | first = node.children[0] |
| 6424 | |
| 6425 | # Julia macrocall: ``@test expr`` — name is inside |
| 6426 | # ``macro_identifier > identifier``. Prefix with ``@`` to distinguish |
| 6427 | # from ordinary calls. |
| 6428 | if language == "julia" and node.type == "macrocall_expression": |
| 6429 | for child in node.children: |
| 6430 | if child.type == "macro_identifier": |
| 6431 | for sub in child.children: |
| 6432 | if sub.type == "identifier": |
| 6433 | raw = sub.text.decode("utf-8", errors="replace") |
| 6434 | return f"@{raw}" |
| 6435 | return None |
| 6436 | return None |
| 6437 | |
| 6438 | # Julia broadcast call: ``sin.(x)`` — same structure as |
| 6439 | # call_expression (first child is identifier or field_expression) |
| 6440 | # so the generic paths below handle it. |
| 6441 | if language == "php": |
| 6442 | def _normalize_php_name(text: str) -> str: |
| 6443 | # PHP global/function names can be prefixed with '\\'. |
| 6444 | return text.lstrip("\\") |
| 6445 | |
| 6446 | if node.type == "function_call_expression": |
| 6447 | for child in node.children: |
| 6448 | if child.type in ("name", "qualified_name"): |
| 6449 | raw = child.text.decode("utf-8", errors="replace") |
| 6450 | return _normalize_php_name(raw) |
| 6451 | return None |
| 6452 | |
| 6453 | if node.type in ( |
| 6454 | "member_call_expression", |
| 6455 | "nullsafe_member_call_expression", |
| 6456 | ): |
| 6457 | for child in reversed(node.children): |
| 6458 | if child.type == "name": |
| 6459 | return child.text.decode("utf-8", errors="replace") |
| 6460 | return None |
| 6461 | |
| 6462 | if node.type == "scoped_call_expression": |
| 6463 | parts = [] |
| 6464 | for child in node.children: |
| 6465 | if child.type in ("name", "qualified_name"): |
| 6466 | raw = child.text.decode("utf-8", errors="replace") |
| 6467 | parts.append(_normalize_php_name(raw)) |
| 6468 | if len(parts) >= 2: |
| 6469 | return f"{parts[0]}::{parts[-1]}" |
| 6470 | if parts: |
| 6471 | return parts[0] |
| 6472 | return None |
| 6473 | |
| 6474 | # Scala: instance_expression (new Foo(...)) – extract the type name |
| 6475 | if node.type == "instance_expression": |
no test coverage detected