Skip to content

Commit 0a10517

Browse files
committed
add goto tests for path segments and where clauses
Added goto_path_segments.fe to verify all intermediate path segments are resolvable for goto-definition (e.g. clicking on 'stuff' in 'stuff::calculations::ambiguous' resolves correctly). Added goto_where_clause.fe to verify trait bounds in where clauses are resolvable (e.g. clicking on 'MyTrait' in 'where T: MyTrait' resolves to the trait definition). Both tests cover inline module resolution. Cross-ingot resolution is blocked pending PR argotorg#1146 which adds ingot initialization when opening .fe files.
1 parent c3133ad commit 0a10517

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
mod things { pub struct Why {} }
2+
mod stuff {
3+
pub mod calculations {
4+
pub fn ambiguous() {}
5+
pub mod ambiguous {}
6+
}
7+
}
8+
9+
fn f() {
10+
let _u: things::Why
11+
let _a: stuff::calculations::ambiguous
12+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
source: crates/language-server/src/functionality/goto.rs
3+
expression: snapshot
4+
input_file: test_files/goto_path_segments.fe
5+
---
6+
0: mod things { pub struct Why {} }
7+
1: mod stuff {
8+
2: pub mod calculations {
9+
3: pub fn ambiguous() {}
10+
4: pub mod ambiguous {}
11+
5: }
12+
6: }
13+
7:
14+
8: fn f() {
15+
9: let _u: things::Why
16+
10: let _a: stuff::calculations::ambiguous
17+
11: }
18+
---
19+
cursor position (9, 10), path: goto_path_segments::things
20+
cursor position (9, 18), path: goto_path_segments::things::Why
21+
cursor position (10, 10), path: goto_path_segments::stuff
22+
cursor position (10, 17), path: goto_path_segments::stuff::calculations
23+
cursor position (10, 31), path: goto_path_segments::stuff::calculations::ambiguous
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
trait MyTrait {
2+
fn do_something(self)
3+
}
4+
5+
struct Container<T> {
6+
value: T
7+
}
8+
9+
impl<T> Container<T>
10+
where T: MyTrait
11+
{
12+
fn process(self) {
13+
self.value.do_something()
14+
}
15+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
source: crates/language-server/src/functionality/goto.rs
3+
expression: snapshot
4+
input_file: test_files/goto_where_clause.fe
5+
---
6+
0: trait MyTrait {
7+
1: fn do_something(self)
8+
2: }
9+
3:
10+
4: struct Container<T> {
11+
5: value: T
12+
6: }
13+
7:
14+
8: impl<T> Container<T>
15+
9: where T: MyTrait
16+
10: {
17+
11: fn process(self) {
18+
12: self.value.do_something()
19+
13: }
20+
14: }
21+
---
22+
cursor position (1, 20), path: goto_where_clause::MyTrait
23+
cursor position (5, 11), path: goto_where_clause::Container::T
24+
cursor position (8, 8), path: goto_where_clause::Container
25+
cursor position (9, 13), path: goto_where_clause::MyTrait
26+
cursor position (11, 15), path: goto_where_clause::Container

0 commit comments

Comments
 (0)