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: Fix hover on definition #6255

Merged
merged 1 commit into from
Aug 27, 2024
Merged

LS: Fix hover on definition #6255

merged 1 commit into from
Aug 27, 2024

Conversation

Draggu
Copy link
Collaborator

@Draggu Draggu commented Aug 21, 2024

fix #5826


This change is Reviewable

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.

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


crates/cairo-lang-language-server/tests/test_data/hover/basic.txt line 216 at r1 (raw file):

fn main()

Well xD Seems like it doesn't work :c

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 4 of 4 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Arcticae, @Draggu, and @mkaput)

Copy link
Collaborator Author

@Draggu Draggu 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: 1 of 4 files reviewed, 1 unresolved discussion (waiting on @Arcticae, @mkaput, @orizi, and @piotmag769)


crates/cairo-lang-language-server/tests/test_data/hover/basic.txt line 216 at r1 (raw file):

Previously, piotmag769 (Piotr Magiera) wrote…

Well xD Seems like it doesn't work :c

Done.

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.

Reviewable status: 1 of 4 files reviewed, 2 unresolved discussions (waiting on @Arcticae, @Draggu, @mkaput, and @orizi)


crates/cairo-lang-language-server/tests/test_data/hover/basic.txt line 323 at r2 (raw file):

impl RectangleImpl of RectangleTrait

This one seems wrong

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.

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

@Draggu Draggu linked an issue Aug 26, 2024 that may be closed by this pull request
Copy link
Member

@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 1 of 4 files at r1, 3 of 3 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Arcticae, @Draggu, and @piotmag769)


-- commits line 4 at r2:

Suggestion:

- 590e171: LS: Fix hover on definition

  fix #5826

  commit-id:7654b189

crates/cairo-lang-language-server/src/lib.rs line 999 at r2 (raw file):

    }

    for lookup_item_id in lookup_items.iter().rev().copied() {

please add a comment stating that you're looking for variable definitions here


crates/cairo-lang-language-server/tests/test_data/hover/basic.txt line 323 at r2 (raw file):

Previously, piotmag769 (Piotr Magiera) wrote…

This one seems wrong

I'm not sure. Technically, it is because we're inside an impl so we are in a concrete context. But UX-wise, it would also be nice to get trait info alongside. Topic for a separate issue nonetheless.

Copy link
Member

@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 1 of 2 files at r3, all commit messages.
Reviewable status: 3 of 4 files reviewed, 3 unresolved discussions (waiting on @Arcticae, @Draggu, @orizi, and @piotmag769)


crates/cairo-lang-language-server/src/lib.rs line 1000 at r3 (raw file):

    }

    // Skip variable definition.

skip?


crates/cairo-lang-language-server/src/lib.rs line 1021 at r3 (raw file):

    } else {
        None
    }

let's stick with single style of returning

Suggestion:

    // Skip variable definition.
    if db.first_ancestor_of_kind(identifier.as_syntax_node(), SyntaxKind::StatementLet).is_none() {
        let item = match lookup_items.first().copied()? {
            LookupItemId::ModuleItem(item) => {
                ResolvedGenericItem::from_module_item(db, item).to_option()?
            }
            LookupItemId::TraitItem(trait_item) => {
                if let TraitItemId::Function(trait_fn) = trait_item {
                    ResolvedGenericItem::TraitFunction(trait_fn)
                } else {
                    ResolvedGenericItem::Trait(trait_item.trait_id(db))
                }
            }
            LookupItemId::ImplItem(impl_item) => {
                ResolvedGenericItem::Impl(impl_item.impl_def_id(db))
            }
        };

        return Some((ResolvedItem::Generic(item.clone()), resolved_generic_item_def(db, item)?));
    }
    
    None

Copy link
Collaborator Author

@Draggu Draggu 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: 2 of 4 files reviewed, 3 unresolved discussions (waiting on @Arcticae, @mkaput, @orizi, and @piotmag769)


-- commits line 4 at r2:
Done.


crates/cairo-lang-language-server/src/lib.rs line 999 at r2 (raw file):

Previously, mkaput (Marek Kaput) wrote…

please add a comment stating that you're looking for variable definitions here

Done.


crates/cairo-lang-language-server/tests/test_data/hover/basic.txt line 323 at r2 (raw file):

Previously, mkaput (Marek Kaput) wrote…

I'm not sure. Technically, it is because we're inside an impl so we are in a concrete context. But UX-wise, it would also be nice to get trait info alongside. Topic for a separate issue nonetheless.

Not a simple fix. Track it here #6287

Copy link
Member

@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 1 of 2 files at r3.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Arcticae 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.

:lgtm:

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


crates/cairo-lang-language-server/src/lib.rs line 1007 at r3 (raw file):

            }
            LookupItemId::TraitItem(trait_item) => {
                if let TraitItemId::Function(trait_fn) = trait_item {

Why is it here, but in the impl we don't do it?


crates/cairo-lang-language-server/src/lib.rs line 1021 at r3 (raw file):

Previously, mkaput (Marek Kaput) wrote…

let's stick with single style of returning

Imo the one you proposed is worse

Copy link
Member

@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:

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Arcticae and @Draggu)

Copy link
Collaborator

@Arcticae Arcticae left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Draggu)

Copy link
Collaborator Author

@Draggu Draggu 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: all files reviewed, 2 unresolved discussions (waiting on @mkaput and @piotmag769)


crates/cairo-lang-language-server/src/lib.rs line 1000 at r3 (raw file):

Previously, mkaput (Marek Kaput) wrote…

skip?

If this check is missing we would get parent ModuleItem for variable.


crates/cairo-lang-language-server/src/lib.rs line 1007 at r3 (raw file):

Previously, piotmag769 (Piotr Magiera) wrote…

Why is it here, but in the impl we don't do it?

Because ResolvedGenericItem has only 1 variant for Impl and 2 for Trait.

Copy link
Member

@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.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Draggu and @piotmag769)


crates/cairo-lang-language-server/src/lib.rs line 1000 at r3 (raw file):

Previously, Draggu (Piotr Figiela) wrote…

If this check is missing we would get parent ModuleItem for variable.

please leave this information in code as a comment

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.

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Draggu)

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 1 of 2 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Draggu)

fix #5826

commit-id:7654b189
Copy link
Collaborator Author

@Draggu Draggu 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 @mkaput and @piotmag769)


crates/cairo-lang-language-server/src/lib.rs line 1000 at r3 (raw file):

Previously, mkaput (Marek Kaput) wrote…

please leave this information in code as a comment

Done.

Copy link
Member

@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 1 of 1 files at r4, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @Draggu)

@Draggu Draggu enabled auto-merge August 27, 2024 10:50
@Draggu Draggu added this pull request to the merge queue Aug 27, 2024
Merged via the queue into main with commit 9322175 Aug 27, 2024
87 checks passed
@orizi orizi deleted the spr/main/7654b189 branch August 28, 2024 05:57
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.

Hovers on identifiers *defining* the item/variable are not working
5 participants