Find and format definition location for an expression. If it is not a RefExpr, it is effectively skipped by returning an empty result.
(self, expression: Expression)
| 427 | return modules, reload_needed |
| 428 | |
| 429 | def expression_def(self, expression: Expression) -> tuple[str, bool]: |
| 430 | """Find and format definition location for an expression. |
| 431 | |
| 432 | If it is not a RefExpr, it is effectively skipped by returning an |
| 433 | empty result. |
| 434 | """ |
| 435 | if not isinstance(expression, RefExpr): |
| 436 | # If there are no suitable matches at all, we return error later. |
| 437 | return "", True |
| 438 | |
| 439 | nodes = self.collect_nodes(expression) |
| 440 | |
| 441 | if not nodes: |
| 442 | return self.missing_node(expression), False |
| 443 | |
| 444 | modules, reload_needed = self.modules_for_nodes(nodes, expression) |
| 445 | if reload_needed: |
| 446 | # TODO: line/column are not stored in cache for vast majority of symbol nodes. |
| 447 | # Adding them will make thing faster, but will have visible memory impact. |
| 448 | nodes = self.collect_nodes(expression) |
| 449 | modules, reload_needed = self.modules_for_nodes(nodes, expression) |
| 450 | assert not reload_needed |
| 451 | |
| 452 | result = [] |
| 453 | for node in modules: |
| 454 | result.append(self.format_node(modules[node], node)) |
| 455 | |
| 456 | if not result: |
| 457 | return self.missing_node(expression), False |
| 458 | |
| 459 | return self.add_prefixes(", ".join(result), expression), True |
| 460 | |
| 461 | def missing_type(self, expression: Expression) -> str: |
| 462 | alt_suggestion = "" |
nothing calls this directly
no test coverage detected