Closed Yoskaldyr closed 7 months ago
I asked similar question on the #plugin-live-plugin
slack channel, but looks like you don't read it often
To be clear, this is more of a question about IntelliJ API rather than live plugin itself 😅
TLDR you probably need something like this:
val ep = ApplicationManager.getApplication()!!.extensionArea
.getExtensionPoint<LanguageExtensionPoint<InspectionSuppressor>>("com.intellij.lang.inspectionSuppressor")
val xmlSuppressor = ep.extensions.find { it.implementationClass.contains("XmlInspectionSuppressor") }
if (xmlSuppressor != null) {
ep.unregisterExtension(xmlSuppressor)
}
Although unregisterExtension
is deprecated, so maybe the right thing is to ask on YouTrack for better reloadable IntelliJ API 😅
The API you tried using didn't work because I think LanguageInspectionSuppressors.INSTANCE.allForLanguage(...)
reloads all extensions from xml, see https://github.com/JetBrains/intellij-community/blob/72efd72cf0f45a39325e4e9900b42a1476576f2a/platform/core-api/src/com/intellij/openapi/util/KeyedExtensionCollector.java#L135 (Btw, I really just opened IntelliJ source code and looked up what it does. It did help that I came across this issue before though.)
There are examples of registering an Intention, Inspection or Action because for them IntelliJ API is a bit cumbersome to use and there is a bit of wrapper code in LivePlugin to make it easier. Overall, the pattern for registering is to use Disposable
. When it's disposed, the intention or action is unregistered. This is more tricky with XmlInspectionSuppressor
because how do you find which Disposable
was used with it 🤷 And I suspect it's registered by built-in xml plugin so the disposable is probably for all extensions of the xml plugin.
I almost forgot about the slack channel 🙈 It not great that there is no history and not sure I like how it was renamed from #live-plugin.
Understand. For me discussing bugs and features here is also much better than in slack (all time history is available)
I found some API, but this code doesn't work