Skip to content

Commit a18b455

Browse files
committed
Selected node overview
TODO: - Unsafe fallback option - The Whole bundle must be from the same repository - Better file watcher (create events, watch the whole local repo) - Check how exceptions are handled while in checkers - Better redraw algorithm for exceptions
1 parent 9216d10 commit a18b455

12 files changed

+1360
-145
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.mr3zee.kotlinPlugins
22

33
import com.intellij.icons.AllIcons
4-
import com.intellij.openapi.actionSystem.ActionPlaces
54
import com.intellij.openapi.actionSystem.ActionUpdateThread
65
import com.intellij.openapi.actionSystem.AnAction
76
import com.intellij.openapi.actionSystem.AnActionEvent
@@ -13,7 +12,7 @@ import javax.swing.JComponent
1312
open class KotlinPluginsClearCachesAction : AnAction(AllIcons.Actions.ClearCash) {
1413
override fun actionPerformed(e: AnActionEvent) {
1514
val project = e.project ?: return
16-
val treeState = TreeState.getInstance(project)
15+
val treeState = KotlinPluginsTreeState.getInstance(project)
1716

1817
val clear = !treeState.showClearCachesDialog || run {
1918
val (clear, dontShowAgain) = ClearCachesDialog.show()

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent
66
import com.intellij.openapi.components.service
77
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory
88
import com.intellij.openapi.options.Configurable
9+
import com.intellij.openapi.options.ShowSettingsUtil
910
import com.intellij.openapi.project.Project
1011
import com.intellij.openapi.ui.ComboBox
1112
import com.intellij.openapi.ui.DialogWrapper
@@ -51,7 +52,7 @@ private class LocalState {
5152

5253
fun isModified(
5354
analyzer: KotlinPluginsExceptionAnalyzerState,
54-
tree: TreeState,
55+
tree: KotlinPluginsTreeState,
5556
settings: KotlinPluginsSettings.State,
5657
): Boolean {
5758
return repositories != settings.repositories ||
@@ -64,7 +65,7 @@ private class LocalState {
6465

6566
fun reset(
6667
analyzer: KotlinPluginsExceptionAnalyzerState,
67-
tree: TreeState,
68+
tree: KotlinPluginsTreeState,
6869
settings: KotlinPluginsSettings.State,
6970
) {
7071
repositories.clear()
@@ -83,7 +84,7 @@ private class LocalState {
8384

8485
fun applyTo(
8586
analyzer: KotlinPluginsExceptionAnalyzerService,
86-
tree: TreeState,
87+
tree: KotlinPluginsTreeState,
8788
settings: KotlinPluginsSettings,
8889
) {
8990
val enabledPlugins = plugins.map {
@@ -101,6 +102,21 @@ private class LocalState {
101102
}
102103

103104
class KotlinPluginsConfigurable(private val project: Project) : Configurable {
105+
companion object {
106+
@Volatile
107+
private var selectArtifactsInitially: Boolean = false
108+
109+
fun showArtifacts(project: Project) {
110+
selectArtifactsInitially = true
111+
ShowSettingsUtil.getInstance().showSettingsDialog(project, KotlinPluginsConfigurable::class.java)
112+
}
113+
114+
fun showGeneral(project: Project) {
115+
selectArtifactsInitially = false
116+
ShowSettingsUtil.getInstance().showSettingsDialog(project, KotlinPluginsConfigurable::class.java)
117+
}
118+
}
119+
104120
private val local: LocalState = LocalState()
105121

106122
private lateinit var repoTable: JBTable
@@ -303,6 +319,10 @@ class KotlinPluginsConfigurable(private val project: Project) : Configurable {
303319
val tabs = JBTabbedPane()
304320
tabs.addTab("General", generalContent)
305321
tabs.addTab("Artifacts", artifactsContent)
322+
if (selectArtifactsInitially) {
323+
tabs.selectedIndex = 1
324+
selectArtifactsInitially = false
325+
}
306326
rootPanel = JPanel(BorderLayout()).apply { add(tabs, BorderLayout.NORTH) }
307327

308328
reset() // initialise from a persisted state

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@ class KotlinPluginsEditorNotificationProvider : EditorNotificationProvider {
7171
}
7272

7373
panel.createActionLabel("Open diagnostics") {
74-
// todo update state to show error panel
74+
val pluginOrNull = grouped.keys.singleOrNull()
75+
76+
val jarIdOrNull = pluginOrNull?.let { grouped[it]?.singleOrNull() }
77+
val mavenIdOrNull = jarIdOrNull?.mavenId
78+
val versionOrNull = jarIdOrNull?.version
79+
80+
KotlinPluginsTreeState.getInstance(project)
81+
.select(pluginOrNull, mavenIdOrNull, versionOrNull)
7582

7683
KotlinPluginsToolWindowFactory.show(project)
7784
}

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ class KotlinPluginsExceptionAnalyzerService(
4040
Disposable {
4141
private val logger by lazy { thisLogger() }
4242
private val handler: AtomicReference<Handler?> = AtomicReference(null)
43-
val supervisorJob = SupervisorJob(scope.coroutineContext.job)
43+
private val supervisorJob = scope.coroutineContext + SupervisorJob(scope.coroutineContext.job)
44+
private val publisherSync by lazy { project.messageBus.syncPublisher(KotlinPluginStatusUpdater.TOPIC) }
4445

4546
override fun dispose() {
46-
supervisorJob.cancel()
47+
supervisorJob.job.cancel()
4748
val handler = handler.getAndSet(null)
4849
rootLogger().removeHandler(handler)
4950
handler?.close()
@@ -59,6 +60,7 @@ class KotlinPluginsExceptionAnalyzerService(
5960
}
6061

6162
project.service<KotlinPluginsExceptionReporter>().start()
63+
publisherSync.redraw()
6264
exceptionHandler.start()
6365
logger.debug("Exception analyzer started")
6466
rootLogger().addHandler(exceptionHandler)
@@ -79,15 +81,27 @@ class KotlinPluginsExceptionAnalyzerService(
7981
val lookup = reporter.lookFor()
8082

8183
lookup.entries.find { (jarId, fqNames) ->
82-
exception.stackTrace.any { it.className in fqNames }
84+
var curr: Throwable? = exception
85+
while (curr != null) {
86+
if (curr.stackTrace.any { it.className in fqNames }) {
87+
return@find true
88+
}
89+
90+
curr = curr.cause
91+
}
92+
false
8393
} ?: continue
8494

85-
val ids = match(lookup, exception)
86-
.takeIf { it.isNotEmpty() }
87-
?: return@launch
95+
val ids = match(lookup, exception) ?: continue
8896

8997
logger.debug("Exception detected for $ids: ${exception.message}")
90-
reporter.matched(ids.toList(), exception, autoDisable = state.autoDisable)
98+
99+
reporter.matched(
100+
ids = ids.toList(),
101+
exception = exception,
102+
autoDisable = state.autoDisable,
103+
isProbablyIncompatible = exception.isProbablyIncompatible(),
104+
)
91105
}
92106
}
93107

@@ -141,15 +155,26 @@ class KotlinPluginsExceptionAnalyzerService(
141155
}
142156

143157
companion object {
144-
internal fun match(lookup: Map<JarId, Set<String>>, exception: Throwable): Set<JarId> {
158+
internal fun match(lookup: Map<JarId, Set<String>>, exception: Throwable): Set<JarId>? {
145159
return exception.stackTrace
146160
.map { trace ->
147161
lookup.entries
148162
.filter { (_, fqNames) -> trace.className in fqNames }
149163
.map { it.key }.toSet()
150164
}
151165
.filter { it.isNotEmpty() }
152-
.reduce { acc, set -> acc.intersect(set) }
166+
.takeIf { it.isNotEmpty() }
167+
?.reduce { acc, set -> acc.intersect(set) }
168+
?: match(lookup, exception.cause ?: return null)
169+
}
170+
171+
private fun Throwable.isProbablyIncompatible(): Boolean {
172+
return this is ClassNotFoundException ||
173+
this is NoClassDefFoundError ||
174+
this is IncompatibleClassChangeError ||
175+
this is LinkageError ||
176+
this is ClassCastException ||
177+
this.cause?.isProbablyIncompatible() == true
153178
}
154179
}
155180
}

0 commit comments

Comments
 (0)