How to determine when code analysis is complete for a specific project?



I am invoking CodeInspectionAction#analyze after promoting it's visibility with a wrapper class.  This is so that I don't need to access the internal API of GlobalInspectionContextImpl .  I have also implemented the GlobalInspectionContextExtension in an attempt to properly react to the code analysis lifecycle for my project.  

While GlobalInspectionContextExtension#cleanup exists, it doesn't provide the GlobalInspectionContext the other methods do, so I don't see a way to identify the project for which the cleanup method is being invoked.  Extensions are not supposed to have state, so holding the project within the extension is out.  Also, only the cleanup method is called after analysis completes despite the misleading method name performPostRunActivities, which is invoked before any inspections have reported results.

I also have an InspectListener, but the only ActivityKind reported to InspectListener#activityFinished is GLOBAL_POST_RUN_ACTIVITIES and it comes long before the analysis is complete.

The GlobalInspectionContextBase#notifyInspectionsFinished(AnalysisScope) method is the obvious place that listeners would be called, but from the implementation in GlobalInspectionContextImpl, I could not identify any listeners being called, nor could I find a way to register a listener to be called.  If it just called notify on the AnalysisScope parameter, I could have leveraged that.

This all brings me back to the GlobalInspectionContextExtension#cleanup  method appearing to be where I should be able to call project level services, but without the context, there is no available project.

How do I determine when code analysis is complete for a specific project?  Or how to do I register a project level service to be invoked with code analysis is complete for a specific project?


I see a “planned” decoration has been added to my question.  What does that mean?  Is there no current answer to this and the code is “planned' to be updated?  Or does it mean someone has ”planned" to answer this question? Or something else altogether?


It means I'm gathering information to answer your question.


Thanks for the clarification Yann Cebron!  I am working to solve this in my own way in the meantime


I had previously believed that the GlobalInspectionContextExtension#cleanup method was called after the inspections were completed, but more experimentation show it is called before the inspections and when the project is closed, so it isn't a viable method to use either.


More experimenting shows that multiple code analyses can run simultaneously and an instance of GlobalInspectionContextExtension is used for each, which means that the GlobalInspectionContext provided to the GlobalInspectionContextExtension methods would need to have a way to differentiate which task it represents, though there doesn't seem to be a way to get that information either.

I'm just adding thoughts and discoveries.  I don't know if they will help solve this issue.  I am realizing that tracking a particular code analysis requires quite a bit of hidden information.

I have tried implementing services such as the ProgrressManager to extract information about progress indicators and to know when my desired task has been completed, but the classes that need to be extended for the various services to get the expected execution are final and/or are annotated as internal.


I have a workaround that relies on listeners and collections.  It is not the best solution, since a notification of completion is the best, but it satisfies my current needs.  I will keep this thread open, hoping a robust solution is returned by Yann.


Sorry for long delay, ATM I don't have any additional pointers to your question.