-
Notifications
You must be signed in to change notification settings - Fork 70
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
Create from inferred usage #711
base: master
Are you sure you want to change the base?
Create from inferred usage #711
Conversation
A fun reference, Kolja shared this PR with me where he implements the same functionality for the Elm languages server: |
|
||
val arity = (element.parent as? ElmFunctionCallExpr)?.arguments?.count() ?: 0 | ||
|
||
val argList: String = argListFromArity(arity) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can generate type-based parameter names like this:
val inference = element.findInference() ?: return
val callExpr = element.parent as? ElmFunctionCallExpr ?: return
val argsTys = callExpr.arguments.map { inference.elementType(it) }
val parameters = argsTys.joinToString(" ") { it.renderParam() }
And then, if argsTys
isn't empty, you can generate a type annotation the way the MakeAnnotationIntention does.
"$s : ${TyFunction(args, TyUnknown()).renderedText(elmFile = element.elmFile).replace("→", "->")}"
This will fix #661 |
Hi @dillonkearns ! I took over the stewardship of this repo. I find this PR nice to merge. Do you want to address the point @ajalt made and extend on this feature before you take it out of "draft" and I merge it? Or would you also promote this PR in it's current shape from draft to ready-to-merge? |
For reference, here's the work-in-progress from our live stream today. I'll update this thread as I finish these todos.
Current State
Todos
Maybe now, maybe defer?