why do you need to register an inspection at runtime? I mean that runtime means that the inspection can't have settings and can't be enabled/disabled, looks not really native to me. There are a number of inspections which contain multiple inspections, like Structural Search which allows to configure patterns and these patterns are registered "at runtime"
The main motivation is this plugin https://github.com/dkandalov/live-plugin which is about writing plugin code at runtime. So inspection configuration and enabling/disabling is supposed to be done by changing code (I agree it's not native).
That's very unstable indeed but the profiles are not designed to be reloaded once instantiated so unfortunately I don't have a better solution,
BTW Did you try Tools| IDE Scripting Console (com.intellij.execution.console.RunIdeConsoleAction)? Looks to be the similar idea. As far as I know it's impossible to add a new inspection but it's possible to fix some bugs there without reloading the IDE.
Ok, thank you. I was hoping it might be not that difficult to make inspections reloadable at runtime, e.g. com.intellij.codeInspection.ex.InspectionProfileImpl looks like it almost supports it.
Yes, I tried IDE Scripting Console a while ago. It is a very similar idea indeed but there are few problems with it:
uncertain future, i.e. it's been an experimental feature for couple years but doesn't seem to evolve
IDE scripts don't run on IDE startup, can't have additional jars loaded into classloader, not sure if they can have multiple files, etc
most of IntelliJ APIs are not designed to be quick and easy to use at runtime and there isn't one entry point, so it helps to have a bit of "wrapping". For LivePlugin I wrote https://github.com/dkandalov/live-plugin/blob/master/src_groovy/liveplugin/PluginUtil.groovy (I don't mean it's great but it was somewhat ok for my needs). IMHO without some kind of wrappers for most common plugin features IDE Scripting is too much pain to use.
I wrote LivePlugin couple years before it and I might be a bit biased :)
Hi Dmitry,
why do you need to register an inspection at runtime? I mean that runtime means that the inspection can't have settings and can't be enabled/disabled, looks not really native to me. There are a number of inspections which contain multiple inspections, like Structural Search which allows to configure patterns and these patterns are registered "at runtime"
Anna
Hello Anna,
The main motivation is this plugin https://github.com/dkandalov/live-plugin which is about writing plugin code at runtime. So inspection configuration and enabling/disabling is supposed to be done by changing code (I agree it's not native).
This is the current hack to make inspections loadable at runtime but it's not nice and fragile https://github.com/dkandalov/live-plugin/blob/master/src_groovy/liveplugin/implementation/Inspections.groovy#L128
That's very unstable indeed but the profiles are not designed to be reloaded once instantiated so unfortunately I don't have a better solution,
BTW Did you try Tools| IDE Scripting Console (com.intellij.execution.console.RunIdeConsoleAction)? Looks to be the similar idea. As far as I know it's impossible to add a new inspection but it's possible to fix some bugs there without reloading the IDE.
Anna
Ok, thank you. I was hoping it might be not that difficult to make inspections reloadable at runtime, e.g. com.intellij.codeInspection.ex.InspectionProfileImpl looks like it almost supports it.
Yes, I tried IDE Scripting Console a while ago. It is a very similar idea indeed but there are few problems with it: