Skip to content

Symbols: include Go packages

Administrator requested to merge include-go-packages into master

Created by: chrismwendt

Motivation: basic-code-intel will be more precise when it filters definitions by which package it's defined in. Before this change, parent information was being suppressed for some Go symbols.

Before to this change, many Go symbols had a null parent because packages were suppressed with --kinds-Go=-p.

sqlite> select * from symbols where path = 'mux.go';
name               namelowercase      path        pathlowercase  line        kind        language    parent      parentkind  signature   pattern                                                       filelimited
-----------------  -----------------  ----------  -------------  ----------  ----------  ----------  ----------  ----------  ----------  ------------------------------------------------------------  -----------
ErrMethodMismatch  errmethodmismatch  mux.go      mux.go         18          var         Go                                              /^	ErrMethodMismatch = errors.New("method is not allowed")$/  0
ErrNotFound        errnotfound        mux.go      mux.go         20          var         Go                                              /^	ErrNotFound = errors.New("no matching route was found")$/  0
NewRouter          newrouter          mux.go      mux.go         24          func        Go                                  ()          /^func NewRouter() *Router {$/                                0
Router             router             mux.go      mux.go         46          struct      Go                                              /^type Router struct {$/                                      0
NotFoundHandler    notfoundhandler    mux.go      mux.go         48          member      Go          Router      struct                  /^	NotFoundHandler http.Handler$/                             0

After this change, more Go symbols will have a valid parent, which is often times the package they're defined in. Contrast the parent column before and after:

sqlite> select * from symbols where path = 'mux.go';
name        namelowercase  path        pathlowercase  line        kind        language    parent      parentkind  signature   pattern          filelimited
----------  -------------  ----------  -------------  ----------  ----------  ----------  ----------  ----------  ----------  ---------------  -----------
mux         mux            mux.go      mux.go         5           package     Go                                              /^package mux$/  0
ErrMethodM  errmethodmism  mux.go      mux.go         18          var         Go          mux         package                 /^	ErrMethodMis  0
ErrNotFoun  errnotfound    mux.go      mux.go         20          var         Go          mux         package                 /^	ErrNotFound   0
NewRouter   newrouter      mux.go      mux.go         24          func        Go          mux         package     ()          /^func NewRoute  0
Router      router         mux.go      mux.go         46          struct      Go          mux         package                 /^type Router s  0
NotFoundHa  notfoundhandl  mux.go      mux.go         48          member      Go          mux.Router  struct                  /^	NotFoundHand  0

As a side effect, for any package foo, there will be N symbols named foo of kind package, one for each file in the package's directory. This isn't exactly desirable, but will be mitigated by scoping the symbols sidebar to the current file.

image

Merge request reports

Loading