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

Improve generation of function template variable names #754

Merged
merged 8 commits into from
Apr 28, 2023

Conversation

zth
Copy link
Collaborator

@zth zth commented Apr 3, 2023

We're able to generate function template/snippets for callbacks since a while back. But, given that the type information has no name for unlabelled arguments, we've been forced to call most variables in the generated template v (with a few notable exceptions that we've special cased).

This PR improves how we infer template variable names by looking at the type path. For example, the type Environment.t would be called environment in templates, whereas Environment.envConfig would be called envConfig.

This can help the DX quite a lot, because we can capture some of the variable name intent, at least for more complex types.

Before:
image

After:
image

I think this will be quite useful, but interested in hearing more thoughts.

@zth zth requested a review from cristianoc April 3, 2023 12:25
@cristianoc
Copy link
Collaborator

Looks like CI is red.

@zth
Copy link
Collaborator Author

zth commented Apr 3, 2023

No idea why CI is red now, everything passes locally. Will try and figure out tomorrow.

@zth zth force-pushed the poc-template-variable-names branch from c684fbb to 31d576e Compare April 27, 2023 19:16
@zth
Copy link
Collaborator Author

zth commented Apr 27, 2023

@cristianoc I removed the custom attribute stuff, and just went with improving the template variable names for now.

@zth zth merged commit 7fdcee7 into master Apr 28, 2023
@zth zth deleted the poc-template-variable-names branch April 28, 2023 04:46
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.

2 participants