PsiDocumentManager.commitAllDocuments() on non-dispatch thread

My plugin, which is an in-house i18n plugin, is running into a problem with IDEA 10, where it's getting lots of "Write access is allowed from event dispatch thread only" errors when it's trying to call PsiDocumentManager.commitAllDocuments() in what seems to be a background thread invoked to run an inspection. It's calling commitAllDocuments because it wants to make sure that the PSI for a properties file is up-to-date with document changes.

This code was written quite a while ago for a much older version of IDEA. Is it still necessary to call commitAllDocuments before accessing PSI? If it is still necessary, how would I do this in code that IDEA is running on a background thread?

2 comments
Comment actions Permalink

Hello Gordon,

It has always been required to call PSI commit functions only from the event
dispatch thread; nothing has changed in IDEA 10. In an inspection, you can
count on having an up-to-date PSI and don't have to commit the document yourself.

My plugin, which is an in-house i18n plugin, is running into a problem
with IDEA 10, where it's getting lots of "Write access is allowed from
event dispatch thread only" errors when it's trying to call
PsiDocumentManager.commitAllDocuments() in what seems to be a
background thread invoked to run an inspection. It's calling
commitAllDocuments because it wants to make sure that the PSI for a
properties file is up-to-date with document changes.

This code was written quite a while ago for a much older version of
IDEA. Is it still necessary to call commitAllDocuments before
accessing PSI? If it is still necessary, how would I do this in code
that IDEA is running on a background thread?

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks for the quick reply!

0

Please sign in to leave a comment.