how to open file in socket thread.
I want to open file by using OpenFileDescriptor,but an error occured in
Editor editor= FileEditorManager.getInstance(myProject).openTextEditor(ofd,true);
:
java.lang.Throwable: Read access is allowed from event dispatch thread or inside read-action only (see com.intellij.openapi.application.Application.runReadAction())
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:154)
at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1048)
at com.intellij.psi.impl.file.impl.FileManagerImpl.findFile(FileManagerImpl.java:346)
at com.intellij.psi.impl.PsiManagerImpl.findFile(PsiManagerImpl.java:187)
at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer.GoToFile(HiCoderSocketServer.java:91)
at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer.access$300(HiCoderSocketServer.java:23)
at com.huawei.hicoder.intellij.plugin.server.HiCoderSocketServer$1$1.run(HiCoderSocketServer.java:46)
at java.lang.Thread.run(Thread.java:748)
Please sign in to leave a comment.
The trace doesn't seem to be related to the line of code you quote.
Anyway, as the exception says, you need a read action to access PSI. See http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/general_threading_rules.html
Thank you so much!You save my life! I solve it by using