如何实时检测 Intellij 或 Android stdio 文件修改 'real'?

How do I detect Intellij or Android stdio file modifications 'real' realtime?

我正在为intellij idea写一个插件。

如何实时检测 Intellij 或 Android stdio 文件修改?

方案一:BulkFileListener

But it works after pressing Ctrl+S. When a character was added or deleted without ctrl+s, it cannot report this event.

方案二: TypedActionHandler

But it only works for adding characters. When a character or a line was deleted, it cannot report this event.

上面两个不是我想要的

还有其他建议吗?

要获取有关所有文档更改的通知,您可以使用 EditorFactory.getEventMulticaster().addDocumentListener()