Skip to content

Commit bb17d56

Browse files
committed
Add comments on initialization
1 parent 13cab18 commit bb17d56

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

clion-plugin/src/main/kotlin/org/utbot/cpp/clion/plugin/UTBotStartupActivity.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package org.utbot.cpp.clion.plugin
22

33
import com.intellij.ide.util.RunOnceUtil
4+
import com.intellij.openapi.components.service
45
import com.intellij.openapi.project.Project
56
import com.intellij.openapi.startup.StartupActivity
67
import org.utbot.cpp.clion.plugin.client.Client
8+
import org.utbot.cpp.clion.plugin.client.ClientManager
79
import org.utbot.cpp.clion.plugin.settings.pluginSettings
810
import org.utbot.cpp.clion.plugin.settings.settings
911
import org.utbot.cpp.clion.plugin.ui.wizard.UTBotWizard
@@ -12,8 +14,9 @@ import org.utbot.cpp.clion.plugin.utils.invokeOnEdt
1214

1315
class UTBotStartupActivity : StartupActivity {
1416
override fun runActivity(project: Project) {
15-
16-
project.getCurrentClient()
17+
// we initialize Client here, so that initialization will not happen when user issues first
18+
// generation request which would cause a UI freeze
19+
initializeClient(project)
1720
guessPathsOnFirstProjectOpen(project)
1821
showWizardOnFirstProjectOpen(project)
1922
}
@@ -27,6 +30,13 @@ class UTBotStartupActivity : StartupActivity {
2730
}
2831
}
2932

33+
private fun initializeClient(project: Project) {
34+
// Here we address the service ClientManager for the first time so that it
35+
// will be initialized by the ide and Client will be created.
36+
// Client in turn will create a grpc channel and start heartbeating the server
37+
project.service<ClientManager>()
38+
}
39+
3040
private fun guessPathsOnFirstProjectOpen(project: Project) {
3141
RunOnceUtil.runOnceForProject(project, "Guess UTBot paths in settings") {
3242
project.settings.predictPaths()

clion-plugin/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<codeInsight.lineMarkerProvider language="ObjectiveC"
1616
implementationClass="org.utbot.cpp.clion.plugin.ui.testsResults.UTBotTestRunLineMarkerProvider"/>
1717
<projectService serviceImplementation="org.utbot.cpp.clion.plugin.settings.UTBotAllProjectSettings"/>
18+
<projectService serviceImplementation="org.utbot.cpp.clion.plugin.client.ClientManager"/>
1819
<applicationService serviceImplementation="org.utbot.cpp.clion.plugin.settings.UTBotPluginSpecificSettings"/>
1920
<coverageEngine implementation="org.utbot.cpp.clion.plugin.coverage.UTBotCoverageEngine"/>
2021
<postStartupActivity implementation="org.utbot.cpp.clion.plugin.UTBotStartupActivity"/>

0 commit comments

Comments
 (0)