I have build a LocalInspectionTool that reports problems directly by highlighting parts of the code and offering quick fixes. However, I would like to extend this and offer more sophisticated options and descriptions of the problem in a separate ToolWindow.
All problems that are highlighted in the code should again be listed in the tool window – the right pane will offer more detailed descriptions of the problem and further more advanced options for refactoring. The problem I am facing now is that am unsure as to how to share data about problems between the LocalInspectionTool and the ToolWindow instances. Is there a standard pattern on how to do this in Intellij?
- Use a publish-subscribe model to publish problem desciptors from the Inspection Tool and subscribe to these from the ToolWindow? If so, are there already PubSub mechanisms available (I saw there is a project message bus)?
- Build a singleton cache that both objects have access to?
- Run the LocalInspectionTool manually via a PsiTreeChangeAdapter from ToolWindow itself (using this approach: https://devnet.jetbrains.com/message/5514826#5514826) (EDIT: This has the disadvantage that if the tool window is closed the problems will also no longer be highlighted in the code, which is undesireable)
- something else?
Both components (inspection tool and toolwindow) are currently set up via the plugin.xml file.
Thank you very much in advance,