Skip to content

Commit

Permalink
fix(Python parser): Use Declare for functions
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Jan 26, 2022
1 parent b5fcfa6 commit 60095f7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
12 changes: 8 additions & 4 deletions rust/parser-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ impl ParserTrait for PyParser {
5 => "Function",
_ => unreachable!(),
};
Some((
relations::assigns(range),
resources::symbol(path, &name, kind),
))

let symbol = resources::symbol(path, &name, kind);
let relation = match pattern {
4 => relations::assigns(range),
5 => relations::declares(range),
_ => unreachable!(),
};
Some((relation, symbol))
}
6 => {
// Uses an identifier assigned elsewhere
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: rust/parser-py/src/lib.rs
assertion_line: 209
assertion_line: 213
expression: resource_info
input_file: fixtures/fragments/py/assigns.py

Expand Down Expand Up @@ -50,7 +50,7 @@ input_file: fixtures/fragments/py/assigns.py
],
[
{
"type": "Assign",
"type": "Declare",
"range": [
3,
4,
Expand Down
4 changes: 2 additions & 2 deletions rust/parser-py/src/snapshots/parse_py_fragments@reads.py.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: rust/parser-py/src/lib.rs
assertion_line: 209
assertion_line: 213
expression: resource_info
input_file: fixtures/fragments/py/reads.py

Expand Down Expand Up @@ -138,7 +138,7 @@ input_file: fixtures/fragments/py/reads.py
],
[
{
"type": "Assign",
"type": "Declare",
"range": [
16,
4,
Expand Down
4 changes: 2 additions & 2 deletions rust/parser-py/src/snapshots/parse_py_fragments@uses.py.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: rust/parser-py/src/lib.rs
assertion_line: 209
assertion_line: 213
expression: resource_info
input_file: fixtures/fragments/py/uses.py

Expand Down Expand Up @@ -373,7 +373,7 @@ input_file: fixtures/fragments/py/uses.py
],
[
{
"type": "Assign",
"type": "Declare",
"range": [
31,
4,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: rust/parser-py/src/lib.rs
assertion_line: 209
assertion_line: 213
expression: resource_info
input_file: fixtures/fragments/py/writes.py

Expand Down Expand Up @@ -127,7 +127,7 @@ input_file: fixtures/fragments/py/writes.py
],
[
{
"type": "Assign",
"type": "Declare",
"range": [
10,
4,
Expand Down

0 comments on commit 60095f7

Please sign in to comment.