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

Goimpl implementation#939

Merged
ramya-rao-a merged 4 commits intomicrosoft:masterfrom
itsjamie:goimpl-implementation
Jun 4, 2017
Merged

Goimpl implementation#939
ramya-rao-a merged 4 commits intomicrosoft:masterfrom
itsjamie:goimpl-implementation

Conversation

@itsjamie
Copy link
Copy Markdown
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
Copy Markdown

@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
Copy Markdown
Contributor Author

Just waiting for DocuSign email regarding CLA request.

@msftclas
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @fatih

}));

ctx.subscriptions.push(vscode.commands.registerCommand('go.impl.cursor', () => {
implCursor();
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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