Is it possible to add inspection classes dynamically?


assuming registering inspections like:

public class MynspectionToolProvider implements InspectionToolProvider {

    public Class[] getInspectionClasses() {
        Collection<Class> classes = fetchInspectionTools();
        return classes.toArray(new Class[classes.size()]);


where fetchInspectionTools generates some classes dynamically at runtime based on external data.

This works fine, but only on IDE startup. If adding new inspection classes (my external data was updated) it needs a IDE restart, so that getInspectionClasses is reexecuted, the inspections are registered and so on.

My question is, if it is possible to register a new inspection class at runtime without IDE restart?
Is there something like InspectionsManager.register(getInspectionClasses()) ?

Thank you!

No, there is no such API. Every inspection profile contains a list of instances of all inspections registered at system startup, and persists the settings for those inspections. Because of that, it wouldn't be enough to add the inspections to the inspection manager; you would also need to update all the inspection profiles in the system, and that is not currently supported.


ok, thx for very fast answer.


Please sign in to leave a comment.