mirror of https://github.com/golang/go.git
internal/lsp: include function literals in outgoing call hierarchy
Currently we don't consider function literals in outgoing call hierarchy, because we only consider expressions of type `ast.SelectorExpr` and `ast.Ident`. So function literals are skipped. Fix this by ensuring we traverse through other types even if we don't add the type itself as an outgoing call hierarchy. Fixes golang/go#43438 Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Change-Id: I9eacbd5ec7a68224518bf0e405319adeb673c853 GitHub-Last-Rev: 3e7118a8fd090b339a3eacf32fa8d62e05a76b87 GitHub-Pull-Request: golang/tools#320 Reviewed-on: https://go-review.googlesource.com/c/tools/+/323809 Reviewed-by: Rebecca Stambler <rstambler@golang.org> Trust: Rebecca Stambler <rstambler@golang.org> Trust: Peter Weinberger <pjw@google.com>
This commit is contained in:
parent
df07577eb1
commit
377464f22d
|
|
@ -223,6 +223,10 @@ func collectCallExpressions(fset *token.FileSet, mapper *protocol.ColumnMapper,
|
|||
start, end = n.Sel.NamePos, call.Lparen
|
||||
case *ast.Ident:
|
||||
start, end = n.NamePos, call.Lparen
|
||||
case *ast.FuncLit:
|
||||
// while we don't add the function literal as an 'outgoing' call
|
||||
// we still want to traverse into it
|
||||
return true
|
||||
default:
|
||||
// ignore any other kind of call expressions
|
||||
// for ex: direct function literal calls since that's not an 'outgoing' call
|
||||
|
|
|
|||
|
|
@ -30,11 +30,14 @@ func D() { //@mark(hierarchyD, "D"),incomingcalls(hierarchyD, hierarchyA, hierar
|
|||
e()
|
||||
x()
|
||||
F()
|
||||
g()
|
||||
outgoing.B()
|
||||
foo := func() {} //@mark(hierarchyFoo, "foo"),incomingcalls(hierarchyFoo, hierarchyD),outgoingcalls(hierarchyFoo)
|
||||
foo()
|
||||
|
||||
func() {
|
||||
g()
|
||||
}()
|
||||
|
||||
var i Interface = impl{}
|
||||
i.H()
|
||||
i.I()
|
||||
|
|
|
|||
Loading…
Reference in New Issue