-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LS: Add completions of struct members
commit-id:9fb1df2c
- Loading branch information
1 parent
e8f66e9
commit ef74001
Showing
4 changed files
with
275 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
crates/cairo-lang-language-server/tests/test_data/completions/structs.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
//! > Test completing struct members upon construction. | ||
|
||
//! > test_runner_name | ||
test_completions_text_edits(detail: true) | ||
|
||
//! > cairo_project.toml | ||
[crate_roots] | ||
hello = "src" | ||
|
||
[config.global] | ||
edition = "2024_07" | ||
|
||
//! > cairo_code | ||
mod some_module { | ||
pub struct Struct { | ||
x: u32, | ||
pub y: felt252, | ||
pub z: i16 | ||
} | ||
|
||
fn build_struct() { | ||
let s = Struct { | ||
x: 0x0, | ||
y: 0x0, | ||
z: 0x0 | ||
}; | ||
|
||
let a = Struct { <caret> }; | ||
|
||
let b = Struct { x: 0x0, <caret> }; | ||
|
||
let c = Struct { | ||
x: 0x0, | ||
<caret> | ||
..s | ||
}; | ||
|
||
let d = Struct { | ||
x: 0x0, | ||
<caret>..s | ||
}; | ||
|
||
let e = Struct { <caret>..s }; | ||
} | ||
} | ||
|
||
mod happy_cases { | ||
use super::some_module::Struct; | ||
|
||
fn foo() { | ||
let a = Struct { <caret> }; | ||
let b = Struct { y: 0x0, <caret> }; | ||
let c = Struct { y: 0x0, x: 0x0, <caret> } | ||
} | ||
} | ||
|
||
mod unhappy_cases { | ||
fn foo() { | ||
let a = NonexsitentStruct { <caret> }; | ||
} | ||
} | ||
|
||
//! > Completions #0 | ||
let a = Struct { <caret> }; | ||
-------------------------- | ||
Completion: x | ||
Detail: core::integer::u32 | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #1 | ||
let b = Struct { x: 0x0, <caret> }; | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #2 | ||
<caret> | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #3 | ||
<caret>..s | ||
-------------------------- | ||
Completion: core | ||
-------------------------- | ||
Completion: hello | ||
-------------------------- | ||
Completion: Struct | ||
-------------------------- | ||
Completion: build_struct | ||
-------------------------- | ||
Completion: s | ||
-------------------------- | ||
Completion: a | ||
-------------------------- | ||
Completion: b | ||
-------------------------- | ||
Completion: c | ||
-------------------------- | ||
Completion: d | ||
-------------------------- | ||
Completion: e | ||
|
||
//! > Completions #4 | ||
let e = Struct { <caret>..s }; | ||
-------------------------- | ||
Completion: x | ||
Detail: core::integer::u32 | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #5 | ||
let a = Struct { <caret> }; | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #6 | ||
let b = Struct { y: 0x0, <caret> }; | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #7 | ||
let c = Struct { y: 0x0, x: 0x0, <caret> } | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #8 | ||
let a = NonexsitentStruct { <caret> }; |