What is the correct disposable parent for Project lifetime instances? Follow
In my code I used to use project as the parent disposable for any project based entities. Now there is an inspection saying: "Don't use Project as disposable in plugin code"
What would be the recommended parent disposable for these entities which have project life-time?
Please sign in to leave a comment.
You should try and pass a plugin service or another disposable with a smaller scope.
Thanks Yann. Am I correct to understand that an application or project service can be used as a disposable parent and it will be automatically disposed?
Since Disposable has to be explicitly added to the services, I am adding a call Disposer.register(project, this) for each project service in order for it to be disposed.
What about application and project components? I still have one of each until I can figure out how to split them up into smaller services.
Please see https://www.jetbrains.org/intellij/sdk/docs/basics/disposers.html#automatically-disposed-objects
Thanks Yann. I see that I can use one of my Project services which is always loaded by the plugin as the parent for all other disposables.