Skip to content
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: Discover struct members in constructor #6632

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

integraledelebesgue
Copy link
Collaborator

Closes #6537

Changes

  • Struct members in constructors are properly recognized and generate hovers identical as members in any other context (e.g. struct_var.member)
  • New test fixture - structs.txt - covers all struct member hovers scenarios

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Contributor

@mkaput mkaput left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, @orizi, and @piotmag769)

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, and @piotmag769)

Copy link
Contributor

@mkaput mkaput left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Arcticae, @Draggu, and @piotmag769)

Copy link
Collaborator

@piotmag769 piotmag769 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r1, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, and @integraledelebesgue)


crates/cairo-lang-language-server/src/lang/inspect/defs.rs line 383 at r3 (raw file):

    let struct_member = ast::StructArgSingle::from_syntax_node(db, struct_member);

    let ast::OptionStructArgExpr::StructArgExpr(struct_member_expr) = struct_member.arg_expr(db)

OptionStructArgExpr::Empty is also a valid path here, it mean that the expression looks like this:

let my_field = 5;

MyStruct {
   my_field,
}

I think we want to handle it as well

Copy link
Collaborator Author

@integraledelebesgue integraledelebesgue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 4 files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, @mkaput, and @piotmag769)


crates/cairo-lang-language-server/src/lang/inspect/defs.rs line 383 at r3 (raw file):

Previously, piotmag769 (Piotr Magiera) wrote…

OptionStructArgExpr::Empty is also a valid path here, it mean that the expression looks like this:

let my_field = 5;

MyStruct {
   my_field,
}

I think we want to handle it as well

I changed the implementation to handle this case. However, OptionStructArgExpr::Empty doesn't have any useful functions to retrieve ExprIds etc. thus I had to change the whole implementation to match members by names. Please have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LS: Incorrect hover when used on member of struct llteral
5 participants