diff --git a/go.mod b/go.mod index 511049c8db..0d0fd7bb67 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( github.com/confluentinc/cmf-sdk-go v0.0.2 github.com/confluentinc/confluent-kafka-go/v2 v2.6.0 github.com/confluentinc/go-editor v0.11.0 - github.com/confluentinc/go-prompt v0.2.38 + github.com/confluentinc/go-prompt v0.2.40 github.com/confluentinc/go-ps1 v1.0.2 github.com/confluentinc/kafka-rest-sdk-go/kafkarestv3 v0.3.18 github.com/confluentinc/mds-sdk-go-public/mdsv1 v0.0.0-20240923163156-b922b35891f9 @@ -87,6 +87,7 @@ require ( github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100 github.com/linkedin/goavro/v2 v2.13.0 github.com/mattn/go-isatty v0.0.20 + github.com/mattn/go-runewidth v0.0.15 github.com/olekukonko/tablewriter v0.0.5 github.com/opencontainers/image-spec v1.1.0 github.com/panta/machineid v1.0.2 @@ -175,7 +176,6 @@ require ( github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mattn/go-tty v0.0.4 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect diff --git a/go.sum b/go.sum index eade639084..87eb5f6233 100644 --- a/go.sum +++ b/go.sum @@ -271,8 +271,8 @@ github.com/confluentinc/confluent-kafka-go/v2 v2.6.0 h1:VKnMT71Tl0dCp3lfGBp2D8eq github.com/confluentinc/confluent-kafka-go/v2 v2.6.0/go.mod h1:hScqtFIGUI1wqHIgM3mjoqEou4VweGGGX7dMpcUKves= github.com/confluentinc/go-editor v0.11.0 h1:fcEALYHj7xV/fRSp54/IHi2DS4GlZMJWVgrYvi/llvU= github.com/confluentinc/go-editor v0.11.0/go.mod h1:nEjwqdqx8S7ZGjXsDvRgawsA04Fu2P/KAtA8fa5afMI= -github.com/confluentinc/go-prompt v0.2.38 h1:z9tSfrJYHbiZC81kZQjenW5nFx9w2Vzbs84aswwx3vE= -github.com/confluentinc/go-prompt v0.2.38/go.mod h1:Bc4kUldoYFpXx7frWasxAG0wpp+xOcu/Ehq930/FJBw= +github.com/confluentinc/go-prompt v0.2.40 h1:tveghQJ+FVOVvF0dgQaZEm7YZSQ3r3tyuLMHy7w4PK0= +github.com/confluentinc/go-prompt v0.2.40/go.mod h1:Bc4kUldoYFpXx7frWasxAG0wpp+xOcu/Ehq930/FJBw= github.com/confluentinc/go-ps1 v1.0.2 h1:+4cKOzWs3AWmxL2s96oHu0QutZESDRXECnhFzm2ic4o= github.com/confluentinc/go-ps1 v1.0.2/go.mod h1:qmgG9xQgFd4u7/CS6eA9nNP8eQqOtXuRHmZ4+w7Vprs= github.com/confluentinc/kafka-rest-sdk-go/kafkarestv3 v0.3.18 h1:M9/yzpG+eOTp/peiHNHRQWax0If6+GAJIC/NcvbzAOI= diff --git a/pkg/flink/app/application.go b/pkg/flink/app/application.go index 9720ec854a..3d840f501c 100644 --- a/pkg/flink/app/application.go +++ b/pkg/flink/app/application.go @@ -118,7 +118,7 @@ func StartApp(gatewayClient ccloudv2.GatewayClientInterface, tokenRefreshFunc fu reportUsage: reportUsageFunc, appOptions: appOptions, } - components.PrintWelcomeHeader() + components.PrintWelcomeHeader(appOptions) return app.readEvalPrintLoop() } diff --git a/pkg/flink/components/.snapshots/TestPrintCompletionsFalse b/pkg/flink/components/.snapshots/TestPrintCompletionsFalse new file mode 100644 index 0000000000..03d885d253 --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintCompletionsFalse @@ -0,0 +1,3 @@ + +Completions are now disabled. + diff --git a/pkg/flink/components/.snapshots/TestPrintCompletionsTrue b/pkg/flink/components/.snapshots/TestPrintCompletionsTrue new file mode 100644 index 0000000000..8f77a0e746 --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintCompletionsTrue @@ -0,0 +1,3 @@ + +Completions are now enabled. + diff --git a/pkg/flink/components/.snapshots/TestPrintDiagnosticsStateFalse b/pkg/flink/components/.snapshots/TestPrintDiagnosticsStateFalse new file mode 100644 index 0000000000..f72e0be9fe --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintDiagnosticsStateFalse @@ -0,0 +1,3 @@ + +Diagnostics are now disabled. + diff --git a/pkg/flink/components/.snapshots/TestPrintDiagnosticsStateTrue b/pkg/flink/components/.snapshots/TestPrintDiagnosticsStateTrue new file mode 100644 index 0000000000..264b1fcdf6 --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintDiagnosticsStateTrue @@ -0,0 +1,4 @@ + +You should now see the errors in your SQL statement highlighted as you type, if there are any. +Diagnostics are now enabled. + diff --git a/pkg/flink/components/.snapshots/TestPrintSmartCompletionFalse b/pkg/flink/components/.snapshots/TestPrintSmartCompletionFalse new file mode 100644 index 0000000000..ff0658972b --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintSmartCompletionFalse @@ -0,0 +1,3 @@ + +Smart Completion is now disabled + diff --git a/pkg/flink/components/.snapshots/TestPrintSmartCompletionTrue b/pkg/flink/components/.snapshots/TestPrintSmartCompletionTrue new file mode 100644 index 0000000000..f2e9e130b2 --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintSmartCompletionTrue @@ -0,0 +1,3 @@ + +Smart Completion is now enabled + diff --git a/pkg/flink/components/.snapshots/TestPrintSmartDiagnosticsStateTrue b/pkg/flink/components/.snapshots/TestPrintSmartDiagnosticsStateTrue new file mode 100644 index 0000000000..7f8d29c857 --- /dev/null +++ b/pkg/flink/components/.snapshots/TestPrintSmartDiagnosticsStateTrue @@ -0,0 +1,4 @@ + +You should now see the errors in your SQL statement highlighted as you type, if there are any. +Diagnostics are now enabled. + diff --git a/pkg/flink/components/interactive_input.go b/pkg/flink/components/interactive_input.go index b0f5b68fc5..cd74d90b19 100644 --- a/pkg/flink/components/interactive_input.go +++ b/pkg/flink/components/interactive_input.go @@ -4,14 +4,25 @@ import ( "strings" fColor "github.com/fatih/color" + "github.com/mattn/go-runewidth" "github.com/confluentinc/cli/v4/pkg/color" + "github.com/confluentinc/cli/v4/pkg/featureflags" + "github.com/confluentinc/cli/v4/pkg/flink/types" "github.com/confluentinc/cli/v4/pkg/output" ) -func PrintSmartCompletionState(smartCompletion bool, maxCol int) { - msgPrefix := "Smart Completion is now " - PrintOptionState(msgPrefix, smartCompletion, maxCol) +func PrintCompletionsState(completionsEnabled bool, maxCol int) { + msgPrefix := "Completions are now " + PrintOptionState(msgPrefix, completionsEnabled, maxCol) +} + +func PrintDiagnosticsState(diagnosticsEnabled bool, maxCol int) { + msg := "Diagnostics are now " + if diagnosticsEnabled { + msg = "You should now see the errors in your SQL statement highlighted as you type, if there are any.\n" + msg + } + PrintOptionState(msg, diagnosticsEnabled, maxCol) } func PrintOptionState(prefix string, isEnabled bool, maxCol int) { @@ -20,18 +31,35 @@ func PrintOptionState(prefix string, isEnabled bool, maxCol int) { stateMsg = "enabled" } - output.Print(false, "\n"+prefix+fColor.CyanString(stateMsg)) + lines := strings.Split(prefix, "\n") + + output.Print(false, "\n") + for i, line := range lines { + if i == len(lines)-1 { + output.Print(false, line+fColor.CyanString(stateMsg)+".") + line = line + stateMsg + "." + } else { + output.Print(false, line) + } - // This prints to the console the exact amount of empty characters to fill the line might have autocompletions before - output.Println(false, strings.Repeat(" ", maxCol-len(prefix+stateMsg))) + // This prints to the console the exact amount of empty characters to fill the line might have autocompletions before + // This is to avoid the linter to complain about not using the + output.Println(false, strings.Repeat(" ", maxCol-runewidth.StringWidth(line))) + } } -func PrintWelcomeHeader() { +func PrintWelcomeHeader(appOtions types.ApplicationOptions) { // Print welcome message output.Print(false, "Welcome! \n") output.Print(false, "To exit, press Ctrl-Q or type \"exit\". \n\n") // Print shortcuts c := fColor.New(color.AccentColor) - output.Printf(false, "[Ctrl-Q] %s [Ctrl-S] %s \n", c.Sprint("Quit"), c.Sprint("Toggle Smart Completion")) + + ldClient := featureflags.GetCcloudLaunchDarklyClient(appOtions.Context.PlatformName) + if featureflags.Manager.BoolVariation("flink.language_service.enable_diagnostics", appOtions.Context, ldClient, true, false) { + output.Printf(false, "[Ctrl-Q] %s [Ctrl-S] %s [Ctrl-G] %s \n", c.Sprint("Quit"), c.Sprint("Toggle Completions"), c.Sprint("Toggle Diagnostics")) + } else { + output.Printf(false, "[Ctrl-Q] %s [Ctrl-S] %s \n", c.Sprint("Quit"), c.Sprint("Toggle Completions")) + } } diff --git a/pkg/flink/components/interactive_input_test.go b/pkg/flink/components/interactive_input_test.go new file mode 100644 index 0000000000..f1aa60b5e8 --- /dev/null +++ b/pkg/flink/components/interactive_input_test.go @@ -0,0 +1,43 @@ +package components + +import ( + "testing" + + "github.com/bradleyjkemp/cupaloy/v2" + + "github.com/confluentinc/cli/v4/pkg/flink/test" +) + +const maxCol = 100 + +func TestPrintCompletionsTrue(t *testing.T) { + actual := test.RunAndCaptureSTDOUT(t, func() { + PrintCompletionsState(true, maxCol) + }) + + cupaloy.SnapshotT(t, actual) +} + +func TestPrintCompletionsFalse(t *testing.T) { + actual := test.RunAndCaptureSTDOUT(t, func() { + PrintCompletionsState(false, maxCol) + }) + + cupaloy.SnapshotT(t, actual) +} + +func TestPrintDiagnosticsStateTrue(t *testing.T) { + actual := test.RunAndCaptureSTDOUT(t, func() { + PrintDiagnosticsState(true, maxCol) + }) + + cupaloy.SnapshotT(t, actual) +} + +func TestPrintDiagnosticsStateFalse(t *testing.T) { + actual := test.RunAndCaptureSTDOUT(t, func() { + PrintDiagnosticsState(false, maxCol) + }) + + cupaloy.SnapshotT(t, actual) +} diff --git a/pkg/flink/internal/autocomplete/completer.go b/pkg/flink/internal/autocomplete/completer.go index e4809a57b4..716170f2ca 100644 --- a/pkg/flink/internal/autocomplete/completer.go +++ b/pkg/flink/internal/autocomplete/completer.go @@ -4,11 +4,11 @@ import ( "github.com/confluentinc/go-prompt" ) -func combineCompleters(getSmartCompletion func() bool, completers ...prompt.Completer) prompt.Completer { +func combineCompleters(getCompletionsEnabled func() bool, completers ...prompt.Completer) prompt.Completer { return func(d prompt.Document) []prompt.Suggest { suggestions := []prompt.Suggest{} - if !getSmartCompletion() { + if !getCompletionsEnabled() { return suggestions } @@ -20,19 +20,19 @@ func combineCompleters(getSmartCompletion func() bool, completers ...prompt.Comp } type completerBuilder struct { - isSmartCompletionEnabled func() bool - completer prompt.Completer + completionsEnabled func() bool + completer prompt.Completer } -func NewCompleterBuilder(isSmartCompletionEnabled func() bool) *completerBuilder { - return &completerBuilder{isSmartCompletionEnabled: isSmartCompletionEnabled} +func NewCompleterBuilder(completionsEnabled func() bool) *completerBuilder { + return &completerBuilder{completionsEnabled: completionsEnabled} } func (c *completerBuilder) AddCompleter(completer prompt.Completer) *completerBuilder { if c.completer == nil { - c.completer = combineCompleters(c.isSmartCompletionEnabled, completer) + c.completer = combineCompleters(c.completionsEnabled, completer) } else { - c.completer = combineCompleters(c.isSmartCompletionEnabled, c.completer, completer) + c.completer = combineCompleters(c.completionsEnabled, c.completer, completer) } return c } diff --git a/pkg/flink/internal/autocomplete/completer_test.go b/pkg/flink/internal/autocomplete/completer_test.go index 26e9544420..6f71fa1393 100644 --- a/pkg/flink/internal/autocomplete/completer_test.go +++ b/pkg/flink/internal/autocomplete/completer_test.go @@ -12,7 +12,7 @@ import ( "github.com/confluentinc/cli/v4/pkg/flink/test/generators" ) -func mockGetSmartCompletion() bool { +func mockCompletionsEnabled() bool { return true } @@ -22,7 +22,7 @@ func TestBasicSelectAutoCompletion(t *testing.T) { buffer.InsertText(input, false, true) expected := prompt.Suggest{Text: "SELECT ", Description: "Select data from a database"} - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). AddCompleter(SetCompleter). AddCompleter(ShowCompleter). @@ -38,7 +38,7 @@ func TestFailingBasicAutoCompletion(t *testing.T) { buffer.InsertText(input, false, true) expected := prompt.Suggest{Text: "SELECT", Description: "Select data from a database"} - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). AddCompleter(SetCompleter). AddCompleter(ShowCompleter). @@ -62,7 +62,7 @@ func TestNoLineBreaksInAutocompletion(t *testing.T) { // when buffer.InsertText(randomStatement.Text, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). AddCompleter(SetCompleter). AddCompleter(ShowCompleter). diff --git a/pkg/flink/internal/autocomplete/examples_completer_test.go b/pkg/flink/internal/autocomplete/examples_completer_test.go index 3a21dd3e85..c1de3ba16a 100644 --- a/pkg/flink/internal/autocomplete/examples_completer_test.go +++ b/pkg/flink/internal/autocomplete/examples_completer_test.go @@ -13,7 +13,7 @@ func TestSelectExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() @@ -27,7 +27,7 @@ func TestAlterExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() @@ -41,7 +41,7 @@ func TestInserttExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() @@ -55,7 +55,7 @@ func TestDescribeExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() @@ -69,7 +69,7 @@ func TestUseExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() @@ -83,7 +83,7 @@ func TestSetExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() @@ -97,7 +97,7 @@ func TestResetExampleAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ExamplesCompleter). BuildCompleter() diff --git a/pkg/flink/internal/autocomplete/history_completer_test.go b/pkg/flink/internal/autocomplete/history_completer_test.go index c43266c0e0..3260b60ab2 100644 --- a/pkg/flink/internal/autocomplete/history_completer_test.go +++ b/pkg/flink/internal/autocomplete/history_completer_test.go @@ -15,7 +15,7 @@ func TestHistorySnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(GenerateHistoryCompleter(history)). BuildCompleter() diff --git a/pkg/flink/internal/autocomplete/set_completer_test.go b/pkg/flink/internal/autocomplete/set_completer_test.go index 5ff47ed99d..df96dd4d9b 100644 --- a/pkg/flink/internal/autocomplete/set_completer_test.go +++ b/pkg/flink/internal/autocomplete/set_completer_test.go @@ -13,7 +13,7 @@ func TestSetAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(SetCompleter). BuildCompleter() diff --git a/pkg/flink/internal/autocomplete/show_completer_test.go b/pkg/flink/internal/autocomplete/show_completer_test.go index 4fbc177f85..9d3f188a33 100644 --- a/pkg/flink/internal/autocomplete/show_completer_test.go +++ b/pkg/flink/internal/autocomplete/show_completer_test.go @@ -13,7 +13,7 @@ func TestShowAutoCompletionSnapshot(t *testing.T) { buffer := prompt.NewBuffer() buffer.InsertText(input, false, true) - completer := NewCompleterBuilder(mockGetSmartCompletion). + completer := NewCompleterBuilder(mockCompletionsEnabled). AddCompleter(ShowCompleter). BuildCompleter() diff --git a/pkg/flink/internal/controller/input_controller.go b/pkg/flink/internal/controller/input_controller.go index 6993040965..3b922c0b58 100644 --- a/pkg/flink/internal/controller/input_controller.go +++ b/pkg/flink/internal/controller/input_controller.go @@ -25,7 +25,8 @@ import ( type InputController struct { History *history.History InitialBuffer string - smartCompletion bool + completionsEnabled bool + diagnosticsEnabled bool reverseISearchEnabled bool prompt prompt.IPrompt shouldExit bool @@ -37,12 +38,13 @@ const defaultWindowSize = 100 func NewInputController(history *history.History, lspCompleter prompt.Completer, handlerCh chan *jsonrpc2.Request) types.InputControllerInterface { inputController := &InputController{ - History: history, - InitialBuffer: "", - smartCompletion: true, - shouldExit: false, - reverseISearch: reverseisearch.NewReverseISearch(), - lspCompleter: lspCompleter, + History: history, + InitialBuffer: "", + completionsEnabled: true, + diagnosticsEnabled: true, + shouldExit: false, + reverseISearch: reverseisearch.NewReverseISearch(), + lspCompleter: lspCompleter, } if prompt, err := inputController.initPrompt(); err == nil { inputController.prompt = prompt @@ -163,7 +165,7 @@ func (c *InputController) initPrompt() (prompt.IPrompt, error) { } func (c *InputController) promptCompleter() prompt.Completer { - completer := autocomplete.NewCompleterBuilder(c.getSmartCompletion) + completer := autocomplete.NewCompleterBuilder(c.CompletionsEnabled) if c.lspCompleter == nil { completer. @@ -179,12 +181,16 @@ func (c *InputController) promptCompleter() prompt.Completer { return completer.BuildCompleter() } -func (c *InputController) getSmartCompletion() bool { - return c.smartCompletion +func (c *InputController) CompletionsEnabled() bool { + return c.completionsEnabled } -func (c *InputController) toggleSmartCompletion() { - c.smartCompletion = !c.smartCompletion +func (c *InputController) DiagnosticsEnabled() bool { + return c.diagnosticsEnabled +} + +func (c *InputController) toggleCompletions() { + c.completionsEnabled = !c.completionsEnabled maxCol, err := c.getMaxCol() if err != nil { @@ -192,7 +198,20 @@ func (c *InputController) toggleSmartCompletion() { return } - components.PrintSmartCompletionState(c.getSmartCompletion(), maxCol) + components.PrintCompletionsState(c.CompletionsEnabled(), maxCol) +} + +func (c *InputController) toggleDiagnostics() { + c.diagnosticsEnabled = !c.diagnosticsEnabled + c.SetDiagnostics(nil) + + maxCol, err := c.getMaxCol() + if err != nil { + log.CliLogger.Error(err) + return + } + + components.PrintDiagnosticsState(c.DiagnosticsEnabled(), maxCol) } func (c *InputController) getKeyBindings() []prompt.Option { @@ -211,7 +230,13 @@ func (c *InputController) getKeyBindings() []prompt.Option { prompt.OptionAddKeyBind(prompt.KeyBind{ Key: prompt.ControlS, Fn: func(b *prompt.Buffer) { - c.toggleSmartCompletion() + c.toggleCompletions() + }, + }), + prompt.OptionAddKeyBind(prompt.KeyBind{ + Key: prompt.ControlG, + Fn: func(b *prompt.Buffer) { + c.toggleDiagnostics() }, }), prompt.OptionAddKeyBind(prompt.KeyBind{ @@ -290,6 +315,11 @@ func startLspRequestHandler(c types.InputControllerInterface, handlerCh chan *js for req := range handlerCh { switch req.Method { case "textDocument/publishDiagnostics": + if !c.DiagnosticsEnabled() { + log.CliLogger.Infof("Received diagnostics from language server, but diagnostics are disabled") + continue + } + var params lsp.PublishDiagnosticsParams if err := json.Unmarshal(*req.Params, ¶ms); err != nil { log.CliLogger.Error("Not able to unmarshal diagnostics from language server", err) diff --git a/pkg/flink/internal/controller/input_controller_test.go b/pkg/flink/internal/controller/input_controller_test.go index 397fa9ad92..734ad52ccf 100644 --- a/pkg/flink/internal/controller/input_controller_test.go +++ b/pkg/flink/internal/controller/input_controller_test.go @@ -151,18 +151,36 @@ func (s *InputControllerTestSuite) TestHasUserInitiatedExitShouldBeFalse() { require.False(s.T(), hasUserEnabledReverseSearch) } -func (s *InputControllerTestSuite) TestTurnOnSmartCompletion() { - s.inputController.smartCompletion = false +func (s *InputControllerTestSuite) TestTurnOnCompletions() { + s.inputController.completionsEnabled = false - s.inputController.toggleSmartCompletion() + s.inputController.toggleCompletions() - require.True(s.T(), s.inputController.smartCompletion) + require.True(s.T(), s.inputController.completionsEnabled) } -func (s *InputControllerTestSuite) TestTurnOffSmartCompletion() { - s.inputController.smartCompletion = true +func (s *InputControllerTestSuite) TestTurnOffCompletions() { + s.inputController.completionsEnabled = true - s.inputController.toggleSmartCompletion() + s.inputController.toggleCompletions() - require.False(s.T(), s.inputController.smartCompletion) + require.False(s.T(), s.inputController.completionsEnabled) +} + +func (s *InputControllerTestSuite) TestTurnOnDiagnostics() { + s.inputController.diagnosticsEnabled = false + s.prompt.EXPECT().SetDiagnostics(nil) + + s.inputController.toggleDiagnostics() + + require.True(s.T(), s.inputController.diagnosticsEnabled) +} + +func (s *InputControllerTestSuite) TestTurnOffDiagnostics() { + s.inputController.diagnosticsEnabled = true + s.prompt.EXPECT().SetDiagnostics(nil) + + s.inputController.toggleDiagnostics() + + require.False(s.T(), s.inputController.diagnosticsEnabled) } diff --git a/pkg/flink/lsp/completer_test.go b/pkg/flink/lsp/completer_test.go index 8bf80fe79b..e1a85bdb5b 100644 --- a/pkg/flink/lsp/completer_test.go +++ b/pkg/flink/lsp/completer_test.go @@ -4,9 +4,9 @@ import ( "errors" "testing" - "github.com/golang/mock/gomock" "github.com/sourcegraph/go-lsp" "github.com/stretchr/testify/require" + "go.uber.org/mock/gomock" "github.com/confluentinc/cli/v4/pkg/flink/test/mock" ) diff --git a/pkg/flink/lsp/lsp_handler.go b/pkg/flink/lsp/lsp_handler.go index e8e56ee5b8..335d92aa8a 100644 --- a/pkg/flink/lsp/lsp_handler.go +++ b/pkg/flink/lsp/lsp_handler.go @@ -4,6 +4,8 @@ import ( "context" "github.com/sourcegraph/jsonrpc2" + + "github.com/confluentinc/cli/v4/pkg/log" ) type LSPHandler struct { @@ -12,7 +14,13 @@ type LSPHandler struct { //  All we do here is to pass the request to the channel since the controller that has to process and do something with the request is the InputController func (h *LSPHandler) Handle(ctx context.Context, conn *jsonrpc2.Conn, req *jsonrpc2.Request) { - h.handlerCh <- req + select { + case h.handlerCh <- req: + // Successfully sent the request + default: + // Channel is closed or full + log.CliLogger.Warn("handlerCh is closed or full, unable to send request to handler") + } } func NewLspHandler(handlerCh chan *jsonrpc2.Request) *LSPHandler { diff --git a/pkg/flink/test/mock/application_controller_mock.go b/pkg/flink/test/mock/application_controller_mock.go index 488d82098c..5a7c353932 100644 --- a/pkg/flink/test/mock/application_controller_mock.go +++ b/pkg/flink/test/mock/application_controller_mock.go @@ -5,6 +5,7 @@ // // mockgen -destination application_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ApplicationControllerInterface // + // Package mock is a generated GoMock package. package mock diff --git a/pkg/flink/test/mock/console_parser_mock.go b/pkg/flink/test/mock/console_parser_mock.go index 0fc52bfe63..be4a2082f4 100644 --- a/pkg/flink/test/mock/console_parser_mock.go +++ b/pkg/flink/test/mock/console_parser_mock.go @@ -5,6 +5,7 @@ // // mockgen -destination console_parser_mock.go -package=mock github.com/confluentinc/go-prompt ConsoleParser // + // Package mock is a generated GoMock package. package mock diff --git a/pkg/flink/test/mock/input_controller_mock.go b/pkg/flink/test/mock/input_controller_mock.go index 532ff9d37b..32a8a98eb2 100644 --- a/pkg/flink/test/mock/input_controller_mock.go +++ b/pkg/flink/test/mock/input_controller_mock.go @@ -5,13 +5,14 @@ // // mockgen -destination input_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types InputControllerInterface // + // Package mock is a generated GoMock package. package mock import ( reflect "reflect" - "github.com/sourcegraph/go-lsp" + lsp "github.com/sourcegraph/go-lsp" gomock "go.uber.org/mock/gomock" ) @@ -38,6 +39,20 @@ func (m *MockInputControllerInterface) EXPECT() *MockInputControllerInterfaceMoc return m.recorder } +// DiagnosticsEnabled mocks base method. +func (m *MockInputControllerInterface) DiagnosticsEnabled() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DiagnosticsEnabled") + ret0, _ := ret[0].(bool) + return ret0 +} + +// DiagnosticsEnabled indicates an expected call of DiagnosticsEnabled. +func (mr *MockInputControllerInterfaceMockRecorder) DiagnosticsEnabled() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DiagnosticsEnabled", reflect.TypeOf((*MockInputControllerInterface)(nil).DiagnosticsEnabled)) +} + // GetUserInput mocks base method. func (m *MockInputControllerInterface) GetUserInput() string { m.ctrl.T.Helper() @@ -94,26 +109,26 @@ func (mr *MockInputControllerInterfaceMockRecorder) HasUserInitiatedExit(arg0 an return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUserInitiatedExit", reflect.TypeOf((*MockInputControllerInterface)(nil).HasUserInitiatedExit), arg0) } -// StartReverseSearch mocks base method. -func (m *MockInputControllerInterface) StartReverseSearch() { +// SetDiagnostics mocks base method. +func (m *MockInputControllerInterface) SetDiagnostics(arg0 []lsp.Diagnostic) { m.ctrl.T.Helper() - m.ctrl.Call(m, "StartReverseSearch") + m.ctrl.Call(m, "SetDiagnostics", arg0) } -// StartReverseSearch indicates an expected call of StartReverseSearch. -func (mr *MockInputControllerInterfaceMockRecorder) StartReverseSearch() *gomock.Call { +// SetDiagnostics indicates an expected call of SetDiagnostics. +func (mr *MockInputControllerInterfaceMockRecorder) SetDiagnostics(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartReverseSearch", reflect.TypeOf((*MockInputControllerInterface)(nil).StartReverseSearch)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockInputControllerInterface)(nil).SetDiagnostics), arg0) } -// SetDiagnostics mocks base method. -func (m *MockInputControllerInterface) SetDiagnostics(arg0 []lsp.Diagnostic) { +// StartReverseSearch mocks base method. +func (m *MockInputControllerInterface) StartReverseSearch() { m.ctrl.T.Helper() - m.ctrl.Call(m, "SetDiagnostics") + m.ctrl.Call(m, "StartReverseSearch") } -// SetDiagnostics indicates an expected call of SetDiagnostics. -func (mr *MockInputControllerInterfaceMockRecorder) SetDiagnostics(arg0 any) *gomock.Call { +// StartReverseSearch indicates an expected call of StartReverseSearch. +func (mr *MockInputControllerInterfaceMockRecorder) StartReverseSearch() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetDiagnostics", reflect.TypeOf((*MockInputControllerInterface)(nil).SetDiagnostics)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartReverseSearch", reflect.TypeOf((*MockInputControllerInterface)(nil).StartReverseSearch)) } diff --git a/pkg/flink/test/mock/json_rpc2_conn.go b/pkg/flink/test/mock/json_rpc2_conn.go index fd601607a6..26a69e15d4 100644 --- a/pkg/flink/test/mock/json_rpc2_conn.go +++ b/pkg/flink/test/mock/json_rpc2_conn.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: JSONRpcConn) +// +// Generated by this command: +// +// mockgen -destination json_rpc2_conn.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types JSONRpcConn +// // Package mock is a generated GoMock package. package mock @@ -8,8 +13,8 @@ import ( context "context" reflect "reflect" - gomock "github.com/golang/mock/gomock" jsonrpc2 "github.com/sourcegraph/jsonrpc2" + gomock "go.uber.org/mock/gomock" ) // MockJSONRpcConn is a mock of JSONRpcConn interface. @@ -36,9 +41,9 @@ func (m *MockJSONRpcConn) EXPECT() *MockJSONRpcConnMockRecorder { } // Call mocks base method. -func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 interface{}, arg4 ...jsonrpc2.CallOption) error { +func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 any, arg4 ...jsonrpc2.CallOption) error { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2, arg3} + varargs := []any{arg0, arg1, arg2, arg3} for _, a := range arg4 { varargs = append(varargs, a) } @@ -48,9 +53,9 @@ func (m *MockJSONRpcConn) Call(arg0 context.Context, arg1 string, arg2, arg3 int } // Call indicates an expected call of Call. -func (mr *MockJSONRpcConnMockRecorder) Call(arg0, arg1, arg2, arg3 interface{}, arg4 ...interface{}) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) Call(arg0, arg1, arg2, arg3 any, arg4 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2, arg3}, arg4...) + varargs := append([]any{arg0, arg1, arg2, arg3}, arg4...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Call", reflect.TypeOf((*MockJSONRpcConn)(nil).Call), varargs...) } @@ -83,9 +88,9 @@ func (mr *MockJSONRpcConnMockRecorder) DisconnectNotify() *gomock.Call { } // DispatchCall mocks base method. -func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 interface{}, arg3 ...jsonrpc2.CallOption) (jsonrpc2.Waiter, error) { +func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 any, arg3 ...jsonrpc2.CallOption) (jsonrpc2.Waiter, error) { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} + varargs := []any{arg0, arg1, arg2} for _, a := range arg3 { varargs = append(varargs, a) } @@ -96,16 +101,16 @@ func (m *MockJSONRpcConn) DispatchCall(arg0 context.Context, arg1 string, arg2 i } // DispatchCall indicates an expected call of DispatchCall. -func (mr *MockJSONRpcConnMockRecorder) DispatchCall(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) DispatchCall(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + varargs := append([]any{arg0, arg1, arg2}, arg3...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DispatchCall", reflect.TypeOf((*MockJSONRpcConn)(nil).DispatchCall), varargs...) } // Notify mocks base method. -func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 interface{}, arg3 ...jsonrpc2.CallOption) error { +func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 any, arg3 ...jsonrpc2.CallOption) error { m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} + varargs := []any{arg0, arg1, arg2} for _, a := range arg3 { varargs = append(varargs, a) } @@ -115,9 +120,9 @@ func (m *MockJSONRpcConn) Notify(arg0 context.Context, arg1 string, arg2 interfa } // Notify indicates an expected call of Notify. -func (mr *MockJSONRpcConnMockRecorder) Notify(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) Notify(arg0, arg1, arg2 any, arg3 ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) + varargs := append([]any{arg0, arg1, arg2}, arg3...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Notify", reflect.TypeOf((*MockJSONRpcConn)(nil).Notify), varargs...) } @@ -130,7 +135,7 @@ func (m *MockJSONRpcConn) ReplyWithError(arg0 context.Context, arg1 jsonrpc2.ID, } // ReplyWithError indicates an expected call of ReplyWithError. -func (mr *MockJSONRpcConnMockRecorder) ReplyWithError(arg0, arg1, arg2 interface{}) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) ReplyWithError(arg0, arg1, arg2 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReplyWithError", reflect.TypeOf((*MockJSONRpcConn)(nil).ReplyWithError), arg0, arg1, arg2) } @@ -144,7 +149,7 @@ func (m *MockJSONRpcConn) SendResponse(arg0 context.Context, arg1 *jsonrpc2.Resp } // SendResponse indicates an expected call of SendResponse. -func (mr *MockJSONRpcConnMockRecorder) SendResponse(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockJSONRpcConnMockRecorder) SendResponse(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendResponse", reflect.TypeOf((*MockJSONRpcConn)(nil).SendResponse), arg0, arg1) } diff --git a/pkg/flink/test/mock/output_controller_mock.go b/pkg/flink/test/mock/output_controller_mock.go index 4c1f0036d4..5c3eb1700d 100644 --- a/pkg/flink/test/mock/output_controller_mock.go +++ b/pkg/flink/test/mock/output_controller_mock.go @@ -5,6 +5,7 @@ // // mockgen -destination output_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types OutputControllerInterface // + // Package mock is a generated GoMock package. package mock diff --git a/pkg/flink/test/mock/result_fetcher_mock.go b/pkg/flink/test/mock/result_fetcher_mock.go index cc626b90f2..a54f3197fb 100644 --- a/pkg/flink/test/mock/result_fetcher_mock.go +++ b/pkg/flink/test/mock/result_fetcher_mock.go @@ -5,6 +5,7 @@ // // mockgen -destination result_fetcher_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types ResultFetcherInterface // + // Package mock is a generated GoMock package. package mock diff --git a/pkg/flink/test/mock/reverse_i_search_mock.go b/pkg/flink/test/mock/reverse_i_search_mock.go index 13e585872f..616235ddab 100644 --- a/pkg/flink/test/mock/reverse_i_search_mock.go +++ b/pkg/flink/test/mock/reverse_i_search_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/internal/reverseisearch (interfaces: ReverseISearch) +// +// Generated by this command: +// +// mockgen -destination reverse_i_search_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/internal/reverseisearch ReverseISearch +// // Package mock is a generated GoMock package. package mock @@ -42,7 +47,7 @@ func (m *MockReverseISearch) ReverseISearch(arg0 []string, arg1 string) string { } // ReverseISearch indicates an expected call of ReverseISearch. -func (mr *MockReverseISearchMockRecorder) ReverseISearch(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockReverseISearchMockRecorder) ReverseISearch(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReverseISearch", reflect.TypeOf((*MockReverseISearch)(nil).ReverseISearch), arg0, arg1) } diff --git a/pkg/flink/test/mock/statement_controller_mock.go b/pkg/flink/test/mock/statement_controller_mock.go index a357392c97..dc0ed0ab88 100644 --- a/pkg/flink/test/mock/statement_controller_mock.go +++ b/pkg/flink/test/mock/statement_controller_mock.go @@ -5,6 +5,7 @@ // // mockgen -destination statement_controller_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StatementControllerInterface // + // Package mock is a generated GoMock package. package mock diff --git a/pkg/flink/test/mock/store_mock.go b/pkg/flink/test/mock/store_mock.go index bddd1a347e..75174b4c93 100644 --- a/pkg/flink/test/mock/store_mock.go +++ b/pkg/flink/test/mock/store_mock.go @@ -1,5 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: github.com/confluentinc/cli/v4/pkg/flink/types (interfaces: StoreInterface) +// +// Generated by this command: +// +// mockgen -destination store_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/types StoreInterface +// // Package mock is a generated GoMock package. package mock @@ -7,6 +12,7 @@ package mock import ( context "context" reflect "reflect" + types "github.com/confluentinc/cli/v4/pkg/flink/types" gomock "go.uber.org/mock/gomock" ) @@ -43,7 +49,7 @@ func (m *MockStoreInterface) DeleteStatement(arg0 string) bool { } // DeleteStatement indicates an expected call of DeleteStatement. -func (mr *MockStoreInterfaceMockRecorder) DeleteStatement(arg0 interface{}) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) DeleteStatement(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteStatement", reflect.TypeOf((*MockStoreInterface)(nil).DeleteStatement), arg0) } @@ -58,67 +64,11 @@ func (m *MockStoreInterface) FetchStatementResults(arg0 types.ProcessedStatement } // FetchStatementResults indicates an expected call of FetchStatementResults. -func (mr *MockStoreInterfaceMockRecorder) FetchStatementResults(arg0 interface{}) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) FetchStatementResults(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FetchStatementResults", reflect.TypeOf((*MockStoreInterface)(nil).FetchStatementResults), arg0) } -// GetAuthToken mocks base method. -func (m *MockStoreInterface) GetAuthToken() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAuthToken") - ret0, _ := ret[0].(string) - return ret0 -} - -// GetAuthToken indicates an expected call of GetAuthToken. -func (mr *MockStoreInterfaceMockRecorder) GetAuthToken() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAuthToken", reflect.TypeOf((*MockStoreInterface)(nil).GetAuthToken)) -} - -// GetComputePool mocks base method. -func (m *MockStoreInterface) GetComputePool() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetComputePool") - ret0, _ := ret[0].(string) - return ret0 -} - -// GetComputePool indicates an expected call of GetComputePool. -func (mr *MockStoreInterfaceMockRecorder) GetComputePool() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetComputePool", reflect.TypeOf((*MockStoreInterface)(nil).GetComputePool)) -} - -// GetEnvironmentId mocks base method. -func (m *MockStoreInterface) GetEnvironmentId() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetEnvironmentId") - ret0, _ := ret[0].(string) - return ret0 -} - -// GetEnvironmentId indicates an expected call of GetEnvironmentId. -func (mr *MockStoreInterfaceMockRecorder) GetEnvironmentId() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetEnvironmentId", reflect.TypeOf((*MockStoreInterface)(nil).GetEnvironmentId)) -} - -// GetOrganizationId mocks base method. -func (m *MockStoreInterface) GetOrganizationId() string { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetOrganizationId") - ret0, _ := ret[0].(string) - return ret0 -} - -// GetOrganizationId indicates an expected call of GetOrganizationId. -func (mr *MockStoreInterfaceMockRecorder) GetOrganizationId() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetOrganizationId", reflect.TypeOf((*MockStoreInterface)(nil).GetOrganizationId)) -} - // ProcessStatement mocks base method. func (m *MockStoreInterface) ProcessStatement(arg0 string) (*types.ProcessedStatement, *types.StatementError) { m.ctrl.T.Helper() @@ -129,7 +79,7 @@ func (m *MockStoreInterface) ProcessStatement(arg0 string) (*types.ProcessedStat } // ProcessStatement indicates an expected call of ProcessStatement. -func (mr *MockStoreInterfaceMockRecorder) ProcessStatement(arg0 interface{}) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) ProcessStatement(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ProcessStatement", reflect.TypeOf((*MockStoreInterface)(nil).ProcessStatement), arg0) } @@ -143,7 +93,7 @@ func (m *MockStoreInterface) StopStatement(arg0 string) bool { } // StopStatement indicates an expected call of StopStatement. -func (mr *MockStoreInterfaceMockRecorder) StopStatement(arg0 interface{}) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) StopStatement(arg0 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StopStatement", reflect.TypeOf((*MockStoreInterface)(nil).StopStatement), arg0) } @@ -158,7 +108,7 @@ func (m *MockStoreInterface) WaitForTerminalStatementState(arg0 context.Context, } // WaitForTerminalStatementState indicates an expected call of WaitForTerminalStatementState. -func (mr *MockStoreInterfaceMockRecorder) WaitForTerminalStatementState(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) WaitForTerminalStatementState(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitForTerminalStatementState", reflect.TypeOf((*MockStoreInterface)(nil).WaitForTerminalStatementState), arg0, arg1) } @@ -173,7 +123,7 @@ func (m *MockStoreInterface) WaitPendingStatement(arg0 context.Context, arg1 typ } // WaitPendingStatement indicates an expected call of WaitPendingStatement. -func (mr *MockStoreInterfaceMockRecorder) WaitPendingStatement(arg0, arg1 interface{}) *gomock.Call { +func (mr *MockStoreInterfaceMockRecorder) WaitPendingStatement(arg0, arg1 any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WaitPendingStatement", reflect.TypeOf((*MockStoreInterface)(nil).WaitPendingStatement), arg0, arg1) } diff --git a/pkg/flink/test/mock/table_view_mock.go b/pkg/flink/test/mock/table_view_mock.go index 90b38040b2..4d7106a756 100644 --- a/pkg/flink/test/mock/table_view_mock.go +++ b/pkg/flink/test/mock/table_view_mock.go @@ -5,6 +5,7 @@ // // mockgen -destination table_view_mock.go -package=mock github.com/confluentinc/cli/v4/pkg/flink/components TableViewInterface // + // Package mock is a generated GoMock package. package mock diff --git a/pkg/flink/types/controllers.go b/pkg/flink/types/controllers.go index 272d489995..d59f4dc9ff 100644 --- a/pkg/flink/types/controllers.go +++ b/pkg/flink/types/controllers.go @@ -14,6 +14,7 @@ type InputControllerInterface interface { StartReverseSearch() GetWindowWidth() int SetDiagnostics(diagnostics []lsp.Diagnostic) + DiagnosticsEnabled() bool } type StatementControllerInterface interface { diff --git a/test/fixtures/output/flink/shell/reset-all-keys.golden b/test/fixtures/output/flink/shell/reset-all-keys.golden index 6aac45793f..d5e410ea87 100644 --- a/test/fixtures/output/flink/shell/reset-all-keys.golden +++ b/test/fixtures/output/flink/shell/reset-all-keys.golden @@ -1,6 +1,6 @@ Welcome! To exit, press Ctrl-Q or type "exit". -[Ctrl-Q] Quit [Ctrl-S] Toggle Smart Completion +[Ctrl-Q] Quit [Ctrl-S] Toggle Completions [Ctrl-G] Toggle Diagnostics > set 'cli.a-key'='a value'; Statement successfully submitted. Statement phase is COMPLETED. diff --git a/test/fixtures/output/flink/shell/reset-single-key.golden b/test/fixtures/output/flink/shell/reset-single-key.golden index d730261c3f..f60a418280 100644 --- a/test/fixtures/output/flink/shell/reset-single-key.golden +++ b/test/fixtures/output/flink/shell/reset-single-key.golden @@ -1,6 +1,6 @@ Welcome! To exit, press Ctrl-Q or type "exit". -[Ctrl-Q] Quit [Ctrl-S] Toggle Smart Completion +[Ctrl-Q] Quit [Ctrl-S] Toggle Completions [Ctrl-G] Toggle Diagnostics > set 'cli.a-key'='a value'; Statement successfully submitted. Statement phase is COMPLETED. diff --git a/test/fixtures/output/flink/shell/set-single-key.golden b/test/fixtures/output/flink/shell/set-single-key.golden index 16241cd309..b853fce825 100644 --- a/test/fixtures/output/flink/shell/set-single-key.golden +++ b/test/fixtures/output/flink/shell/set-single-key.golden @@ -1,6 +1,6 @@ Welcome! To exit, press Ctrl-Q or type "exit". -[Ctrl-Q] Quit [Ctrl-S] Toggle Smart Completion +[Ctrl-Q] Quit [Ctrl-S] Toggle Completions [Ctrl-G] Toggle Diagnostics > set 'cli.a-key'='a value'; Statement successfully submitted. Statement phase is COMPLETED. diff --git a/test/fixtures/output/flink/shell/use-catalog.golden b/test/fixtures/output/flink/shell/use-catalog.golden index 2ede486fe8..8cda807be9 100644 --- a/test/fixtures/output/flink/shell/use-catalog.golden +++ b/test/fixtures/output/flink/shell/use-catalog.golden @@ -1,6 +1,6 @@ Welcome! To exit, press Ctrl-Q or type "exit". -[Ctrl-Q] Quit [Ctrl-S] Toggle Smart Completion +[Ctrl-Q] Quit [Ctrl-S] Toggle Completions [Ctrl-G] Toggle Diagnostics > use catalog default; Statement successfully submitted. Statement phase is COMPLETED. diff --git a/test/fixtures/output/flink/shell/use-database.golden b/test/fixtures/output/flink/shell/use-database.golden index b39fe2a14c..93bdb27085 100644 --- a/test/fixtures/output/flink/shell/use-database.golden +++ b/test/fixtures/output/flink/shell/use-database.golden @@ -1,6 +1,6 @@ Welcome! To exit, press Ctrl-Q or type "exit". -[Ctrl-Q] Quit [Ctrl-S] Toggle Smart Completion +[Ctrl-Q] Quit [Ctrl-S] Toggle Completions [Ctrl-G] Toggle Diagnostics > use db1; Statement successfully submitted. Statement phase is COMPLETED. diff --git a/test/flink_test.go b/test/flink_test.go index 64bfbcedfd..888b3cab4b 100644 --- a/test/flink_test.go +++ b/test/flink_test.go @@ -380,7 +380,7 @@ func (s *CLITestSuite) runFlinkShellTest(flinkShellTest flinkShellTest) { require.NoError(t, err) output := &strings.Builder{} - output.WriteString(waitForLine(stdoutScanner, "[Ctrl-Q] Quit [Ctrl-S] Toggle Smart Completion")) + output.WriteString(waitForLine(stdoutScanner, "[Ctrl-Q] Quit [Ctrl-S] Toggle Completions")) // Execute commands require.NoError(t, err) diff --git a/test/test-server/ccloud_handlers.go b/test/test-server/ccloud_handlers.go index 1ce1fc6673..0506deb0a1 100644 --- a/test/test-server/ccloud_handlers.go +++ b/test/test-server/ccloud_handlers.go @@ -411,16 +411,17 @@ func handleLaunchDarkly(t *testing.T) http.HandlerFunc { require.NoError(t, json.Unmarshal(ldUserData, &ldUser)) flags := map[string]any{ - "testBool": true, - "testString": "string", - "testInt": 1, - "testAnotherInt": 99, - "testJson": map[string]any{"key": "val"}, - "cli.deprecation_notices": []map[string]any{}, - "cli.client_quotas.enable": true, - "cli.stream_designer.source_code.enable": true, - "flink.rbac.namespace.cli.enable": true, - "auth.rbac.identity_admin.enable": true, + "testBool": true, + "testString": "string", + "testInt": 1, + "testAnotherInt": 99, + "testJson": map[string]any{"key": "val"}, + "cli.deprecation_notices": []map[string]any{}, + "cli.client_quotas.enable": true, + "cli.stream_designer.source_code.enable": true, + "flink.rbac.namespace.cli.enable": true, + "auth.rbac.identity_admin.enable": true, + "flink.language_service.enable_diagnostics": true, "cloud_growth.marketplace_linking_advertisement_experiment.enable": true, }