idea插件报错如下 如何解决java.lang.Throwable: Read access is allowed from inside read-action (or EDT) only (see com.intellij.openapi.application.Application.runReadAction()) at com.intellij.openapi.diagnostic.Logger.error(Logger.java:202) at com.intellij.openapi.application.impl.ApplicationImpl.assertReadAccessAllowed(ApplicationImpl.java:1056) at com.intellij.openapi.editor.impl.CaretImpl.validateContext(CaretImpl.java:1319) at com.intellij.openapi.editor.impl.CaretImpl.getOffset(CaretImpl.java:659) at com.ts.rubikstudioforas.listener.MyCompletionContributor.fillCompletionVariants$lambda$0(MyCompletionContributor.kt:47) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) at java.base/java.lang.Thread.run(Thread.java:833)
时间: 2023-08-05 09:06:32 浏览: 961
解析Java中所有错误和异常的父类java.lang.Th
这个错误通常是因为在非 EDT(Event Dispatch Thread)线程中尝试访问 Swing 组件。你可以使用 `ApplicationManager.getApplication().invokeLater()` 方法来确保代码在 EDT 线程中执行。例如,你可以这样修改代码:
```
ApplicationManager.getApplication().invokeLater {
// 在此处放置你的代码
}
```
这将确保代码在 EDT 线程中执行,并且不会触发读取操作的异常。
阅读全文