Skip to content
This repository has been archived by the owner on Sep 24, 2021. It is now read-only.

[callhierarchy] added call hierarchy for Go #11

Merged
merged 2 commits into from
May 23, 2018
Merged

Conversation

JanKoehnlein
Copy link
Member

Signed-off-by: Jan Koehnlein jan.koehnlein@typefox.io

@JanKoehnlein JanKoehnlein requested a review from simark March 1, 2018 17:08
@JanKoehnlein
Copy link
Member Author

Available in the context menu over a function or function call.
Please test whether it makes sense this way.

@simark
Copy link

simark commented Mar 1, 2018

If I understand correctly, the call hierarchy UI is not really decided by this extension, it's done by some other Theia extension or the core? So what this extension does is simply state that the Go language supports call hierarchies?

I used this code for testing: https://github.com/simark/ls-interact/tree/master/go-test

When I try on the plus and plusPlus functions, it works. When I try on the Times function (which is defined in other.go), I get:

Error running guru: Command failed: /home/emaisin/gopath/bin/guru -modified referrers /home/emaisin/src/ls-interact/go-test/other.go:#19
guru: query object not found during reloading

in an error popup.

And when trying on Println:

Command failed: /home/emaisin/gopath/bin/godef -t -i -f /home/emaisin/src/ls-interact/go-test/test.go -o 830
godef: no declaration found for fmt.Println

@JanKoehnlein
Copy link
Member Author

JanKoehnlein commented Mar 2, 2018

@simark Yes, the callhierarchy is implemented in @theia/callhierarchy. We just state here that we support it.

The problem you describe comes from a missconfigured GOPATH variable. The command line tools the go LS delegates to needs GOPATH to be defined correctly to find references across files. By default, it assumes GOPATH=~/go. So this is not a callhierarchy issue, but a general one.

I've created #12 to discuss this.

A workaround here is to put

{
    "inferGopath": true
}

in the go.json in the root of your workspace.

@@ -0,0 +1,15 @@
/*
* Copyright (C) 2017 TypeFox and others.
Copy link

Choose a reason for hiding this comment

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

2018?


export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Unbind, isBound: interfaces.IsBound, rebind: interfaces.Rebind) => {
bind(LanguageClientContribution).to(GoClientContribution).inSingletonScope();
bind(MenuContribution).to(GoMenuContribution).inSingletonScope();
bind(CommandContribution).to(GoCommandContribution).inSingletonScope();
bind(GoCommands).to(GoCommands).inSingletonScope();
bind(GoCallHierarchyService).toSelf().inSingletonScope();
Copy link

Choose a reason for hiding this comment

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

There is some indentation issue here.

Signed-off-by: Jan Koehnlein <jan.koehnlein@typefox.io>
Signed-off-by: Jan Koehnlein <jan.koehnlein@typefox.io>
@JanKoehnlein JanKoehnlein merged commit d261010 into master May 23, 2018
@JanKoehnlein JanKoehnlein deleted the jk/callhierarchy branch May 23, 2018 14:20
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.

2 participants