-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LS: Add "fill struct fields" code action #6565
Conversation
65713e2
to
a50dd82
Compare
a50dd82
to
43f9b00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @mkaput, @orizi, and @piotmag769)
a discussion (no related file):
I'm still working on this feature and e2e tests for it.
aa6b402
to
eef5d39
Compare
43f9b00
to
b3c30f2
Compare
b3c30f2
to
c812043
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @Arcticae, @Draggu, @integraledelebesgue, @mkaput, and @orizi)
crates/cairo-lang-language-server/src/ide/code_actions/mod.rs
line 34 at r2 (raw file):
); actions.extend( fill_struct_members::fill_struct_members(db, node.clone(), ¶ms)
Shouldn't it be based on a diagnostic like in the loop above? This way you don't have to redetermine if it's needed.
Will require assigning error code to SemanticDiagnosticKind::MissingMember
in SemanticDiagnosticKind::error_code
c812043
to
d43926e
Compare
2af0faf
to
477291d
Compare
d43926e
to
33b35fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r1, all commit messages.
Reviewable status: 1 of 2 files reviewed, 2 unresolved discussions (waiting on @Arcticae, @Draggu, @integraledelebesgue, and @orizi)
477291d
to
3bfc1c2
Compare
33b35fb
to
70595cd
Compare
030cc39
to
ef74001
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r9, 1 of 1 files at r10, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Arcticae, @Draggu, and @piotmag769)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r9, 1 of 1 files at r10, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Arcticae, @Draggu, and @integraledelebesgue)
crates/cairo-lang-language-server/src/ide/code_actions/fill_struct_fields.rs
line 34 at r10 (raw file):
let constructor_expr_id = db.lookup_expr_by_ptr(function_id, constructor_expr.stable_ptr().into()).ok()?; let constructor_semantic = match db.expr_semantic(function_id, constructor_expr_id) {
This is used much later, move it close to the usage pls
crates/cairo-lang-language-server/src/ide/code_actions/fill_struct_fields.rs
line 36 at r10 (raw file):
let constructor_semantic = match db.expr_semantic(function_id, constructor_expr_id) { Expr::StructCtor(semantic) => semantic, _ => return None,
Prob worth logging an error here, it should never happen
crates/cairo-lang-language-server/src/ide/code_actions/fill_struct_fields.rs
line 91 at r10 (raw file):
.collect::<Vec<_>>(); let prefix = String::from(if !has_trailing_comma && last_important_element.is_some() {
Why don't declare it after the for loop with has_trailing_comma
and last_important_element
? This way you don't have to track where these vars are actually used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r9.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @Arcticae, @Draggu, and @integraledelebesgue)
crates/cairo-lang-language-server/src/ide/code_actions/fill_struct_fields.rs
line 75 at r10 (raw file):
let struct_parent_module_id = concrete_struct_id.struct_id(db).parent_module(db); let arguments_to_complete = concrete_struct_members(db, concrete_struct_id)
This is a query, use it as one
Suggestion:
db.concrete_struct_members(concrete_struct_id)
efe63a2
to
3f917bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r11, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Arcticae, @Draggu, and @integraledelebesgue)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Arcticae, @Draggu, and @piotmag769)
crates/cairo-lang-language-server/src/ide/code_actions/fill_struct_fields.rs
line 36 at r10 (raw file):
Previously, piotmag769 (Piotr Magiera) wrote…
Prob worth logging an error here, it should never happen
Done.
crates/cairo-lang-language-server/src/ide/code_actions/fill_struct_fields.rs
line 75 at r10 (raw file):
Previously, piotmag769 (Piotr Magiera) wrote…
This is a query, use it as one
Done.
920e8b0
to
f43dca8
Compare
3f917bb
to
aa88ba2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Arcticae and @Draggu)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r11, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Arcticae and @Draggu)
aa88ba2
to
edb8bac
Compare
f43dca8
to
7a13d8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r12, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @Arcticae and @Draggu)
07f5d86
to
79a7fea
Compare
7a13d8e
to
e0584da
Compare
8638f37
to
322fb00
Compare
commit-id:0051578a
322fb00
to
5964758
Compare
Stack: