(node: Parser.SyntaxNode)
| 599 | |
| 600 | // Helper function to check if a node is a declaration. |
| 601 | function isDeclarationNode(node: Parser.SyntaxNode) { |
| 602 | const nodeType = node.type; |
| 603 | |
| 604 | // Common declaration patterns. |
| 605 | if (nodeType.endsWith("_declaration")) return true; |
| 606 | if (nodeType.endsWith("_definition")) return true; |
| 607 | if (nodeType.endsWith("_item")) return true; // Rust. |
| 608 | |
| 609 | // Language-specific patterns. |
| 610 | const declarationTypes = [ |
| 611 | // Python. |
| 612 | "function_definition", |
| 613 | "class_definition", |
| 614 | "async_function_definition", |
| 615 | "decorated_definition", |
| 616 | |
| 617 | // Ruby. |
| 618 | "method", |
| 619 | "class", |
| 620 | "module", |
| 621 | "singleton_method", |
| 622 | |
| 623 | // Java. |
| 624 | "variable_declarator", |
| 625 | "local_variable_declaration", |
| 626 | |
| 627 | // Go. |
| 628 | "short_var_declaration", |
| 629 | |
| 630 | // General |
| 631 | "method_definition", |
| 632 | ]; |
| 633 | |
| 634 | return declarationTypes.includes(nodeType); |
| 635 | } |
| 636 | |
| 637 | // // Helper function to find the closest identifier node. |
| 638 | // function findClosestIdentifierNode( |
no outgoing calls
no test coverage detected