-
Notifications
You must be signed in to change notification settings - Fork 645
WIP: Suggestion to expand func types to func snippets (#1553) #1560
Conversation
@ramya-rao-a I suspect this needs a test, but at first glance I'm not sure I understand the tests very well. I suspect I need to add something here - https://github.com/Microsoft/vscode-go/blob/0.6.77/test/go.test.ts#L698 - but that's about all the further I got. I'll probably dive into them more tomorrow, but I don't use typescript often so any help would probably speed this up. The actual PR might be worth refactoring a bit, since a good chunk of the code is reused from the function building section, but it was different enough that I opted to duplicate the similar code. I'm open to changing it if desired. |
Given a type that defines a function, added a code completion suggestion to expand the type into a closure. Eg: type Demo func(int) string Will expand into the the suggest with the name "Demo" and upon triggering it the following snippet will be used: Demo(func(${1:arg1} int) { $2 })
@ramya-rao-a I'd love to figure out what needs done to get this submitted. I think it needs a test of some sort; can you point me to an area in the tests where you think this would be most easily tested? After a test is added, is there anything else you feel will need altered in the PR? |
There is just one test failing and that too only on tip, that's unrelated to your PR, I'll take a look at it soon. Pointer to existing test for completion that you can use as reference: https://github.com/Microsoft/vscode-go/blob/0.6.78/test/go.test.ts#L747 You can add another test file to https://github.com/Microsoft/vscode-go/tree/0.6.78/test/fixtures/completions for your case and test it |
Thank you! |
ping |
So I'm currently swamped and won't have time to finish this for at least a week. If you want to close this in the meantime its fine - I'll just reference it with a new PR when it is ready. |
No worries, take your time. |
👍 Thanks for the help on this. Psyched to see it make it into master finally 😄 |
Yup, I finally got around to adding some tests (See 8dd3f33) I'll release an update early next week. |
@joncalhoun I just realized that if the function has a return type, then the snippet doesnt reflect that. |
Take the below code
Next to
which wont compile as there is no return value in the func declaration |
I think you are right looking the code - I see nothing there for return types. I must have forgot about that use case when writing it, and I haven't touched this code in a while. Want me to take a stab at fixing it or are you going to? Regardless it might make sense to roll back the change since it can break things 😦 |
Fixed with 8bb08f6 There is no need to roll back. |
Given a type that defines a function, this change adds a code completion suggestion to expand the type into a closure. Eg:
Will expand into the the suggest with the name
Demo
and upon triggering it the following snippet will be used:Similarly, given the following type:
The variable name that exists will be used (
i
in this example).If accepted, this resolves #1553