Skip to content

Commit

Permalink
Declare executeCommand support
Browse files Browse the repository at this point in the history
  • Loading branch information
appilon committed Oct 21, 2020
1 parent 3993db4 commit 8e73794
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
51 changes: 21 additions & 30 deletions langserver/handlers/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ import (
"github.com/stretchr/testify/mock"
)

const intializeResponse = `{
"jsonrpc": "2.0",
"id": 1,
"result": {
"capabilities": {
"textDocumentSync": {
"openClose": true,
"change": 2
},
"completionProvider": {},
"documentSymbolProvider":true,
"documentFormattingProvider":true,
"executeCommandProvider": {
"commands": ["workspaces"]
}
}
}
}`

func TestInitalizeAndShutdown(t *testing.T) {
ls := langserver.NewLangServerMock(t, NewMockSession(&MockSessionInput{
RootModules: map[string]*rootmodule.RootModuleMock{
Expand All @@ -30,21 +49,7 @@ func TestInitalizeAndShutdown(t *testing.T) {
"capabilities": {},
"rootUri": %q,
"processId": 12345
}`, TempDir(t).URI())}, `{
"jsonrpc": "2.0",
"id": 1,
"result": {
"capabilities": {
"textDocumentSync": {
"openClose": true,
"change": 2
},
"completionProvider": {},
"documentSymbolProvider":true,
"documentFormattingProvider":true
}
}
}`)
}`, TempDir(t).URI())}, intializeResponse)
ls.CallAndExpectResponse(t, &langserver.CallRequest{
Method: "shutdown", ReqParams: `{}`},
`{
Expand All @@ -69,21 +74,7 @@ func TestEOF(t *testing.T) {
"capabilities": {},
"rootUri": %q,
"processId": 12345
}`, TempDir(t).URI())}, `{
"jsonrpc": "2.0",
"id": 1,
"result": {
"capabilities": {
"textDocumentSync": {
"openClose": true,
"change": 2
},
"completionProvider": {},
"documentSymbolProvider":true,
"documentFormattingProvider":true
}
}
}`)
}`, TempDir(t).URI())}, intializeResponse)

ls.CloseClientStdout(t)

Expand Down
3 changes: 3 additions & 0 deletions langserver/handlers/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ func (lh *logHandler) Initialize(ctx context.Context, params lsp.InitializeParam
},
DocumentFormattingProvider: true,
DocumentSymbolProvider: true,
ExecuteCommandProvider: &lsp.ExecuteCommandOptions{
Commands: []string{"workspaces"},
},
},
}

Expand Down

0 comments on commit 8e73794

Please sign in to comment.