internal/lsp/source: eliminate setKind

Eliminate unnecessary function

Change-Id: I1b590961c3b2042f244eeb4c11c34fbf20b8b74a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/218138
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Tomohiro Kusumoto 2020-02-06 17:53:31 +09:00 committed by Rebecca Stambler
parent 3d51b05cfb
commit 112b90105c
1 changed files with 2 additions and 30 deletions

View File

@ -129,40 +129,12 @@ func funcSymbol(ctx context.Context, view View, pkg Package, decl *ast.FuncDecl,
return s, nil
}
func setKind(s *protocol.DocumentSymbol, typ types.Type, q types.Qualifier) {
switch typ := typ.Underlying().(type) {
case *types.Interface:
s.Kind = protocol.Interface
case *types.Struct:
s.Kind = protocol.Struct
case *types.Signature:
s.Kind = protocol.Function
if typ.Recv() != nil {
s.Kind = protocol.Method
}
case *types.Named:
setKind(s, typ.Underlying(), q)
case *types.Basic:
i := typ.Info()
switch {
case i&types.IsNumeric != 0:
s.Kind = protocol.Number
case i&types.IsBoolean != 0:
s.Kind = protocol.Boolean
case i&types.IsString != 0:
s.Kind = protocol.String
}
default:
s.Kind = protocol.Variable
}
}
func typeSymbol(ctx context.Context, view View, pkg Package, info *types.Info, spec *ast.TypeSpec, obj types.Object, q types.Qualifier) (protocol.DocumentSymbol, error) {
s := protocol.DocumentSymbol{
Name: obj.Name(),
}
s.Detail, _ = formatType(obj.Type(), q)
setKind(&s, obj.Type(), q)
s.Kind = typeToKind(obj.Type())
var err error
s.Range, err = nodeToProtocolRange(view, pkg, spec)
@ -236,7 +208,7 @@ func typeSymbol(ctx context.Context, view View, pkg Package, info *types.Info, s
child := protocol.DocumentSymbol{
Name: types.TypeString(embedded, q),
}
setKind(&child, embedded, q)
child.Kind = typeToKind(embedded)
var spanNode, selectionNode ast.Node
Embeddeds:
for _, f := range ai.Methods.List {