@@ -3,11 +3,9 @@ package com.intellij.internal.inspector.components
33
44import com.intellij.ide.DataManager
55import com.intellij.ide.impl.DataManagerImpl
6+ import com.intellij.ide.impl.DataValidators
67import com.intellij.internal.inspector.UiInspectorUtil.getComponentName
7- import com.intellij.openapi.actionSystem.CustomizedDataContext
8- import com.intellij.openapi.actionSystem.DataKey
9- import com.intellij.openapi.actionSystem.PlatformCoreDataKeys
10- import com.intellij.openapi.actionSystem.PlatformDataKeys
8+ import com.intellij.openapi.actionSystem.*
119import com.intellij.openapi.actionSystem.impl.Utils
1210import com.intellij.openapi.project.Project
1311import com.intellij.openapi.ui.DialogWrapper
@@ -37,8 +35,9 @@ internal class DataContextDialog(
3735 @JvmField val componentList : List <Component >
3836) : DialogWrapper(project, false , IdeModalityType .MODELESS ) {
3937
40- var showLazyValues: Boolean = false
41- var showBGTData: Boolean = false
38+ private var showLazyValues: Boolean = false
39+ private var showBGTData: Boolean = false
40+ private var showFQNs: Boolean = false
4241
4342 init {
4443 val component = componentList.firstOrNull() ? : error(" No component" )
@@ -56,18 +55,22 @@ internal class DataContextDialog(
5655 val table = JBTable ()
5756 table.setDefaultRenderer(Object ::class .java, MyTableCellRenderer ())
5857
59- table.model = buildTreeModel( )
58+ rebuild(table )
6059 TableSpeedSearch .installOn(table)
6160
6261 val panel = panel {
6362 row {
6463 checkBox(" Show BGT Data" ).actionListener { _, component ->
6564 showBGTData = component.isSelected
66- table.model = buildTreeModel( )
65+ rebuild(table )
6766 }
6867 checkBox(" Show lazy keys" ).actionListener { _, component ->
6968 showLazyValues = component.isSelected
70- table.model = buildTreeModel()
69+ rebuild(table)
70+ }
71+ checkBox(" Show raw FQNs" ).actionListener { _, component ->
72+ showFQNs = component.isSelected
73+ rebuild(table)
7174 }
7275 }
7376 row {
@@ -83,6 +86,10 @@ internal class DataContextDialog(
8386 return panel.withPreferredSize(width, height)
8487 }
8588
89+ private fun rebuild (table : JBTable ) {
90+ table.model = buildTreeModel()
91+ }
92+
8693 private fun buildTreeModel (): DefaultTableModel {
8794 val model = object : DefaultTableModel () {
8895 override fun isCellEditable (row : Int , column : Int ): Boolean = false
@@ -114,7 +121,7 @@ internal class DataContextDialog(
114121 }
115122
116123 private fun DefaultTableModel.appendHeader (component : Component , index : Int ) {
117- addRow(arrayOf(Header (" $index . ${getComponentName(component)} " ), null , getClassName (component)))
124+ addRow(arrayOf(Header (" $index . ${getComponentName(component)} " ), null , getClassPresentationOrFQN (component)))
118125 }
119126
120127 private fun DefaultTableModel.appendRow (data : ContextData ) {
@@ -144,11 +151,11 @@ internal class DataContextDialog(
144151 result + = ContextData (
145152 key.name,
146153 getValuePresentation(data ? : CustomizedDataContext .EXPLICIT_NULL ),
147- getClassName (data ? : CustomizedDataContext .EXPLICIT_NULL ),
154+ getClassPresentationOrFQN (data ? : CustomizedDataContext .EXPLICIT_NULL ),
148155 childData != null && ! equalData(data, childData, 0 , null ))
149156 if (showLazyValues && data is DataManagerImpl .KeyedDataProvider ) {
150157 result + = data.map.map { (k, v) ->
151- ContextData (" ${key.name} - $k " , getValuePresentation(v), getClassName (v), false )
158+ ContextData (" ${key.name} - $k " , getValuePresentation(v), getClassPresentationOrFQN (v), false )
152159 }
153160 }
154161 if (data != null && key != PlatformCoreDataKeys .BGT_DATA_PROVIDER ) {
@@ -158,6 +165,11 @@ internal class DataContextDialog(
158165 result.sortWith(Comparator .comparing { StringUtil .toUpperCase(it.key) })
159166 return result
160167 }
168+
169+ private fun getClassPresentationOrFQN (value : Any ): String {
170+ return if (showFQNs) (value.javaClass.name ? : " null" )
171+ else getClassPresentation(value)
172+ }
161173}
162174
163175private fun equalData (o1 : Any? , o2 : Any? , level : Int , visited : MutableSet <Any >? ): Boolean {
@@ -215,17 +227,30 @@ private fun getKeyPresentation(key: String, overridden: Boolean) = when {
215227private fun getValuePresentation (value : Any ) = when (value) {
216228 is Array <* > -> value.contentToString()
217229 is DataManagerImpl .KeyedDataProvider ->
218- " ${value.map.size} lazy keys " +
230+ " ${value.javaClass.simpleName} ( ${value. map.size} providers) " +
219231 (value.generic?.let { " + generic" } ? : " " )
232+ is CompositeDataProvider -> {
233+ " ${value.javaClass.simpleName} (${value.dataProviders.size} providers)"
234+ }
220235 else -> value.toString()
221236}
222237
223- private fun getClassName (value : Any ): String {
238+ private fun getClassPresentation (value : Any ): String {
239+ val source = (value as ? DataValidators .SourceWrapper )?.unwrapSource()
240+ if (source != null && source != = value) {
241+ return getClassPresentation(source)
242+ }
243+ if (value is CompositeDataProvider ) {
244+ return value.dataProviders.joinToString { getClassPresentation(it) }
245+ }
224246 val clazz: Class <* > = value.javaClass
225- return when {
226- clazz.isAnonymousClass -> " ${clazz.superclass.simpleName} $..."
247+ val str = when {
248+ clazz.isAnonymousClass -> " ${clazz.name.substringAfterLast(" ." )} : ${clazz.superclass.simpleName} "
249+ clazz.isHidden -> clazz.simpleName.substringBefore(" /" ).let { if (it.endsWith(" Lambda" )) it else " $it /-" }
227250 else -> clazz.simpleName
228251 }
252+ return if (value is Array <* >) " ${str.substringBeforeLast(" [" )} [${value.size} ]"
253+ else str
229254}
230255
231256private class MyTableCellRenderer : ColoredTableCellRenderer () {
0 commit comments