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

Add the receiver to method completions #100

Merged
merged 4 commits into from
Dec 26, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/suggest/candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,12 @@ func (b *candidateCollector) asCandidate(obj types.Object) Candidate {
path = pkg.Path()
}

receiver := ""
var receiver string
if sig, ok := typ.(*types.Signature); ok {
if receiverVar := sig.Recv(); receiverVar != nil {
receiver = types.TypeString(receiverVar.Type(), func(*types.Package) string { return "" })
if sig.Recv() != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry, one last comment - you can avoid the nested if with:

if sig, ok := typ.(*types.Signature); ok && sig.Recv() != nil {

receiver = types.TypeString(sig.Recv().Type(), func(*types.Package) string {
return ""
})
}
}

Expand Down