ApplicationManager.getApplication().runWriteAction() vs WriteCommandAction.runWriteCommandAction()
Some operations cannot be invoked inside
ApplicationManager.getApplication().runWriteAction()
must use
WriteCommandAction.runWriteCommandAction()
So what is the different between these two calls? is there any other similar write call i should take care about?
Thanks
Please sign in to leave a comment.
All modifications to physical PSI, VFS and project model should be done in write actions (see also http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/general_threading_rules.html). All modifications to documents should be done in commands (see also http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/documents.html). For most PSI operations, documents would also be affected, so such operations should be wrapped into both commands and write actions. WriteCommandAction just combines these two APIs into one handy shortcut.
Thank you Peter.