-
Notifications
You must be signed in to change notification settings - Fork 19
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
cmd/fillstruct: add option to select by line number. #8
Conversation
37a9b6b
to
d01ca2e
Compare
Hm, I get a "could not find file" error when I try to use
|
fbb6762
to
e7731cf
Compare
@Carpetsmoker: I updated the PR, PTAL. |
Thanks!
That output for the line with two structs isn't valid JSON:
Not sure what would be a good/sane way to handle this; put it in an array? Or maybe the current behaviour is fine and clients should treat every output line as its own JSON document? It would also make more sense to print it in reverse, I think. Because replacing the first struct would influence the offset of what follows (making the offsets that I can also give both
It looks like the Another small thing is an inconsistency with
|
@Carpetsmoker, thank you alot for your detailed feedback. About the JSON output: fillstruct is used primarily by editor I like the idea of first trying to use the About the inconsistent error: when no struct literal is found: it |
e7731cf
to
929d207
Compare
@Carpetsmoker, have you had the opportunity to look at my latest changes? |
Ugh. I don't think I got notified about that, or if I did, it slipped through. Sorry about that >_< I'll check over the weekend! |
Seems to work well 👍 PR for vim-go here: fatih/vim-go#1607 |
Great, thanks for your feedback. The tool now always prints a JSON array instead of a JSON object to stdout. That's a breaking change—do you think I can just merge this PR or will it break vim-go for existing users? I'm not sure how to handle that. Do you bundle vim-go releases with the accompanying tools? Or should I tag releases so that users can pull a certain version of fillstruct for a certain version of vim-go? Thanks. |
Yeah, this PR will break vim-go's We don't really have a strategy for managing this at the moment; People reporting issues due to outdated Go tools is actually fairly common. We may need to think about a way to do this better, like bundling dependencies or something to that effect. |
I think this is a necessary change and we should merge fatih/vim-go#1607 as soon as this PR is merged... |
OK, thank you for your feedback—I'll try to keep breaking changes at a minimum. |
The new command line parameter -line can be used to specify the position of one or more struct literals by providing the corresponding line number. If both parameters, -offset and -line, are provided, then the tool first uses the more specific offset information. If there was no struct literal found at the given offset, then the line information is used. If more than one struct literal was found, code to fill all of them is generated. The output is a JSON array with the elements in reverse order of their occurence. Fixes #3.
929d207
to
4081440
Compare
Since davidrjenni/reftools#8, fillstruct always outputs a JSON array.
Fixes #3.