Debian Codegraph @

gopls/internal/server/interactive.go

raw symbols SCIP
1 // Copyright 2026 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 "fmt"
10
11 "golang.org/x/tools/gopls/internal/cache"
12 "golang.org/x/tools/gopls/internal/golang"
13 "golang.org/x/tools/gopls/internal/protocol"
14 "golang.org/x/tools/internal/event"
15 )
16
17 // InteractiveListEnum handles requests to dynamically populate interactive UI
18 // elements in the client. Based on the requested param.Source, it queries the
19 // underlying session data (like workspace symbols) and returns a list of enum
20 // entries matching the user's query.
21 func (s *server) InteractiveListEnum(ctx context.Context, param *protocol.InteractiveListEnumParams) ([]protocol.FormEnumEntry, error) {
22 ctx, done := event.Start(ctx, "server.interactiveListEnum")
23 defer done()
24
25 switch param.Source {
26 case "workspaceSymbol":
27 var snapshots []*cache.Snapshot
28 for _, v := range s.session.Views() {
29 snapshot, release, err := v.Snapshot()
30 if err != nil {
31 continue // snapshot is shutting down
32 }
33 // If err is non-nil, the snapshot is shutting down. Skip it.
34 defer release()
35 snapshots = append(snapshots, snapshot)
36 }
37 return golang.ListWorkspaceSymbol(ctx, snapshots, param)
38 default:
39 return nil, fmt.Errorf("unrecognized enum source: %s", param.Source)
40 }
41 }