File tree Expand file tree Collapse file tree 6 files changed +40
-3
lines changed
kotlin/org/utbot/cpp/clion/plugin Expand file tree Collapse file tree 6 files changed +40
-3
lines changed Original file line number Diff line number Diff line change
1
+ package org.utbot.cpp.clion.plugin.actions
2
+
3
+ import com.intellij.openapi.actionSystem.AnAction
4
+ import com.intellij.openapi.actionSystem.AnActionEvent
5
+ import com.intellij.openapi.components.service
6
+ import org.utbot.cpp.clion.plugin.UTBot
7
+ import org.utbot.cpp.clion.plugin.client.ClientManager
8
+
9
+ class ReconnectAction : AnAction (UTBot .message("actions.reconnect")) {
10
+ override fun actionPerformed (e : AnActionEvent ) {
11
+ e.project!! .service<ClientManager >().restartClient()
12
+ }
13
+
14
+ override fun update (e : AnActionEvent ) {
15
+ e.presentation.isEnabledAndVisible = e.project != null
16
+ }
17
+ }
Original file line number Diff line number Diff line change @@ -17,13 +17,15 @@ import kotlinx.coroutines.launch
17
17
import kotlinx.coroutines.runBlocking
18
18
import kotlinx.coroutines.withTimeout
19
19
import org.jetbrains.annotations.TestOnly
20
+ import org.utbot.cpp.clion.plugin.UTBot
20
21
import org.utbot.cpp.clion.plugin.client.channels.LogChannel
21
22
import org.utbot.cpp.clion.plugin.client.requests.CheckProjectConfigurationRequest
22
23
import org.utbot.cpp.clion.plugin.grpc.getProjectConfigGrpcRequest
23
24
import org.utbot.cpp.clion.plugin.listeners.ConnectionStatus
24
25
import org.utbot.cpp.clion.plugin.listeners.UTBotEventsListener
25
26
import org.utbot.cpp.clion.plugin.settings.projectIndependentSettings
26
27
import org.utbot.cpp.clion.plugin.utils.logger
28
+ import org.utbot.cpp.clion.plugin.utils.notifyWarning
27
29
import testsgen.Testgen
28
30
29
31
/* *
@@ -72,6 +74,7 @@ class Client(
72
74
if (isDisposed) {
73
75
// if client is disposed, then connection settings were changed, and requests issued to this client
74
76
// are no longer relevant, so we don't execute them
77
+ notifyWarning(UTBot .message(" warning.reconnecting" ))
75
78
return
76
79
}
77
80
executeRequestImpl(request)
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import org.utbot.cpp.clion.plugin.listeners.ConnectionSettingsListener
12
12
import org.utbot.cpp.clion.plugin.utils.logger
13
13
14
14
@Service
15
- class ClientManager (val project : Project ): Disposable {
15
+ class ClientManager (val project : Project ) : Disposable {
16
16
private val clientId = generateClientID()
17
17
private val loggingChannels = listOf<LogChannel >(GTestLogChannelImpl (project), ServerLogChannelImpl (project))
18
18
var client: Client = Client (project, clientId, loggingChannels)
@@ -28,14 +28,18 @@ class ClientManager(val project: Project): Disposable {
28
28
override fun connectionSettingsChanged (newPort : Int , newServerName : String ) {
29
29
if (newPort != client.port || newServerName != client.serverName) {
30
30
project.logger.trace { " Connection settings changed. Setting up new client." }
31
- client.dispose()
32
- client = Client (project, clientId, loggingChannels)
31
+ restartClient()
33
32
}
34
33
}
35
34
})
36
35
}
37
36
}
38
37
38
+ fun restartClient () {
39
+ client.dispose()
40
+ client = Client (project, clientId, loggingChannels)
41
+ }
42
+
39
43
override fun dispose () = client.dispose()
40
44
41
45
private fun generateClientID (): String {
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import com.intellij.openapi.wm.StatusBarWidgetFactory
13
13
import com.intellij.ui.awt.RelativePoint
14
14
import com.intellij.util.Consumer
15
15
import org.utbot.cpp.clion.plugin.actions.AskServerToGenerateJsonForProjectConfiguration
16
+ import org.utbot.cpp.clion.plugin.actions.ReconnectAction
16
17
import org.utbot.cpp.clion.plugin.actions.configure.ConfigureProjectAction
17
18
import org.utbot.cpp.clion.plugin.actions.configure.ReconfigureProjectAction
18
19
import org.utbot.cpp.clion.plugin.actions.ShowWizardAction
@@ -105,6 +106,8 @@ object StatusBarActionsPopup {
105
106
actionGroup.addSeparator()
106
107
actionGroup.add(ConfigureProjectAction ())
107
108
actionGroup.addSeparator()
109
+ actionGroup.add(ReconnectAction ())
110
+ actionGroup.addSeparator()
108
111
actionGroup.addAction(ReconfigureProjectAction ())
109
112
110
113
return actionGroup
Original file line number Diff line number Diff line change 188
188
description =" Generates tests for file without context of a project" >
189
189
<synonym text =" US" />
190
190
</action >
191
+
191
192
<action id =" org.utbot.cpp.clion.plugin.actions.generate.RunAllTestsWithCoverageAction"
192
193
class =" org.utbot.cpp.clion.plugin.actions.generate.RunAllTestsWithCoverageAction"
193
194
text =" UTBot: Run All Tests and Show Coverage" />
195
+
196
+ <action id =" org.utbot.cpp.clion.plugin.actions.ReconnectAction"
197
+ class =" org.utbot.cpp.clion.plugin.actions.ReconnectAction" text =" Reconnect to Server"
198
+ description =" Recreates connection to server, useful when you launch the server and plugin don' t connect immedeately" >
199
+ <override-text place =" GoToAction" text =" UTBot: Reconnect to Server" />
200
+ </action >
201
+
194
202
</actions >
195
203
</idea-plugin >
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ settings.project.remotePath=Path to project on remote machine
14
14
settings.project.serverName =Server host name
15
15
settings.project.port =Server port
16
16
settings.project.cmakeOptions =Cmake options
17
+ actions.reconnect =Reconnect to Server
17
18
requests.assertion.description.progress =Generating for assertion...
18
19
requests.file.description.progress =Generating for file...
19
20
requests.function.description.progress =Generating for function...
@@ -49,3 +50,4 @@ advanced.timeoutPerFunction.description=Maximum time (in seconds) alloted for ge
49
50
advanced.timeoutPerTest.title =Timeout per test:
50
51
advanced.timeoutPerTest.description =Maximum time (in seconds) alloted for a single test run. Set to non-positive number to disable it. <a href =https://github.com/UnitTestBot/UTBotCpp/wiki/vscode-extension-settings# timeout-per-test>Learn more</a>
51
52
targets.notargets.description =No targets can be found by UTBot in current project
53
+ warning.reconnecting =Reconnecting to server! Request won' t be executed! Please try again, later.
You can’t perform that action at this time.
0 commit comments