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 completion for field names inside recursive records. #1088

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

ebresafegaga
Copy link
Contributor

@ebresafegaga ebresafegaga commented Jan 31, 2023

Implements item 4 in #877

As a consequence of this change, we get completion on stdlib names (such as string, array, contracts, etc), because they are record field names which are in scope.

This only returns field identifiers which are in the current scope.
If a field declaration is in scope, it means that we have access to
it and we should include it as a possible completion identiifer.
@ebresafegaga ebresafegaga self-assigned this Jan 31, 2023
@github-actions github-actions bot temporarily deployed to pull request January 31, 2023 13:27 Inactive
@ebresafegaga ebresafegaga mentioned this pull request Jan 31, 2023
7 tasks
@ebresafegaga ebresafegaga marked this pull request as ready for review January 31, 2023 16:06
@yannham
Copy link
Member

yannham commented Jan 31, 2023

As a consequence of this change, we get completion on stdlib names (such as string, array, contracts, etc), because they are record field names which are in scope.

😎

Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

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

Code looks good, but I tried this inside the mantis benchmark and it didn't work. That being said, I don't know if it didn't because it was too slow, or something related to coc.nvim not liking the LSP. Does it work for you @ebresafegaga ? If you go inside types.ncl, pick a random record, and add a new filed that refers to one of its sibling (which is a record), do you get completion?

@ebresafegaga
Copy link
Contributor Author

ebresafegaga commented Feb 1, 2023

I'm not sure what is going on, but I know in some cases, if the program incomplete, the parser might not be able to correctly parse the record with good error recovery.

I get completion if I do this (note the comma at the end):


image

If the comma is not present, no completion is given

@yannham
Copy link
Member

yannham commented Feb 1, 2023

Got it. In any case incomplete programs are a more general problem, and orthogonal to this PR. It's good to go for me 👍

@ebresafegaga ebresafegaga merged commit 3c60ef1 into master Feb 1, 2023
@ebresafegaga ebresafegaga deleted the lsp/recursive-records branch February 1, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants