Skip to content

Commit db257d2

Browse files
committed
Add test with argument enabled
1 parent 12443ed commit db257d2

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
---
2+
source: crates/ark/src/lsp/symbols.rs
3+
expression: symbols
4+
---
5+
[
6+
DocumentSymbol {
7+
name: "inner1",
8+
detail: None,
9+
kind: Variable,
10+
tags: None,
11+
deprecated: None,
12+
range: Range {
13+
start: Position {
14+
line: 2,
15+
character: 2,
16+
},
17+
end: Position {
18+
line: 2,
19+
character: 8,
20+
},
21+
},
22+
selection_range: Range {
23+
start: Position {
24+
line: 2,
25+
character: 2,
26+
},
27+
end: Position {
28+
line: 2,
29+
character: 8,
30+
},
31+
},
32+
children: Some(
33+
[],
34+
),
35+
},
36+
DocumentSymbol {
37+
name: "a",
38+
detail: Some(
39+
"function()",
40+
),
41+
kind: Function,
42+
tags: None,
43+
deprecated: None,
44+
range: Range {
45+
start: Position {
46+
line: 4,
47+
character: 0,
48+
},
49+
end: Position {
50+
line: 7,
51+
character: 1,
52+
},
53+
},
54+
selection_range: Range {
55+
start: Position {
56+
line: 4,
57+
character: 0,
58+
},
59+
end: Position {
60+
line: 7,
61+
character: 1,
62+
},
63+
},
64+
children: Some(
65+
[
66+
DocumentSymbol {
67+
name: "inner2",
68+
detail: None,
69+
kind: Variable,
70+
tags: None,
71+
deprecated: None,
72+
range: Range {
73+
start: Position {
74+
line: 5,
75+
character: 2,
76+
},
77+
end: Position {
78+
line: 5,
79+
character: 8,
80+
},
81+
},
82+
selection_range: Range {
83+
start: Position {
84+
line: 5,
85+
character: 2,
86+
},
87+
end: Position {
88+
line: 5,
89+
character: 8,
90+
},
91+
},
92+
children: Some(
93+
[],
94+
),
95+
},
96+
DocumentSymbol {
97+
name: "inner3",
98+
detail: Some(
99+
"function()",
100+
),
101+
kind: Function,
102+
tags: None,
103+
deprecated: None,
104+
range: Range {
105+
start: Position {
106+
line: 6,
107+
character: 2,
108+
},
109+
end: Position {
110+
line: 6,
111+
character: 24,
112+
},
113+
},
114+
selection_range: Range {
115+
start: Position {
116+
line: 6,
117+
character: 2,
118+
},
119+
end: Position {
120+
line: 6,
121+
character: 24,
122+
},
123+
},
124+
children: Some(
125+
[],
126+
),
127+
},
128+
],
129+
),
130+
},
131+
]

crates/ark/src/lsp/symbols.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,4 +849,29 @@ a <- function() {
849849
));
850850
assert_eq!(test_symbol("{ foo <- 1 }"), vec![]);
851851
}
852+
853+
#[test]
854+
fn test_symbol_nested_assignments_enabled() {
855+
let doc = Document::new(
856+
"
857+
local({
858+
inner1 <- 1
859+
})
860+
a <- function() {
861+
inner2 <- 2
862+
inner3 <- function() 3
863+
}
864+
",
865+
None,
866+
);
867+
let node = doc.ast.root_node();
868+
869+
let ctx = &mut CollectContext::new();
870+
ctx.include_assignments_in_blocks = true;
871+
872+
let mut symbols = Vec::new();
873+
collect_symbols(ctx, &node, &doc.contents, 0, &mut symbols).unwrap();
874+
875+
insta::assert_debug_snapshot!(symbols);
876+
}
852877
}

0 commit comments

Comments
 (0)