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

Add Go to implementation cmd to the Go: Show all Commands for better discoverability #1822

Closed
covrom opened this issue Aug 1, 2018 · 9 comments · Fixed by #1952
Closed

Comments

@covrom
Copy link

covrom commented Aug 1, 2018

Proposal. Please, implement a function that shows which interfaces from the current scope are satisfied by the selected function.

@ramya-rao-a
Copy link
Contributor

Are you aware of any Go tools that can do this? The Go extension itself is not smart enough to figure out Go ASTs. It relies on a set of Go Tools to give rich language features.

@vscodebot
Copy link

vscodebot bot commented Aug 11, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. Thank you for your contributions.

@ChrisHines
Copy link

@ramya-rao-a
Copy link
Contributor

Thanks for sharing that @ChrisHines!
We have the Go to implementation and Peek Implementation commands that uses the guru implements command.
@covrom Can you try these commands?

@vimalk78
Copy link
Contributor

@ramya-rao-a is it possible to add this command(Go: Implements) to Go : Show All Commands... right-click sub menu?

i was trying to look for the same, how does vscode invoke guru implements. i could not find it in the list of go commands. I found it in extension source, but had to search in issues to lead to this issue to know how it is to be used.

if this is not a bad idea, i can try sending a PR

@ramya-rao-a
Copy link
Contributor

I understand that this is a discovery problem.

We can add the below commands to the Go: Show All Commands. These are not really registered by the Go extension, but does implement them

  • Go to definition
  • Go to implementation
  • Go to symbol in file
  • Go to symbol in workspace

PR is definitely welcome.
Code pointers:

@ramya-rao-a ramya-rao-a reopened this Sep 22, 2018
@ramya-rao-a ramya-rao-a changed the title Add "View satisfied interfaces" Add Go to implementation cmd to the Go: Show all Commands for better discoverability Sep 22, 2018
@vimalk78
Copy link
Contributor

i tried the following

file : package.json
add a new command

    "commands": [
      {
        "command": "go.go.toimpl",
        "title": "Go: Test Go To Implementation",
        "description": "Test Command for testing go.go.toimpl."
      },

file : goMain.ts
invoke the 'vscode.executeImplementationProvider' command in this command handler

	ctx.subscriptions.push(vscode.commands.registerCommand('go.go.toimpl', () => {
		let textdoc = vscode.window.activeTextEditor.document;
		let pos = vscode.window.activeTextEditor.selection.active;
		vscode.commands.executeCommand('vscode.executeImplementationProvider',textdoc, pos);
	}));	

i am getting the below error in the Debug Console :

Object
command:"go.go.toimpl"
title:"Go: Test Go To Implementation"
description:"Test Command for testing go.go.toimpl."
rejected promise not handled within 1 second

invoking with async/await also results in same error

debugging:
a breakpoint in goImplementations.ts:44 is not hit when invoked via the above command. but breakpoint is hit if invoked via Go -> Go to Implementation from the vscode menu.

perhaps there is a better way. #needhelp

@ramya-rao-a
Copy link
Contributor

Try passing editor.action.goToImplementation as command for vscode.commands.executeCommand, that should work.

But, we shouldnt add new commands that behind the scenes just calls another command. I was thinking of passing the existing commands for Go to Implementation, Go to symbol in file etc to the quick pick control in https://github.com/Microsoft/vscode-go/blob/0.6.89/src/goMain.ts#L357

vimalk78 added a commit to vimalk78/vscode-go that referenced this issue Sep 27, 2018
commands added :
 * Go to definition
 * Go to implementation
 * Go to symbol in file
 * Go to symbol in workspace

fixes microsoft#1822
vimalk78 added a commit to vimalk78/vscode-go that referenced this issue Oct 1, 2018
commands added :
 * Go to definition
 * Go to implementation
 * Go to symbol in file
 * Go to symbol in workspace

fixes microsoft#1822
vimalk78 added a commit to vimalk78/vscode-go that referenced this issue Oct 1, 2018
commands added :
 * Go to definition
 * Go to implementation
 * Go to symbol in file
 * Go to symbol in workspace

fixes microsoft#1822
vimalk78 added a commit to vimalk78/vscode-go that referenced this issue Oct 1, 2018
commands added :
 * Go to definition
 * Go to implementation
 * Go to symbol in file
 * Go to symbol in workspace

fixes microsoft#1822
ramya-rao-a pushed a commit that referenced this issue Oct 10, 2018
* goMain.ts add commands to Go: Show All Commands
commands added :
 * Go to definition
 * Go to implementation
 * Go to symbol in file
 * Go to symbol in workspace

fixes #1822

* Skip descriptions as they dont get shown in the UI
@ramya-rao-a
Copy link
Contributor

This feature is now out in the latest update to the Go extension (0.6.92). Thanks @vimalk78!

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
4 participants