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

Support local variables for completion and definition requests #1518

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bjarosze
Copy link
Contributor

Motivation

Support for completion and go to definition for local variables.

Implementation

Basic idea is that we don't have to index all local variables, because they are easy to pull off ad hoc. This way indexing time will stay the same.

Method responsible for locating local variables is Document#locate_local_variable_nodes. It returns all nodes that define local variables which are visible in given position.

Completion implementation is pretty straightforward. Just take all unique names of all local variables.
Definition jumps to closest definition node, e. g:

1| test = 1
2| test = 2
3| test = 3
4| puts test

Jumping to definition from line 4 jumps to line 3. From line 3 to line 2, etc.

Automated Tests

Added tests for both completion and definition.

Manual Tests

Write simple code like:

test = 1
puts t

You should see completion menu and then jump to definition.

@bjarosze bjarosze requested a review from a team as a code owner March 11, 2024 14:47
@KaanOzkan KaanOzkan removed their request for review April 8, 2024 14:09
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.

None yet

1 participant