diff options
Diffstat (limited to 'gopls/internal/lsp/testdata/callhierarchy')
3 files changed, 91 insertions, 0 deletions
diff --git a/gopls/internal/lsp/testdata/callhierarchy/callhierarchy.go b/gopls/internal/lsp/testdata/callhierarchy/callhierarchy.go new file mode 100644 index 000000000..252e8054f --- /dev/null +++ b/gopls/internal/lsp/testdata/callhierarchy/callhierarchy.go @@ -0,0 +1,70 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package callhierarchy + +import "golang.org/lsptests/callhierarchy/outgoing" + +func a() { //@mark(hierarchyA, "a") + D() +} + +func b() { //@mark(hierarchyB, "b") + D() +} + +// C is an exported function +func C() { //@mark(hierarchyC, "C") + D() + D() +} + +// To test hierarchy across function literals +var x = func() { //@mark(hierarchyLiteral, "func"),mark(hierarchyLiteralOut, "x") + D() +} + +// D is exported to test incoming/outgoing calls across packages +func D() { //@mark(hierarchyD, "D"),incomingcalls(hierarchyD, hierarchyA, hierarchyB, hierarchyC, hierarchyLiteral, incomingA),outgoingcalls(hierarchyD, hierarchyE, hierarchyF, hierarchyG, hierarchyLiteralOut, outgoingB, hierarchyFoo, hierarchyH, hierarchyI, hierarchyJ, hierarchyK) + e() + x() + F() + outgoing.B() + foo := func() {} //@mark(hierarchyFoo, "foo"),incomingcalls(hierarchyFoo, hierarchyD),outgoingcalls(hierarchyFoo) + foo() + + func() { + g() + }() + + var i Interface = impl{} + i.H() + i.I() + + s := Struct{} + s.J() + s.K() +} + +func e() {} //@mark(hierarchyE, "e") + +// F is an exported function +func F() {} //@mark(hierarchyF, "F") + +func g() {} //@mark(hierarchyG, "g") + +type Interface interface { + H() //@mark(hierarchyH, "H") + I() //@mark(hierarchyI, "I") +} + +type impl struct{} + +func (i impl) H() {} +func (i impl) I() {} + +type Struct struct { + J func() //@mark(hierarchyJ, "J") + K func() //@mark(hierarchyK, "K") +} diff --git a/gopls/internal/lsp/testdata/callhierarchy/incoming/incoming.go b/gopls/internal/lsp/testdata/callhierarchy/incoming/incoming.go new file mode 100644 index 000000000..c629aa879 --- /dev/null +++ b/gopls/internal/lsp/testdata/callhierarchy/incoming/incoming.go @@ -0,0 +1,12 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package incoming + +import "golang.org/lsptests/callhierarchy" + +// A is exported to test incoming calls across packages +func A() { //@mark(incomingA, "A") + callhierarchy.D() +} diff --git a/gopls/internal/lsp/testdata/callhierarchy/outgoing/outgoing.go b/gopls/internal/lsp/testdata/callhierarchy/outgoing/outgoing.go new file mode 100644 index 000000000..74362d419 --- /dev/null +++ b/gopls/internal/lsp/testdata/callhierarchy/outgoing/outgoing.go @@ -0,0 +1,9 @@ +// Copyright 2020 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package outgoing + +// B is exported to test outgoing calls across packages +func B() { //@mark(outgoingB, "B") +} |