starkware-libs / cairo

Cairo is the first Turing-complete language for creating provable programs for general computation.
Apache License 2.0
1.46k stars 446 forks source link

Hovers on identifiers *defining* the item/variable are not working #5826

Open mkaput opened 1 week ago

mkaput commented 1 week ago

Summary

When hovering over identifiers which define items/variables, user expects to get the same hover information as one produced when hovering over identifiers which reference these elements.

See examples:

Expected Actual
Image Image This case shows no hovers at all.
Image Image This is the legacy hover implementation that we aim to remove.

Proposed solution

This logic only looks for references and completely ignores cases when the identifier under the cursor is actual name of the item/variable. Such condition should be added to this code:

https://github.com/starkware-libs/cairo/blob/4646ad819521338ccd92b8ebef76b96770b46ce1/crates/cairo-lang-language-server/src/lang/inspect/defs.rs#L40-L46

Villegas2003 commented 2 days ago

Hello Marek,

I'm a software developer and a student at Universidad Cenfotec. I have experience working with various technologies, including Angular for frontend development, Springboot for backend development, and MySQL for database management. Additionally, I have a strong interest in blockchain technology and have been eager to apply my knowledge in the Web3 space.

I'm interested in contributing to the Cairo project and would like to help with issue #5826. Could you provide more details on the current status and any guidelines for contributing?

Looking forward to collaborating.

mkaput commented 20 hours ago

Hello!

The issue is still open for taking :) I can assign it to you.

As I said, the implementation should extend the snippet provided in issue description. What I imagine, is that that find_definition(...)? call is replaced with match find_definition(...), and in the None case, an extra check is added that:

  1. Handles variables and params (they're not included in lookup item id array). This can be done by walking up AST for appropriate syntax node kinds and then checking if .name() is the same identifier as the one we have on the input.
  2. Otherwise, gets the top-most LookupItemId and checks .name() equality as described.