| 1 |
|
| 2 |
|
| 3 |
|
| 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 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 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 |
| 32 |
} |
| 33 |
|
| 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 |
} |