Cannot register CompoundRendererProvider extension that modify same classes as the Kotlin plugin

Answered

I'm trying to create a plugin that modifies how certain variables are shown in the Debugger, but it seems to conflict with providers defined by the Kotlin plugin, so the end result is that the Kotlin plugin wins and my own extension is ignored.

In my own plugin I have created a custom extension:

<debugger.compoundRendererProvider implementation="io.realm.debugger.ManagedRealmValueRenderer"/>

 

class ManagedRealmValueRenderer: UnboxableTypeRenderer(CommonClassNames.JAVA_LANG_INTEGER) {
override fun getValueLabelRenderer(): ValueLabelRenderer {
return object : LabelRenderer() {
override fun calcLabel(
descriptor: ValueDescriptor,
evaluationContext: EvaluationContext,
labelListener: DescriptorLabelListener
): String {
return "HeyFromPlugin"
}

override fun isOnDemand(
evaluationContext: EvaluationContext,
valueDescriptor: ValueDescriptor
): Boolean {
return false
}
}
}

override fun getIsApplicableChecker(): Function<Type, CompletableFuture<Boolean>> {
return Function { type: Type ->
val isRef = type is ReferenceType
val isOurType = StringUtil.equals(type.name(),CommonClassNames.JAVA_LANG_INTEGER)
CompletableFuture.completedFuture(isRef && isOurType)
}
}
}

 

However, this doesn't work even though the applicable checker returns true. Browsing through the source, I found this: https://github.com/JetBrains/intellij-community/blob/master/java/debugger/impl/src/com/intellij/debugger/settings/NodeRendererSettings.java#L252

Stepping through this part of the code, seems to confirm my thesis, that the Kotlin Plugin also registers a renderer for this variable type and (I assume) due to the order the plugins are loaded, the Kotlin one ends up winning.

This is rather problematic as the Kotlin plugin is more or less considered default now, so it feels strange that it can end up winning over another plugin.

Is there a way to make my CompoundRendererProvider win? I would assume a work-around would be to somehow create a "manual" provider like the ones you can define through the UI, but I didn't see any API's for doing this? 

Alternatively, is there a way a user can define the order the plugins are loaded so my plugin extensions will "win" over the Kotlin plugin provided ones.

 

 

2 comments
Comment actions Permalink

Hi, as a workaround, you can try to use the order attribute - https://plugins.jetbrains.com/docs/intellij/plugin-extensions.html#extension-default-properties

I believe that order=first when registering your CompoundRendererProvider should make it always "win". Unfortunately kotlin render does not specify the id attribute, so you can not set order=before<kotlin renderer>

0
Comment actions Permalink

Yes, that did the trick. Thanks.

0

Please sign in to leave a comment.