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

Goimpl implementation #939

Merged
merged 4 commits into from
Jun 4, 2017
Merged

Goimpl implementation #939

merged 4 commits into from
Jun 4, 2017

Conversation

itsjamie
Copy link
Contributor

A start of the goimpl implementation, pretty simple feature as it exists right now, just pop open the info box, take the information and then inject the stdout at the cursor position.

I see a few ways it could be improved, but figure it was better to just get the simple implementation done.

Idea for improvement

  • Check if cursor is on a typedef, if so, allow input to only contain interface
  • If cursor is not on a empty line, ensure to insert selection on first empty line below cursor

Does some basic input validation to ensure the required information is
passed.

The regex included makes the receiver name optional, the intention there
is that if the receiver name isn't included, that the type the cursor is
in should be used as the receiver for the interface.

However, I think that the first step of just having the ability to use
goimpl was a important first step.
@msftclas
Copy link

@itsjamie,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla.microsoft.com.

It will cover your contributions to all Microsoft-managed open source projects.
Thanks,
Microsoft Pull Request Bot

@itsjamie
Copy link
Contributor Author

Just waiting for DocuSign email regarding CLA request.

@msftclas
Copy link

@itsjamie, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, Microsoft Pull Request Bot

@ramya-rao-a
Copy link
Contributor

Hey @itsjamie, I've been meaning to look at this PR since a while, but I've been swamped this week.
Will definitely review it early next week.

Thanks for your work!

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.

Great start @itsjamie . Just added 2 thoughts on it, let me know what you think

return;
}

// TODO: automatically detect type name at cursor
Copy link
Contributor

Choose a reason for hiding this comment

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

In this case, if you use the cursor to determine the type, then where would you propose to place the stub. End of the file?

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 was thinking of right after the type. So it would need some detection to find the first empty line after the type.

Copy link
Contributor

Choose a reason for hiding this comment

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

@fatih Where does vim-go paste the stub while taking the identifier under the cursor as receiver? Am referring to https://github.com/fatih/vim-go/blob/master/doc/vim-go.txt#L665

Copy link

Choose a reason for hiding this comment

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

@ramya-rao-a currently it just places the generated stub under the cursor. It's not in place. There is an open PR that aims to fix it: josharian/impl#16

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @fatih

@@ -117,6 +118,10 @@ export function activate(ctx: vscode.ExtensionContext): void {
removeTags(args);
}));

ctx.subscriptions.push(vscode.commands.registerCommand('go.impl.cursor', () => {
implCursor();
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add this command in package.json as well, so that the command shows up in the command pallet.

Am curious, how did you test this without the command showing up in the command pallet?

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 registered the command to a key command in keybindings.json

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah! thought so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this to the package.json in commit b640cc3

@renannprado
Copy link

waiting for this to be merged :)

@ramya-rao-a ramya-rao-a merged commit 4167655 into microsoft:master Jun 4, 2017
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.

5 participants