Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

add fillstruct tool #1506

Merged
merged 7 commits into from Feb 19, 2018
Merged

add fillstruct tool #1506

merged 7 commits into from Feb 19, 2018

Conversation

buyology
Copy link
Contributor

@buyology buyology commented Feb 9, 2018

Closes #1227

This adds the nice fillstruct tool.

fillstruct

Copy link
Contributor

@ramya-rao-a ramya-rao-a left a comment

Choose a reason for hiding this comment

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

@buyology I took the liberty of refactoring a bit.

I have left 2 comments. Please do take a look and add the tests. I hope to have this in the next update

Great job!

code: string;
}

export function fillStruct() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to export this function when we already have the runFillStruct?

args.push(offset.toString());
} else if (editor.selection.start.line <= editor.selection.end.line) {
args.push('-line');
args.push(`${editor.selection.start.line + 1},${editor.selection.end.line + 1}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

When the command is run on a selection, fillstruct fails with invalid value "..." for flag -line: strconv.ParseInt: parsing "...": invalid syntax
Looks like the -line flag takes a single number and we are passing 2 here.

Also, in what scenario do we expect the user select text and then run the command?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had that change sitting on my computer :) Since it takes a -line, I thought we might as well support selecting a whole line.

src/goMain.ts Outdated
@@ -434,6 +440,7 @@ function sendTelemetryEventForConfig(goConfig: vscode.WorkspaceConfiguration) {
includeImports: goConfig['gotoSymbol'] && goConfig['gotoSymbol']['includeImports'] + '',
addTags: JSON.stringify(goConfig['addTags']),
removeTags: JSON.stringify(goConfig['removeTags']),
fillStruct: JSON.stringify(goConfig['fillStruct']),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only for configuration. Since there is no config called fillStruct, this change is not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@buyology
Copy link
Contributor Author

Thanks for your comments. Added the tests.

However — after the refactoring I'm back at that same problem that we discussed on Slack that I can see during the tests that stuff is properly edited, but the tests fail. I cannot spot the obvious missing return in this case however.

@ramya-rao-a
Copy link
Contributor

Sorry about that, fixed the issue with the tests.
Also updated to use the first line of the selection as a best guess when selection spans multiple lines.

@buyology
Copy link
Contributor Author

Nice! :)

@ramya-rao-a
Copy link
Contributor

Will just wait for the tests to complete and then merge
Thanks!

@ramya-rao-a ramya-rao-a merged commit 4884626 into microsoft:master Feb 19, 2018
@buyology buyology deleted the fill-struct branch February 19, 2018 08:21
nickboldt added a commit to che-samples/ls-dependencies that referenced this pull request Jan 15, 2019
Change-Id: Iee9b0230618f13e9c864dfee03456c0f8f2a5993
Signed-off-by: nickboldt <nboldt@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants