I am running post-compile task that is possibly changing files status and requires updating file icons. To make the changes visible I am using:
ProjectView.getInstance (project).refresh ();
As was advised in another thread. Refresh is write action thus could be run only from Swing event dispatch thread using Application.runWriteAction() method. On the other hand the post-compile task is being run in Compilation thread that does not allow performing write actions (I get all kinds of assertion errors if I try).
I tried to wait for completion of my post-compile task in a GUI dispatch thread that triggered compilation but it causes deadlock. I am using:
CompilerManager.getInstance (project).make(new ProjectCompileScope (project), null);
To start compilation. I tried a few different approaches and as far as I can see the compilation thread is not started my actionPerfromed() method in Swing dispatch thread has exited. This makes sense to me because compilation is obviously write action that should wait for all possible read actions to complete, but leaves no way to perform an after-compilation write action.
I also tried to start a new thread from event dispatch thread that waits for post-compile task to complete and then starts refresh, but it is no better because the same assertions naturally fail.
Note: the action is actually performed correctly regardless the assertions, the project view is updated.
Any suggestions are greatly appreciated.