-
Notifications
You must be signed in to change notification settings - Fork 581
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
4e09b88
commit dd6a947
Showing
4 changed files
with
253 additions
and
5 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
126 changes: 126 additions & 0 deletions
126
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,126 @@ | ||
//! > 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 | ||
}; | ||
} | ||
} | ||
|
||
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 | ||
<caret> | ||
-------------------------- | ||
Completion: x | ||
Detail: core::integer::u32 | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #1 | ||
<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> | ||
-------------------------- | ||
Completion: y | ||
Detail: core::felt252 | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #4 | ||
<caret> | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #5 | ||
<caret> | ||
-------------------------- | ||
Completion: z | ||
Detail: core::integer::i16 | ||
|
||
//! > Completions #6 | ||
<caret> |