Extract call expressions, including test runner special cases. Returns True if the child was fully handled (test runner call that should skip default recursion). Returns False if the caller should continue to Solidity handling and default recursion.
(
self,
child,
source: bytes,
language: str,
file_path: str,
nodes: list[NodeInfo],
edges: list[EdgeInfo],
enclosing_class: Optional[str],
enclosing_func: Optional[str],
import_map: Optional[dict[str, str]],
defined_names: Optional[set[str]],
_depth: int,
)
| 4575 | )) |
| 4576 | |
| 4577 | def _extract_calls( |
| 4578 | self, |
| 4579 | child, |
| 4580 | source: bytes, |
| 4581 | language: str, |
| 4582 | file_path: str, |
| 4583 | nodes: list[NodeInfo], |
| 4584 | edges: list[EdgeInfo], |
| 4585 | enclosing_class: Optional[str], |
| 4586 | enclosing_func: Optional[str], |
| 4587 | import_map: Optional[dict[str, str]], |
| 4588 | defined_names: Optional[set[str]], |
| 4589 | _depth: int, |
| 4590 | ) -> bool: |
| 4591 | """Extract call expressions, including test runner special cases. |
| 4592 | |
| 4593 | Returns True if the child was fully handled (test runner call that |
| 4594 | should skip default recursion). Returns False if the caller should |
| 4595 | continue to Solidity handling and default recursion. |
| 4596 | """ |
| 4597 | call_name = self._get_call_name(child, language, source) |
| 4598 | |
| 4599 | # For member expressions like describe.only / it.skip / test.each, |
| 4600 | # resolve the base call name so those are treated as test runner |
| 4601 | # calls. |
| 4602 | effective_call_name = call_name |
| 4603 | if ( |
| 4604 | call_name |
| 4605 | and language in ("javascript", "typescript", "tsx") |
| 4606 | and _is_test_file(file_path) |
| 4607 | and call_name not in _TEST_RUNNER_NAMES |
| 4608 | ): |
| 4609 | effective_call_name = ( |
| 4610 | self._get_base_call_name(child, source) or call_name |
| 4611 | ) |
| 4612 | |
| 4613 | # Special handling: test runner calls in test files -> Test nodes |
| 4614 | if ( |
| 4615 | effective_call_name |
| 4616 | and language in ("javascript", "typescript", "tsx") |
| 4617 | and _is_test_file(file_path) |
| 4618 | and effective_call_name in _TEST_RUNNER_NAMES |
| 4619 | ): |
| 4620 | test_desc = self._get_test_description(child, source) |
| 4621 | line_no = child.start_point[0] + 1 |
| 4622 | synthetic_base = ( |
| 4623 | f"{effective_call_name}:{test_desc}" |
| 4624 | if test_desc else effective_call_name |
| 4625 | ) |
| 4626 | synthetic_name = f"{synthetic_base}@L{line_no}" |
| 4627 | qualified = self._qualify( |
| 4628 | synthetic_name, file_path, enclosing_class, |
| 4629 | ) |
| 4630 | |
| 4631 | nodes.append(NodeInfo( |
| 4632 | kind="Test", |
| 4633 | name=synthetic_name, |
| 4634 | file_path=file_path, |
no test coverage detected