Skip to content

Commit 1a0758c

Browse files
committed
Fixed auto-disable and reporter state
TODO: - Unsafe fallback option - Better file watcher (watch the whole local repo) - Check how exceptions are handled while in checkers - Store matched stacktrace with the exception for highlighting
1 parent 05d8810 commit 1a0758c

File tree

4 files changed

+19
-22
lines changed

4 files changed

+19
-22
lines changed

src/main/kotlin/com/github/mr3zee/kotlinPlugins/KotlinPluginsExceptionReporter.kt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.intellij.util.messages.SimpleMessageBusConnection
1010
import kotlinx.coroutines.CoroutineName
1111
import kotlinx.coroutines.CoroutineScope
1212
import kotlinx.coroutines.CoroutineStart
13-
import kotlinx.coroutines.Dispatchers
1413
import kotlinx.coroutines.Job
1514
import kotlinx.coroutines.launch
1615
import kotlinx.coroutines.supervisorScope
@@ -164,6 +163,7 @@ class KotlinPluginsExceptionReporterImpl(
164163
override fun dispose() {
165164
state.getAndSet(null)?.close()
166165
stackTraceMap.clear()
166+
caughtExceptions.clear()
167167
metadata.clear()
168168
}
169169

@@ -340,14 +340,14 @@ class KotlinPluginsExceptionReporterImpl(
340340
}
341341

342342
if (autoDisable) {
343-
settings.disablePlugin(plugin.name)
344-
345-
KotlinPluginsNotificationBallon.notify(
346-
project = project,
347-
disabledPlugin = plugin.name,
348-
mavenId = ids.singleOrNull()?.mavenId,
349-
version = ids.singleOrNull()?.version,
350-
)
343+
if (settings.disablePlugin(plugin.name)) {
344+
KotlinPluginsNotificationBallon.notify(
345+
project = project,
346+
disabledPlugin = plugin.name,
347+
mavenId = ids.singleOrNull()?.mavenId,
348+
version = ids.singleOrNull()?.version,
349+
)
350+
}
351351
} else {
352352
// trigger editor notification across all Kotlin files
353353
project.service<KotlinPluginsNotifications>().activate(ids)
@@ -408,11 +408,6 @@ class KotlinPluginsExceptionReporterImpl(
408408
processDiscovery(discovery, redrawUpdateUpdate)
409409
}
410410
}
411-
412-
override fun reset() {
413-
state.getAndSet(null)?.close()
414-
stackTraceMap.clear()
415-
}
416411
}
417412

418413
fun clearAll() {

src/main/kotlin/com/github/mr3zee/kotlinPlugins/KotlinPluginsSettings.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,24 @@ class KotlinPluginsSettings(
7878
}
7979
}
8080

81-
fun disablePlugin(pluginName: String) {
82-
disablePlugins(setOf(pluginName))
81+
fun disablePlugin(pluginName: String): Boolean {
82+
return disablePlugins(setOf(pluginName))
8383
}
8484

85-
fun disablePlugins(pluginNames: Iterable<String>) {
85+
fun disablePlugins(pluginNames: Iterable<String>): Boolean {
8686
val set = pluginNames.toSet()
87+
var disabled = false
8788
updateWithDetectChanges {
8889
it.copy(
8990
plugins = it.plugins.map { p ->
90-
if (p.name in set) p.copy(enabled = false) else p
91+
if (p.name in set) {
92+
disabled = p.enabled
93+
p.copy(enabled = false)
94+
} else p
9195
}
9296
)
9397
}
98+
return disabled
9499
}
95100

96101
fun isEnabled(pluginName: String): Boolean {

src/main/kotlin/com/github/mr3zee/kotlinPlugins/KotlinPluginsStorage.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class KotlinVersionMismatch(
103103

104104
interface KotlinPluginDiscoveryUpdater {
105105
suspend fun discoveredSync(discovery: Discovery, redrawUpdateUpdate: Boolean = true)
106-
fun reset()
107106

108107
class Discovery(
109108
val pluginName: String,
@@ -232,8 +231,6 @@ class KotlinPluginsStorage(
232231
originalWatchKeys.clear()
233232
originalWatchKeysReverse.clear()
234233

235-
discoveryPublisher.reset()
236-
237234
and()
238235
} finally {
239236
actualizerLock.unlock()

src/main/kotlin/com/github/mr3zee/kotlinPlugins/KotlinPluginsToolWindowFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ private fun parentStatus(children: List<NodeData>): ArtifactStatus {
15991599
return ArtifactStatus.ExceptionInRuntime
16001600
}
16011601

1602-
if (children.any { it.status == ArtifactStatus.PartialSuccess}) {
1602+
if (children.any { it.status == ArtifactStatus.PartialSuccess }) {
16031603
return ArtifactStatus.PartialSuccess
16041604
}
16051605

0 commit comments

Comments
 (0)