Skip to content

Commit 2771ad2

Browse files
committed
fix for python
1 parent 783ccb1 commit 2771ad2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

api/analyzers/python/analyzer.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,7 @@ def get_entity_docstring(self, node: Node) -> Optional[str]:
3333
docstring_node = body.children[0].child(0)
3434
return docstring_node.text.decode('utf-8')
3535
return None
36-
raise ValueError(f"Unknown entity type: {node.type}")
37-
38-
def find_calls(self, method: Entity):
39-
query = self.language.query("(call) @reference.call")
40-
captures = query.captures(method.node)
41-
if 'reference.call' in captures:
42-
for caller in captures['reference.call']:
43-
method.add_symbol("call", caller)
36+
raise ValueError(f"Unknown entity type: {node.type}")
4437

4538
def get_entity_types(self) -> list[str]:
4639
return ['class_definition', 'function_definition']
@@ -55,7 +48,19 @@ def add_symbols(self, entity: Entity) -> None:
5548
for base_class in base_classes_captures['base_class']:
5649
entity.add_symbol("base_class", base_class)
5750
elif entity.node.type == 'function_definition':
58-
self.find_calls(entity)
51+
query = self.language.query("(call) @reference.call")
52+
captures = query.captures(entity.node)
53+
if 'reference.call' in captures:
54+
for caller in captures['reference.call']:
55+
entity.add_symbol("call", caller)
56+
query = self.language.query("(typed_parameter type: (_) @parameter)")
57+
captures = query.captures(entity.node)
58+
if 'parameter' in captures:
59+
for parameter in captures['parameter']:
60+
entity.add_symbol("parameters", parameter)
61+
return_type = entity.node.child_by_field_name('return_type')
62+
if return_type:
63+
entity.add_symbol("return_type", return_type)
5964

6065
def resolve_type(self, files: dict[Path, File], lsp: SyncLanguageServer, path: Path, node: Node) -> list[Entity]:
6166
res = []

0 commit comments

Comments
 (0)