//! > Test filling missing members in struct constructor.
//! > test_runner_name
test_quick_fix
//! > 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 { <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> };
}
}
//! > Code action #0
let _a = Struct { <caret> };
Title: Fill struct fields
Add new text: " x: (), y: (), z: ()"
At: Range { start: Position { line: 14, character: 25 }, end: Position { line: 14, character: 25 } }
//! > Code action #1
let _b = Struct { x: 0x0, <caret> };
Title: Fill struct fields
Add new text: " y: (), z: ()"
At: Range { start: Position { line: 16, character: 33 }, end: Position { line: 16, character: 33 } }
//! > Code action #2
let _c = Struct { <caret>..s };
No code actions.
//! > Code action #3
let _a = Struct { <caret> };
Title: Fill struct fields
Add new text: " y: (), z: ()"
At: Range { start: Position { line: 26, character: 25 }, end: Position { line: 26, character: 25 } }
//! > Code action #4
let _b = Struct { y: 0x0, <caret> };
Title: Fill struct fields
Add new text: " z: ()"
At: Range { start: Position { line: 27, character: 33 }, end: Position { line: 27, character: 33 } }
//! > Code action #5
let _c = Struct { y: 0x0, x: 0x0, <caret> }
Title: Fill struct fields
Add new text: " z: ()"
At: Range { start: Position { line: 28, character: 41 }, end: Position { line: 28, character: 41 } }
//! > Code action #6
let _a = NonexsitentStruct { <caret> };
No code actions.