Debian Codegraph @

gopls/internal/server/workspace_symbol.go

raw symbols SCIP
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package server
6
7 import (
8 "context"
9
10 "golang.org/x/tools/gopls/internal/cache"
11 "golang.org/x/tools/gopls/internal/golang"
12 "golang.org/x/tools/gopls/internal/protocol"
13 "golang.org/x/tools/gopls/internal/telemetry"
14 "golang.org/x/tools/internal/event"
15 )
16
17 func (s *server) Symbol(ctx context.Context, params *protocol.WorkspaceSymbolParams) (_ []protocol.SymbolInformation, rerr error) {
18 recordLatency := telemetry.StartLatencyTimer("symbol")
19 defer func() {
20 recordLatency(ctx, rerr)
21 }()
22
23 ctx, done := event.Start(ctx, "server.Symbol")
24 defer done()
25
26 views := s.session.Views()
27 matcher := s.Options().SymbolMatcher
28 style := s.Options().SymbolStyle
29
30 var snapshots []*cache.Snapshot
31 for _, v := range views {
32 snapshot, release, err := v.Snapshot()
33 if err != nil {
34 continue // snapshot is shutting down
35 }
36 // If err is non-nil, the snapshot is shutting down. Skip it.
37 defer release()
38 snapshots = append(snapshots, snapshot)
39 }
40 return golang.WorkspaceSymbols(ctx, snapshots, params.Query, golang.WorkspaceSymbolsOptions{Matcher: matcher, Style: style})
41 }