Don’t guess which lock your code is running under. You can verify it directly in the debugger.
In this quick example:
ProjectActivityruns without a lockAnAction.actionPerformed()runs under a read lock- PSI modifications must run on the EDT and under a write lock