@@ -38,14 +38,7 @@ def get_entity_docstring(self, node: Node) -> Optional[str]:
3838 if node .prev_sibling .type == "block_comment" :
3939 return node .prev_sibling .text .decode ('utf-8' )
4040 return None
41- raise ValueError (f"Unknown entity type: { node .type } " )
42-
43- def find_calls (self , method : Entity ):
44- query = self .language .query ("(method_invocation) @reference.call" )
45- captures = query .captures (method .node )
46- if 'reference.call' in captures :
47- for caller in captures ['reference.call' ]:
48- method .add_symbol ("call" , caller )
41+ raise ValueError (f"Unknown entity type: { node .type } " )
4942
5043 def get_entity_types (self ) -> list [str ]:
5144 return ['class_declaration' , 'interface_declaration' , 'enum_declaration' , 'method_declaration' , 'constructor_declaration' ]
@@ -69,7 +62,18 @@ def add_symbols(self, entity: Entity) -> None:
6962 for interface in extends_captures ['type' ]:
7063 entity .add_symbol ("extend_interface" , interface )
7164 elif entity .node .type in ['method_declaration' , 'constructor_declaration' ]:
72- self .find_calls (entity )
65+ query = self .language .query ("(method_invocation) @reference.call" )
66+ captures = query .captures (entity .node )
67+ if 'reference.call' in captures :
68+ for caller in captures ['reference.call' ]:
69+ entity .add_symbol ("call" , caller )
70+ if entity .node .type == 'method_declaration' :
71+ query = self .language .query ("(formal_parameters (formal_parameter type: (_) @parameter))" )
72+ captures = query .captures (entity .node )
73+ if 'parameter' in captures :
74+ for parameter in captures ['parameter' ]:
75+ entity .add_symbol ("parameters" , parameter )
76+ entity .add_symbol ("return_type" , entity .node .child_by_field_name ('type' ))
7377
7478 def resolve_type (self , files : dict [Path , File ], lsp : SyncLanguageServer , path : Path , node : Node ) -> list [Entity ]:
7579 res = []
@@ -85,8 +89,8 @@ def resolve_method(self, files: dict[Path, File], lsp: SyncLanguageServer, path:
8589 method_dec = self .find_parent (resolved_node , ['method_declaration' , 'constructor_declaration' , 'class_declaration' , 'interface_declaration' , 'enum_declaration' ])
8690 if method_dec .type in ['class_declaration' , 'interface_declaration' , 'enum_declaration' ]:
8791 continue
88- type_dec = self . find_parent ( method_dec , [ 'class_declaration' , 'interface_declaration' , 'enum_declaration' ])
89- res .append (file .entities [ type_dec ]. children [method_dec ])
92+ if method_dec in file . entities :
93+ res .append (file .entities [method_dec ])
9094 return res
9195
9296 def resolve_symbol (self , files : dict [Path , File ], lsp : SyncLanguageServer , path : Path , key : str , symbol : Node ) -> Entity :
0 commit comments