Search code examples
javaintellij-ideaintellij-plugin

How do I add an event listener in an IntelliJ plugin?


I am making an IntelliJ plugin and would like to add a RefactoringEventListener to it. I implemented the class, but the documentation is unclear on how I register it. Do I have to add it somewhere in plugin.xml?


Solution

  • RefactoringEventListener has REFACTORING_EVENT_TOPIC topic, which is the entry point for the listener. You can use it like:

    project.getMessageBus().connect(Disposable)
        .subscribe(RefactoringEventListener.REFACTORING_EVENT_TOPIC, new MyListener())