Skip to content

Commit

Permalink
fix(intellij): stabilize test discovery at project startup
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Feb 10, 2025
1 parent 50426a2 commit 7aeb379
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlinx.coroutines.flow.onEach
class RobotCodePostStartupActivity : ProjectActivity {
override suspend fun execute(project: Project) {
project.langServerManager.start()
project.testManger.refresh()
project.testManger.refreshDebounced()

VirtualFileManager.getInstance().addAsyncFileListener(RobotCodeVirtualFileListener(project), project.testManger)

Expand All @@ -24,7 +24,7 @@ class RobotCodePostStartupActivity : ProjectActivity {
if (moduleChanges.filterIsInstance<EntityChange.Replaced<ModuleEntity>>().isNotEmpty()) {
project.checkPythonAndRobotVersion(true)
project.langServerManager.restart()
project.testManger.refresh()
project.testManger.refreshDebounced()
}
}.collect()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ class RobotCodeProjectSettingsConfigurable(private val project: Project) : Bound
}.rowComment("Specifies robot execution mode. Corresponds to the `--rpa` or `--norpa` option of __robot__.")
}
group("Editing") { // TODO: not supported in IntelliJ
// group("Editor") {
// row {
// checkBox("4 Spaces Tab").bindSelected(settings::editor4SpacesTab)
// }.rowComment("If actived insert 4 spaces if TAB is pressed.")
// }
group("Completion") {
row {
checkBox("Filter Default Language").bindSelected(settings::completionFilterDefaultLanguage)
Expand Down Expand Up @@ -101,14 +96,12 @@ class RobotCodeProjectConfiguration :
}

class ProjectState : BaseState() {
// TODO var editor4SpacesTab by property(defaultValue = true)
var completionFilterDefaultLanguage by property(defaultValue = false)
var completionHeaderStyle by string()
var inlayHintsParameterNames by property(defaultValue = false)
var inlayHintsNamespaces by property(defaultValue = false)
}

// TODO var editor4SpacesTab by delegate(ProjectState::editor4SpacesTab)
var completionFilterDefaultLanguage by delegate(ProjectState::completionFilterDefaultLanguage)
var completionHeaderStyle by stringDelegate(ProjectState::completionHeaderStyle)
var inlayHintsParameterNames by delegate(ProjectState::inlayHintsParameterNames)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import dev.robotcode.robotcode4ij.psi.RobotSuiteFile
import dev.robotcode.robotcode4ij.utils.escapeRobotGlob
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -114,7 +115,8 @@ import java.util.*
}
}

private val refreshScope = CoroutineScope(Dispatchers.Default)
@OptIn(ExperimentalCoroutinesApi::class)
private val refreshScope = CoroutineScope(Dispatchers.IO.limitedParallelism(1))

fun refreshDebounced(file: VirtualFile) {
if (!project.isOpen || project.isDisposed) {
Expand All @@ -129,7 +131,7 @@ import java.util.*
}
if (refreshJob != null) {
thisLogger().info("Cancelling previous refresh job")
runBlocking { refreshJob?.join() }
//runBlocking { refreshJob?.join() }
}
refreshJobs[file] = refreshScope.launch {
delay(DEBOUNCE_DELAY)
Expand Down

0 comments on commit 7aeb379

Please sign in to comment.