mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-01 19:02:13 +07:00
KTIJ-37427 [CRI] Add diagnostic about dirty modules
GitOrigin-RevId: c6ac89872dff5f05e04325ed46cd8bc4285a3c27
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ca638376fc
commit
dc619c4cf7
+5
@@ -43,6 +43,11 @@
|
||||
internal="true">
|
||||
<add-to-group group-id="Internal" anchor="last"/>
|
||||
</action>
|
||||
<action id="KotlinCriDiagnostics"
|
||||
class="org.jetbrains.kotlin.idea.search.refIndex.CriDiagnosticAction"
|
||||
internal="true">
|
||||
<add-to-group group-id="HelpDiagnosticTools" anchor="last"/>
|
||||
</action>
|
||||
</actions>
|
||||
|
||||
<resource-bundle>messages.KotlinReferenceIndexBundle</resource-bundle>
|
||||
|
||||
+3
@@ -6,3 +6,6 @@ dialog.title.invalid.data=Invalid Data
|
||||
dialog.message.psielement.not.found=PsiElement not found
|
||||
dialog.message.project.not.found=Project not found
|
||||
dialog.title.compiler.index.status=Compiler Index Status
|
||||
dialog.title.kotlin.cri.diagnostics=Kotlin CRI Diagnostics
|
||||
action.KotlinCriDiagnostics.text=Kotlin CRI Diagnostics
|
||||
action.KotlinCriDiagnostics.description=Show Kotlin Compiler Reference Index diagnostics
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.search.refIndex
|
||||
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
import com.intellij.openapi.ui.DialogWrapper
|
||||
import com.intellij.ui.components.JBScrollPane
|
||||
import com.intellij.ui.components.JBTextArea
|
||||
import java.awt.Dimension
|
||||
import java.awt.Font
|
||||
import javax.swing.JComponent
|
||||
|
||||
|
||||
class CriDiagnosticAction : AnAction(), DumbAware {
|
||||
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return
|
||||
|
||||
val diagnosticInfo = buildString {
|
||||
appendLine("=== Kotlin CRI Diagnostics ===")
|
||||
appendLine()
|
||||
|
||||
val dirtyModules = KotlinCompilerReferenceIndexService.getInstanceIfEnabled(project)?.dirtyModules() ?: emptySet()
|
||||
|
||||
appendLine("Dirty Modules (${dirtyModules.size}):")
|
||||
if (dirtyModules.isEmpty()) {
|
||||
appendLine(" (none - all modules are up-to-date)")
|
||||
} else {
|
||||
dirtyModules.sortedBy { it.name }.forEach { moduleName ->
|
||||
appendLine(" - $moduleName")
|
||||
}
|
||||
}
|
||||
appendLine()
|
||||
}
|
||||
|
||||
CriDiagnosticDialog(diagnosticInfo).show()
|
||||
}
|
||||
|
||||
private class CriDiagnosticDialog(private val diagnosticInfo: String) : DialogWrapper(null, false) {
|
||||
init {
|
||||
title = KotlinReferenceIndexBundle.message("dialog.title.kotlin.cri.diagnostics")
|
||||
init()
|
||||
}
|
||||
|
||||
override fun createCenterPanel(): JComponent {
|
||||
val textArea = JBTextArea(diagnosticInfo).apply {
|
||||
isEditable = false
|
||||
font = Font.decode(Font.MONOSPACED)
|
||||
}
|
||||
return JBScrollPane(textArea).apply {
|
||||
preferredSize = Dimension(700, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -45,7 +45,9 @@ import com.intellij.psi.util.PsiUtilCore
|
||||
import com.intellij.util.Processor
|
||||
import com.intellij.util.containers.generateRecursiveSequence
|
||||
import com.intellij.util.indexing.StorageException
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.annotations.VisibleForTesting
|
||||
import org.jetbrains.kotlin.asJava.syntheticAccessors
|
||||
import org.jetbrains.kotlin.asJava.unwrapped
|
||||
import org.jetbrains.kotlin.config.SettingConstants
|
||||
@@ -205,6 +207,12 @@ class KotlinCompilerReferenceIndexService(private val project: Project) : Dispos
|
||||
|
||||
private fun allModules(): Array<Module>? = runReadAction { projectIfNotDisposed?.let { ModuleManager.getInstance(it).modules } }
|
||||
|
||||
@ApiStatus.Internal
|
||||
@VisibleForTesting
|
||||
fun dirtyModules(): Set<Module> {
|
||||
return dirtyScopeHolder.allDirtyModules
|
||||
}
|
||||
|
||||
private fun markAsUpToDate() {
|
||||
val modules = allModules() ?: return
|
||||
withDirtyScopeUnderWriteLock {
|
||||
|
||||
Reference in New Issue
Block a user