Skip to content

Commit c2a8d45

Browse files
committed
Fixed it so both origin and full symbol are represented as usages
1 parent 36e239d commit c2a8d45

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

locust/parse.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,15 @@ def visit_Attribute(self, node: ast.Attribute) -> None:
210210
qualifications = symbols.get(cumulative_component)
211211
if qualifications:
212212
for qualification in qualifications:
213+
origin_definition = RawDefinition(
214+
name=qualification,
215+
change_type=self.context_type.value,
216+
line=node.lineno,
217+
offset=node.col_offset,
218+
end_line=node.end_lineno,
219+
end_offset=node.end_col_offset,
220+
parent=parent,
221+
)
213222
# Replace prefix with qualification in final_component
214223
name = final_component.replace(
215224
cumulative_component, qualification, 1
@@ -223,7 +232,8 @@ def visit_Attribute(self, node: ast.Attribute) -> None:
223232
end_offset=node.end_col_offset,
224233
parent=parent,
225234
)
226-
self.definitions.append(definition)
235+
236+
self.definitions.extend([origin_definition ,definition])
227237

228238
def reset(self):
229239
self.scope = []

tests/fixtures/test_parse.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@
126126
"total_lines": 2,
127127
"parent": {}
128128
},
129+
{
130+
"name": "argparse",
131+
"change_type": "usage",
132+
"filepath": "sample.py",
133+
"revision": "0838585",
134+
"line": 7,
135+
"changed_lines": 1,
136+
"total_lines": 1,
137+
"parent": {}
138+
},
129139
{
130140
"name": "argparse.ArgumentParser",
131141
"change_type": "usage",

tests/fixtures/test_parse_dependencies.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,16 @@
311311
"total_lines": 1,
312312
"parent": {}
313313
},
314+
{
315+
"name": "json",
316+
"change_type": "usage",
317+
"filepath": "mod/submod/print.py",
318+
"revision": "04cec01",
319+
"line": 5,
320+
"changed_lines": 1,
321+
"total_lines": 1,
322+
"parent": {}
323+
},
314324
{
315325
"name": "json.dumps",
316326
"change_type": "usage",

tests/fixtures/test_render.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@
1919
"total_lines": 2,
2020
"children": []
2121
},
22+
{
23+
"name": "argparse",
24+
"type": "usage",
25+
"line": 7,
26+
"changed_lines": 1,
27+
"total_lines": 1,
28+
"children": []
29+
},
2230
{
2331
"name": "argparse.ArgumentParser",
2432
"type": "usage",

0 commit comments

Comments
 (0)