mirror of
https://github.com/golang/go
synced 2024-11-18 08:54:45 -07:00
internal/lsp/source: add Vendor to list of supported commands
I wanted to add a regtest for this, but then immediately got stumped on how to do it well. The best I've got is to add a helper that wraps the client's call to executeCommand, but it's used in so many places that an easier fix was to put it in executeCommand itself. Fixes golang/go#40101 Change-Id: Iafb804fb77e57e6ac01e3de1d115058b21ac1954 Reviewed-on: https://go-review.googlesource.com/c/tools/+/241984 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
f739c553ea
commit
01425d7016
@ -6,6 +6,7 @@ package lsp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
@ -17,6 +18,16 @@ import (
|
||||
)
|
||||
|
||||
func (s *Server) executeCommand(ctx context.Context, params *protocol.ExecuteCommandParams) (interface{}, error) {
|
||||
var found bool
|
||||
for _, command := range s.session.Options().SupportedCommands {
|
||||
if command == params.Command {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return nil, fmt.Errorf("unsupported command detected: %s", params.Command)
|
||||
}
|
||||
switch params.Command {
|
||||
case source.CommandTest:
|
||||
unsaved := false
|
||||
|
@ -102,11 +102,12 @@ func DefaultOptions() Options {
|
||||
Sum: {},
|
||||
},
|
||||
SupportedCommands: []string{
|
||||
CommandGenerate,
|
||||
CommandRegenerateCgo,
|
||||
CommandTest,
|
||||
CommandTidy,
|
||||
CommandUpgradeDependency,
|
||||
CommandGenerate,
|
||||
CommandRegenerateCgo,
|
||||
CommandVendor,
|
||||
},
|
||||
},
|
||||
UserOptions: UserOptions{
|
||||
|
Loading…
Reference in New Issue
Block a user