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

complete JSX prop values #667

Merged
merged 3 commits into from
Dec 29, 2022
Merged

complete JSX prop values #667

merged 3 commits into from
Dec 29, 2022

Conversation

zth
Copy link
Collaborator

@zth zth commented Dec 29, 2022

This is ready for an initial review @cristianoc . A few things to consider:

  • Can we figure out if we need to qualify variant constructors as we complete them? That's a typical issue with JSX props IIRC, that you almost always have to qualify them so the compiler can find them.
  • How can we figure out if we need to expand options for JSX props? With fn arguments it was "easy" - optional label should expand option. How do we do it in JSX, do we need to look up the underlying make function? Maybe we already have access to what we need and I just need a gentle push in the right direction to connect the dots.

Closes #322

@zth zth requested a review from cristianoc December 29, 2022 10:38
@@ -1572,6 +1572,81 @@ let completeTypedValue ~env ~envWhereCompletionStarted ~full ~prefix
in
completeTypedValueInner ~env ~full ~prefix ~expandOption

let getJsxLabels ~componentPath ~findTypeOfValue ~package =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This fn is mostly just extracted for reuse, and adapted so it also returns the relevant env for the labels produced.

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

I think variants are pretty much always unqualified in these completion cases driven by types, as the prop (or label in case of fun) determines the type the variant belongs to.
One counter example that comes to mind is when the prop has a generic type, but I guess in that case we're not able to do typed completion to begin with.

@zth zth mentioned this pull request Dec 29, 2022
24 tasks
@zth zth merged commit 793d195 into master Dec 29, 2022
@zth zth deleted the complete-props-jsx branch December 29, 2022 17:39
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.

[Feature Request] Autocompletion for JSX variant/polymorphic variant props
2 participants