From 74cedbcf320a3111c43aef520569262f0763ef15 Mon Sep 17 00:00:00 2001 From: qvalentin Date: Sun, 17 Mar 2024 10:12:46 +0100 Subject: [PATCH] fix: configuration is working again --- .mockery.yaml | 10 + Makefile | 2 +- go.mod | 1 + go.sum | 2 + internal/adapter/yamlls/configuration.go | 5 +- internal/adapter/yamlls/initization.go | 8 +- .../adapter/yamlls/integration_test_utils.go | 3 +- internal/handler/configuration.go | 38 +- internal/handler/configuration_test.go | 96 +++ internal/handler/initialization.go | 10 +- mocks/go.lsp.dev/protocol/mock_Client.go | 646 ++++++++++++++++++ 11 files changed, 795 insertions(+), 26 deletions(-) create mode 100644 .mockery.yaml create mode 100644 internal/handler/configuration_test.go create mode 100644 mocks/go.lsp.dev/protocol/mock_Client.go diff --git a/.mockery.yaml b/.mockery.yaml new file mode 100644 index 00000000..45e1571a --- /dev/null +++ b/.mockery.yaml @@ -0,0 +1,10 @@ +with-expecter: true +packages: + go.lsp.dev/protocol: + # place your package-specific config here + config: + interfaces: + # select the interfaces you want mocked + Client: + # Modify package-level config for this specific interface (if applicable) + config: diff --git a/Makefile b/Makefile index 1bc5a4ff..9880237e 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ test: @$(GO) test ./... -v -race -tags=integration coverage: - @$(GO) test -coverprofile=.coverage ./internal/... && go tool cover -html=.coverage + @$(GO) test -coverprofile=.coverage -tags=integration ./internal/... && go tool cover -html=.coverage .PHONY: build-release build-release: diff --git a/go.mod b/go.mod index a88c80d8..9b3ad0ea 100644 --- a/go.mod +++ b/go.mod @@ -60,6 +60,7 @@ require ( github.com/shopspring/decimal v1.2.0 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/stretchr/objx v0.5.2 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 // indirect diff --git a/go.sum b/go.sum index b4280ed2..ca232526 100644 --- a/go.sum +++ b/go.sum @@ -122,6 +122,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= diff --git a/internal/adapter/yamlls/configuration.go b/internal/adapter/yamlls/configuration.go index 607bc7ed..cf4e1575 100644 --- a/internal/adapter/yamlls/configuration.go +++ b/internal/adapter/yamlls/configuration.go @@ -7,12 +7,11 @@ import ( ) // Configuration implements protocol.Client. -func (y Connector) Configuration(ctx context.Context, params *protocol.ConfigurationParams) (result []interface{}, err error) { +func (y Connector) Configuration(_ context.Context, _ *protocol.ConfigurationParams) (result []interface{}, err error) { settings := []interface{}{y.config.YamllsSettings} return settings, nil } -func (y Connector) DidChangeConfiguration() (err error) { - ctx := context.Background() +func (y Connector) DidChangeConfiguration(ctx context.Context) (err error) { return y.server.DidChangeConfiguration(ctx, &protocol.DidChangeConfigurationParams{}) } diff --git a/internal/adapter/yamlls/initization.go b/internal/adapter/yamlls/initization.go index 3611315e..396b6ae5 100644 --- a/internal/adapter/yamlls/initization.go +++ b/internal/adapter/yamlls/initization.go @@ -8,7 +8,7 @@ import ( "go.lsp.dev/uri" ) -func (yamllsConnector Connector) CallInitialize(workspaceURI uri.URI) error { +func (yamllsConnector Connector) CallInitialize(ctx context.Context, workspaceURI uri.URI) error { if yamllsConnector.server == nil { return nil } @@ -21,13 +21,13 @@ func (yamllsConnector Connector) CallInitialize(workspaceURI uri.URI) error { }, } - _, err := yamllsConnector.server.Initialize(context.Background(), ¶ms) + _, err := yamllsConnector.server.Initialize(ctx, ¶ms) if err != nil { return err } - err = yamllsConnector.server.DidChangeConfiguration(context.Background(), &lsp.DidChangeConfigurationParams{}) + err = yamllsConnector.server.DidChangeConfiguration(ctx, &lsp.DidChangeConfigurationParams{}) if err != nil { return err } - return yamllsConnector.server.Initialized(context.Background(), &lsp.InitializedParams{}) + return yamllsConnector.server.Initialized(ctx, &lsp.InitializedParams{}) } diff --git a/internal/adapter/yamlls/integration_test_utils.go b/internal/adapter/yamlls/integration_test_utils.go index df977969..343caf55 100644 --- a/internal/adapter/yamlls/integration_test_utils.go +++ b/internal/adapter/yamlls/integration_test_utils.go @@ -3,6 +3,7 @@ package yamlls import ( + "context" "encoding/json" "os" "strings" @@ -60,7 +61,7 @@ func getYamlLsConnector(t *testing.T, config util.YamllsConfiguration) (*Connect t.Fatal("Could not connect to yaml-language-server") } - yamllsConnector.CallInitialize(uri.File(dir)) + yamllsConnector.CallInitialize(context.Background(), uri.File(dir)) return yamllsConnector, documents, diagnosticsChan } diff --git a/internal/handler/configuration.go b/internal/handler/configuration.go index 599576bf..b733b4fb 100644 --- a/internal/handler/configuration.go +++ b/internal/handler/configuration.go @@ -2,9 +2,10 @@ package handler import ( "context" + "encoding/json" + // "reflect" - "github.com/mrjosh/helm-ls/internal/util" lsp "go.lsp.dev/protocol" ) @@ -14,30 +15,43 @@ func (h *langHandler) DidChangeConfiguration(ctx context.Context, params *lsp.Di return nil } -func (h *langHandler) RetrieveWorkspaceConfiguration(ctx context.Context) { - logger.Println("Calling workspace/configuration") - result := []util.HelmlsConfiguration{util.DefaultConfig} - +func (h *langHandler) retrieveWorkspaceConfiguration(ctx context.Context) { + logger.Debug("Calling workspace/configuration") configurationParams := lsp.ConfigurationParams{ Items: []lsp.ConfigurationItem{{Section: "helm-ls"}}, } + result := h.helmlsConfig rawResult, err := h.client.Configuration(ctx, &configurationParams) - if err != nil { logger.Println("Error calling workspace/configuration", err) - } else { - logger.Println("Workspace configuration:", rawResult) + h.initializationWithConfig(ctx) + return } - if len(result) == 0 { + logger.Debug("Raw Workspace configuration:", rawResult) + + if len(rawResult) == 0 { logger.Println("Workspace configuration is empty") + h.initializationWithConfig(ctx) + return + } + + jsonResult, err := json.Marshal(rawResult[0]) + if err != nil { + logger.Println("Error marshalling workspace/configuration", err) + h.initializationWithConfig(ctx) + return + } + err = json.Unmarshal(jsonResult, &result) + if err != nil { + logger.Println("Error unmarshalling workspace/configuration", err) + h.initializationWithConfig(ctx) return } - // TODO: use retrieved config - h.helmlsConfig = util.DefaultConfig + h.helmlsConfig = result logger.Println("Workspace configuration:", h.helmlsConfig) - h.initializationWithConfig() + h.initializationWithConfig(ctx) } diff --git a/internal/handler/configuration_test.go b/internal/handler/configuration_test.go new file mode 100644 index 00000000..0e0eef8e --- /dev/null +++ b/internal/handler/configuration_test.go @@ -0,0 +1,96 @@ +package handler + +import ( + "context" + "errors" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + + "github.com/mrjosh/helm-ls/internal/charts" + "github.com/mrjosh/helm-ls/internal/util" + mocks "github.com/mrjosh/helm-ls/mocks/go.lsp.dev/protocol" + lsp "go.lsp.dev/protocol" + "go.lsp.dev/uri" +) + +var ( + configurationParams = lsp.ConfigurationParams{Items: []lsp.ConfigurationItem{{Section: "helm-ls"}}} + handler = &langHandler{ + helmlsConfig: util.DefaultConfig, + chartStore: charts.NewChartStore(uri.File("/"), charts.NewChart), + } +) + +func TestConfigurationWorks(t *testing.T) { + mockClient := mocks.NewMockClient(t) + handler.client = mockClient + + userConfig := []interface{}{map[string]interface{}{ + "LogLevel": "debug", + // disable yamlls to avoid configuring it in the test + "yamlls": map[string]interface{}{"enabled": false}, + }} + mockClient.EXPECT().Configuration(mock.Anything, &configurationParams).Return(userConfig, nil) + handler.retrieveWorkspaceConfiguration(context.Background()) + + expectedConfig := util.DefaultConfig + expectedConfig.LogLevel = "debug" + expectedConfig.YamllsConfiguration.Enabled = false + assert.Equal(t, expectedConfig, handler.helmlsConfig) +} + +func TestConfigurationWorksForEmptyConfig(t *testing.T) { + mockClient := mocks.NewMockClient(t) + handler.client = mockClient + // disable yamlls to avoid configuring it in the test + handler.helmlsConfig.YamllsConfiguration.Enabled = false + + userConfig := []interface{}{} + mockClient.EXPECT().Configuration(mock.Anything, &configurationParams).Return(userConfig, nil) + handler.retrieveWorkspaceConfiguration(context.Background()) + + expectedConfig := util.DefaultConfig + expectedConfig.YamllsConfiguration.Enabled = false + assert.Equal(t, expectedConfig, handler.helmlsConfig) +} + +func TestConfigurationWorksForError(t *testing.T) { + mockClient := mocks.NewMockClient(t) + handler.client = mockClient + + // disable yamlls to avoid configuring it in the test + handler.helmlsConfig.YamllsConfiguration.Enabled = false + + userConfig := []interface{}{map[string]interface{}{ + "LogLevel": "debug", + }} + mockClient.EXPECT().Configuration(mock.Anything, &configurationParams).Return(userConfig, errors.New("error")) + handler.retrieveWorkspaceConfiguration(context.Background()) + + expectedConfig := util.DefaultConfig + expectedConfig.YamllsConfiguration.Enabled = false + assert.Equal(t, expectedConfig, handler.helmlsConfig) +} + +func TestConfigurationWorksForJsonError(t *testing.T) { + mockClient := mocks.NewMockClient(t) + handler.client = mockClient + + // disable yamlls to avoid configuring it in the test + handler.helmlsConfig.YamllsConfiguration.Enabled = false + + userConfig := []interface{}{map[string]interface{}{ + "LogLevel": "debug", + "test": func() { + return + }, + }} + mockClient.EXPECT().Configuration(mock.Anything, &configurationParams).Return(userConfig, nil) + handler.retrieveWorkspaceConfiguration(context.Background()) + + expectedConfig := util.DefaultConfig + expectedConfig.YamllsConfiguration.Enabled = false + assert.Equal(t, expectedConfig, handler.helmlsConfig) +} diff --git a/internal/handler/initialization.go b/internal/handler/initialization.go index 4113787a..b388d610 100644 --- a/internal/handler/initialization.go +++ b/internal/handler/initialization.go @@ -50,21 +50,21 @@ func (h *langHandler) Initialize(ctx context.Context, params *lsp.InitializePara } func (h *langHandler) Initialized(ctx context.Context, _ *lsp.InitializedParams) (err error) { - go h.RetrieveWorkspaceConfiguration(ctx) + go h.retrieveWorkspaceConfiguration(ctx) return nil } -func (h *langHandler) initializationWithConfig() { +func (h *langHandler) initializationWithConfig(ctx context.Context) { configureLogLevel(h.helmlsConfig) h.chartStore.SetValuesFilesConfig(h.helmlsConfig.ValuesFilesConfig) - configureYamlls(h) + configureYamlls(ctx, h) } -func configureYamlls(h *langHandler) { +func configureYamlls(ctx context.Context, h *langHandler) { config := h.helmlsConfig if config.YamllsConfiguration.Enabled { h.yamllsConnector = yamlls.NewConnector(config.YamllsConfiguration, h.client, h.documents) - err := h.yamllsConnector.CallInitialize(h.chartStore.RootURI) + err := h.yamllsConnector.CallInitialize(ctx, h.chartStore.RootURI) if err != nil { logger.Error("Error initializing yamlls", err) } diff --git a/mocks/go.lsp.dev/protocol/mock_Client.go b/mocks/go.lsp.dev/protocol/mock_Client.go new file mode 100644 index 00000000..751f61fd --- /dev/null +++ b/mocks/go.lsp.dev/protocol/mock_Client.go @@ -0,0 +1,646 @@ +// Code generated by mockery v2.38.0. DO NOT EDIT. + +package protocol + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + protocol "go.lsp.dev/protocol" +) + +// MockClient is an autogenerated mock type for the Client type +type MockClient struct { + mock.Mock +} + +type MockClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClient) EXPECT() *MockClient_Expecter { + return &MockClient_Expecter{mock: &_m.Mock} +} + +// ApplyEdit provides a mock function with given fields: ctx, params +func (_m *MockClient) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (bool, error) { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for ApplyEdit") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ApplyWorkspaceEditParams) (bool, error)); ok { + return rf(ctx, params) + } + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ApplyWorkspaceEditParams) bool); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, *protocol.ApplyWorkspaceEditParams) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClient_ApplyEdit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ApplyEdit' +type MockClient_ApplyEdit_Call struct { + *mock.Call +} + +// ApplyEdit is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.ApplyWorkspaceEditParams +func (_e *MockClient_Expecter) ApplyEdit(ctx interface{}, params interface{}) *MockClient_ApplyEdit_Call { + return &MockClient_ApplyEdit_Call{Call: _e.mock.On("ApplyEdit", ctx, params)} +} + +func (_c *MockClient_ApplyEdit_Call) Run(run func(ctx context.Context, params *protocol.ApplyWorkspaceEditParams)) *MockClient_ApplyEdit_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.ApplyWorkspaceEditParams)) + }) + return _c +} + +func (_c *MockClient_ApplyEdit_Call) Return(result bool, err error) *MockClient_ApplyEdit_Call { + _c.Call.Return(result, err) + return _c +} + +func (_c *MockClient_ApplyEdit_Call) RunAndReturn(run func(context.Context, *protocol.ApplyWorkspaceEditParams) (bool, error)) *MockClient_ApplyEdit_Call { + _c.Call.Return(run) + return _c +} + +// Configuration provides a mock function with given fields: ctx, params +func (_m *MockClient) Configuration(ctx context.Context, params *protocol.ConfigurationParams) ([]interface{}, error) { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for Configuration") + } + + var r0 []interface{} + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ConfigurationParams) ([]interface{}, error)); ok { + return rf(ctx, params) + } + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ConfigurationParams) []interface{}); ok { + r0 = rf(ctx, params) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]interface{}) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *protocol.ConfigurationParams) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClient_Configuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Configuration' +type MockClient_Configuration_Call struct { + *mock.Call +} + +// Configuration is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.ConfigurationParams +func (_e *MockClient_Expecter) Configuration(ctx interface{}, params interface{}) *MockClient_Configuration_Call { + return &MockClient_Configuration_Call{Call: _e.mock.On("Configuration", ctx, params)} +} + +func (_c *MockClient_Configuration_Call) Run(run func(ctx context.Context, params *protocol.ConfigurationParams)) *MockClient_Configuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.ConfigurationParams)) + }) + return _c +} + +func (_c *MockClient_Configuration_Call) Return(result []interface{}, err error) *MockClient_Configuration_Call { + _c.Call.Return(result, err) + return _c +} + +func (_c *MockClient_Configuration_Call) RunAndReturn(run func(context.Context, *protocol.ConfigurationParams) ([]interface{}, error)) *MockClient_Configuration_Call { + _c.Call.Return(run) + return _c +} + +// LogMessage provides a mock function with given fields: ctx, params +func (_m *MockClient) LogMessage(ctx context.Context, params *protocol.LogMessageParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for LogMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.LogMessageParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_LogMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LogMessage' +type MockClient_LogMessage_Call struct { + *mock.Call +} + +// LogMessage is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.LogMessageParams +func (_e *MockClient_Expecter) LogMessage(ctx interface{}, params interface{}) *MockClient_LogMessage_Call { + return &MockClient_LogMessage_Call{Call: _e.mock.On("LogMessage", ctx, params)} +} + +func (_c *MockClient_LogMessage_Call) Run(run func(ctx context.Context, params *protocol.LogMessageParams)) *MockClient_LogMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.LogMessageParams)) + }) + return _c +} + +func (_c *MockClient_LogMessage_Call) Return(err error) *MockClient_LogMessage_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_LogMessage_Call) RunAndReturn(run func(context.Context, *protocol.LogMessageParams) error) *MockClient_LogMessage_Call { + _c.Call.Return(run) + return _c +} + +// Progress provides a mock function with given fields: ctx, params +func (_m *MockClient) Progress(ctx context.Context, params *protocol.ProgressParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for Progress") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ProgressParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_Progress_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Progress' +type MockClient_Progress_Call struct { + *mock.Call +} + +// Progress is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.ProgressParams +func (_e *MockClient_Expecter) Progress(ctx interface{}, params interface{}) *MockClient_Progress_Call { + return &MockClient_Progress_Call{Call: _e.mock.On("Progress", ctx, params)} +} + +func (_c *MockClient_Progress_Call) Run(run func(ctx context.Context, params *protocol.ProgressParams)) *MockClient_Progress_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.ProgressParams)) + }) + return _c +} + +func (_c *MockClient_Progress_Call) Return(err error) *MockClient_Progress_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_Progress_Call) RunAndReturn(run func(context.Context, *protocol.ProgressParams) error) *MockClient_Progress_Call { + _c.Call.Return(run) + return _c +} + +// PublishDiagnostics provides a mock function with given fields: ctx, params +func (_m *MockClient) PublishDiagnostics(ctx context.Context, params *protocol.PublishDiagnosticsParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for PublishDiagnostics") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.PublishDiagnosticsParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_PublishDiagnostics_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PublishDiagnostics' +type MockClient_PublishDiagnostics_Call struct { + *mock.Call +} + +// PublishDiagnostics is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.PublishDiagnosticsParams +func (_e *MockClient_Expecter) PublishDiagnostics(ctx interface{}, params interface{}) *MockClient_PublishDiagnostics_Call { + return &MockClient_PublishDiagnostics_Call{Call: _e.mock.On("PublishDiagnostics", ctx, params)} +} + +func (_c *MockClient_PublishDiagnostics_Call) Run(run func(ctx context.Context, params *protocol.PublishDiagnosticsParams)) *MockClient_PublishDiagnostics_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.PublishDiagnosticsParams)) + }) + return _c +} + +func (_c *MockClient_PublishDiagnostics_Call) Return(err error) *MockClient_PublishDiagnostics_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_PublishDiagnostics_Call) RunAndReturn(run func(context.Context, *protocol.PublishDiagnosticsParams) error) *MockClient_PublishDiagnostics_Call { + _c.Call.Return(run) + return _c +} + +// RegisterCapability provides a mock function with given fields: ctx, params +func (_m *MockClient) RegisterCapability(ctx context.Context, params *protocol.RegistrationParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for RegisterCapability") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.RegistrationParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_RegisterCapability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RegisterCapability' +type MockClient_RegisterCapability_Call struct { + *mock.Call +} + +// RegisterCapability is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.RegistrationParams +func (_e *MockClient_Expecter) RegisterCapability(ctx interface{}, params interface{}) *MockClient_RegisterCapability_Call { + return &MockClient_RegisterCapability_Call{Call: _e.mock.On("RegisterCapability", ctx, params)} +} + +func (_c *MockClient_RegisterCapability_Call) Run(run func(ctx context.Context, params *protocol.RegistrationParams)) *MockClient_RegisterCapability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.RegistrationParams)) + }) + return _c +} + +func (_c *MockClient_RegisterCapability_Call) Return(err error) *MockClient_RegisterCapability_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_RegisterCapability_Call) RunAndReturn(run func(context.Context, *protocol.RegistrationParams) error) *MockClient_RegisterCapability_Call { + _c.Call.Return(run) + return _c +} + +// ShowMessage provides a mock function with given fields: ctx, params +func (_m *MockClient) ShowMessage(ctx context.Context, params *protocol.ShowMessageParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for ShowMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ShowMessageParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_ShowMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShowMessage' +type MockClient_ShowMessage_Call struct { + *mock.Call +} + +// ShowMessage is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.ShowMessageParams +func (_e *MockClient_Expecter) ShowMessage(ctx interface{}, params interface{}) *MockClient_ShowMessage_Call { + return &MockClient_ShowMessage_Call{Call: _e.mock.On("ShowMessage", ctx, params)} +} + +func (_c *MockClient_ShowMessage_Call) Run(run func(ctx context.Context, params *protocol.ShowMessageParams)) *MockClient_ShowMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.ShowMessageParams)) + }) + return _c +} + +func (_c *MockClient_ShowMessage_Call) Return(err error) *MockClient_ShowMessage_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_ShowMessage_Call) RunAndReturn(run func(context.Context, *protocol.ShowMessageParams) error) *MockClient_ShowMessage_Call { + _c.Call.Return(run) + return _c +} + +// ShowMessageRequest provides a mock function with given fields: ctx, params +func (_m *MockClient) ShowMessageRequest(ctx context.Context, params *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error) { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for ShowMessageRequest") + } + + var r0 *protocol.MessageActionItem + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error)); ok { + return rf(ctx, params) + } + if rf, ok := ret.Get(0).(func(context.Context, *protocol.ShowMessageRequestParams) *protocol.MessageActionItem); ok { + r0 = rf(ctx, params) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*protocol.MessageActionItem) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *protocol.ShowMessageRequestParams) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClient_ShowMessageRequest_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ShowMessageRequest' +type MockClient_ShowMessageRequest_Call struct { + *mock.Call +} + +// ShowMessageRequest is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.ShowMessageRequestParams +func (_e *MockClient_Expecter) ShowMessageRequest(ctx interface{}, params interface{}) *MockClient_ShowMessageRequest_Call { + return &MockClient_ShowMessageRequest_Call{Call: _e.mock.On("ShowMessageRequest", ctx, params)} +} + +func (_c *MockClient_ShowMessageRequest_Call) Run(run func(ctx context.Context, params *protocol.ShowMessageRequestParams)) *MockClient_ShowMessageRequest_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.ShowMessageRequestParams)) + }) + return _c +} + +func (_c *MockClient_ShowMessageRequest_Call) Return(result *protocol.MessageActionItem, err error) *MockClient_ShowMessageRequest_Call { + _c.Call.Return(result, err) + return _c +} + +func (_c *MockClient_ShowMessageRequest_Call) RunAndReturn(run func(context.Context, *protocol.ShowMessageRequestParams) (*protocol.MessageActionItem, error)) *MockClient_ShowMessageRequest_Call { + _c.Call.Return(run) + return _c +} + +// Telemetry provides a mock function with given fields: ctx, params +func (_m *MockClient) Telemetry(ctx context.Context, params interface{}) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for Telemetry") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, interface{}) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_Telemetry_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Telemetry' +type MockClient_Telemetry_Call struct { + *mock.Call +} + +// Telemetry is a helper method to define mock.On call +// - ctx context.Context +// - params interface{} +func (_e *MockClient_Expecter) Telemetry(ctx interface{}, params interface{}) *MockClient_Telemetry_Call { + return &MockClient_Telemetry_Call{Call: _e.mock.On("Telemetry", ctx, params)} +} + +func (_c *MockClient_Telemetry_Call) Run(run func(ctx context.Context, params interface{})) *MockClient_Telemetry_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(interface{})) + }) + return _c +} + +func (_c *MockClient_Telemetry_Call) Return(err error) *MockClient_Telemetry_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_Telemetry_Call) RunAndReturn(run func(context.Context, interface{}) error) *MockClient_Telemetry_Call { + _c.Call.Return(run) + return _c +} + +// UnregisterCapability provides a mock function with given fields: ctx, params +func (_m *MockClient) UnregisterCapability(ctx context.Context, params *protocol.UnregistrationParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for UnregisterCapability") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.UnregistrationParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_UnregisterCapability_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UnregisterCapability' +type MockClient_UnregisterCapability_Call struct { + *mock.Call +} + +// UnregisterCapability is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.UnregistrationParams +func (_e *MockClient_Expecter) UnregisterCapability(ctx interface{}, params interface{}) *MockClient_UnregisterCapability_Call { + return &MockClient_UnregisterCapability_Call{Call: _e.mock.On("UnregisterCapability", ctx, params)} +} + +func (_c *MockClient_UnregisterCapability_Call) Run(run func(ctx context.Context, params *protocol.UnregistrationParams)) *MockClient_UnregisterCapability_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.UnregistrationParams)) + }) + return _c +} + +func (_c *MockClient_UnregisterCapability_Call) Return(err error) *MockClient_UnregisterCapability_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_UnregisterCapability_Call) RunAndReturn(run func(context.Context, *protocol.UnregistrationParams) error) *MockClient_UnregisterCapability_Call { + _c.Call.Return(run) + return _c +} + +// WorkDoneProgressCreate provides a mock function with given fields: ctx, params +func (_m *MockClient) WorkDoneProgressCreate(ctx context.Context, params *protocol.WorkDoneProgressCreateParams) error { + ret := _m.Called(ctx, params) + + if len(ret) == 0 { + panic("no return value specified for WorkDoneProgressCreate") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *protocol.WorkDoneProgressCreateParams) error); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockClient_WorkDoneProgressCreate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WorkDoneProgressCreate' +type MockClient_WorkDoneProgressCreate_Call struct { + *mock.Call +} + +// WorkDoneProgressCreate is a helper method to define mock.On call +// - ctx context.Context +// - params *protocol.WorkDoneProgressCreateParams +func (_e *MockClient_Expecter) WorkDoneProgressCreate(ctx interface{}, params interface{}) *MockClient_WorkDoneProgressCreate_Call { + return &MockClient_WorkDoneProgressCreate_Call{Call: _e.mock.On("WorkDoneProgressCreate", ctx, params)} +} + +func (_c *MockClient_WorkDoneProgressCreate_Call) Run(run func(ctx context.Context, params *protocol.WorkDoneProgressCreateParams)) *MockClient_WorkDoneProgressCreate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*protocol.WorkDoneProgressCreateParams)) + }) + return _c +} + +func (_c *MockClient_WorkDoneProgressCreate_Call) Return(err error) *MockClient_WorkDoneProgressCreate_Call { + _c.Call.Return(err) + return _c +} + +func (_c *MockClient_WorkDoneProgressCreate_Call) RunAndReturn(run func(context.Context, *protocol.WorkDoneProgressCreateParams) error) *MockClient_WorkDoneProgressCreate_Call { + _c.Call.Return(run) + return _c +} + +// WorkspaceFolders provides a mock function with given fields: ctx +func (_m *MockClient) WorkspaceFolders(ctx context.Context) ([]protocol.WorkspaceFolder, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for WorkspaceFolders") + } + + var r0 []protocol.WorkspaceFolder + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]protocol.WorkspaceFolder, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []protocol.WorkspaceFolder); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]protocol.WorkspaceFolder) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClient_WorkspaceFolders_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WorkspaceFolders' +type MockClient_WorkspaceFolders_Call struct { + *mock.Call +} + +// WorkspaceFolders is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockClient_Expecter) WorkspaceFolders(ctx interface{}) *MockClient_WorkspaceFolders_Call { + return &MockClient_WorkspaceFolders_Call{Call: _e.mock.On("WorkspaceFolders", ctx)} +} + +func (_c *MockClient_WorkspaceFolders_Call) Run(run func(ctx context.Context)) *MockClient_WorkspaceFolders_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockClient_WorkspaceFolders_Call) Return(result []protocol.WorkspaceFolder, err error) *MockClient_WorkspaceFolders_Call { + _c.Call.Return(result, err) + return _c +} + +func (_c *MockClient_WorkspaceFolders_Call) RunAndReturn(run func(context.Context) ([]protocol.WorkspaceFolder, error)) *MockClient_WorkspaceFolders_Call { + _c.Call.Return(run) + return _c +} + +// NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClient { + mock := &MockClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}