Search code examples
intellij-ideaintellij-plugin

How to get access from ToolWindowFactory based class to current source code


Ian writing a inspection Plugin for IntelliJ. For this Plugin I need access from ToolWindowFactory based class to current source code (cursor position etc.). Theres a way across the PSIManager, but only in AnAction derived classes, not for ToolWindowFactory derived classes. There are any Ideas?


Solution

  • Perhaps a com.intellij.openapi.editor.event.CaretListener would work? You can register it as follows to receive events for all open editors.

    com.intellij.openapi.editor.EditorFactory.getInstance().getEventMulticaster().addCaretListener(myCaretListener);