Open slimsag opened 6 years ago
IMHO, present error is better as it is a no-go for a function or method to be implemented. I also wonder how come it would work on methods. Sounds illogical to me.
The language server client (e.g. editors) shouldn't need to know a priori if a given location in a file is a valid location to call "find implementations". No results instead of an error makes sense to me.
I'm not sure that that's right FWIW, or it might be masking an error.
Calling "find implementations" on MustParse in github.com/kevinburke/aws-vault/vendor/github.com/alecthomas/kingpin.v2 should return at least one implementation, in github.com/kevinburke/aws-vault/main.go, but it doesn't find it.
@kevinburke Find implementations finds methods which implement an interface methods. What you are referring to is find references. In this case it works https://sourcegraph.com/github.com/kevinburke/aws-vault/-/blob/vendor/gopkg.in/alecthomas/kingpin.v2/global.go#L84:6=&tab=references
I suppose but I guess even if I'm calling it incorrectly, it would be nice if the error message was clearer, for example, it could say "this function is not an interface definition" instead of "this function is not a method", the latter of which doesn't make much sense.
If you find implementations on a function rather than a method, you get an error:
e.g. https://sourcegraph.com/github.com/sourcegraph/go-langserver/-/blob/langserver/implementation.go#L65:6&tab=impl
Of course, finding implementations on a function doesn't make sense. It only works on interface types and methods (finding the interfaces that implement that method).
We could make this error less confusing by e.g. just returning no error and simply returning no results.
The error originates from here: https://sourcegraph.com/github.com/sourcegraph/go-langserver@bf90fac03a4d1a07f50701547d56fabfdb0c32ec/-/blob/langserver/implementation.go#L76:30