Directory index is not initialized yet while opening project

I am getting below issue while opening project with my custom plugin installed. In projectCompoent of my plugin, I am trying to read ".idea/workspace.xml" and get this error on random occasions. Any suggestion please to overcome this.



Directory index is not initialized yet for Project 'E:\plugin\test' test
java.lang.Throwable
 at com.intellij.openapi.diagnostic.Logger.error(Logger.java:113)
 at com.intellij.openapi.roots.impl.DirectoryIndexImpl.checkAvailability(DirectoryIndexImpl.java:734)
 at com.intellij.openapi.roots.impl.DirectoryIndexImpl.getInfoForDirectory(DirectoryIndexImpl.java:582)
 at com.intellij.openapi.roots.impl.FileIndexBase.getInfoForFileOrDirectory(FileIndexBase.java:28)
 at com.intellij.openapi.roots.impl.ProjectFileIndexImpl.getModuleForFile(ProjectFileIndexImpl.java:108)
 at com.intellij.openapi.roots.JavaProjectRootsUtil.isInGeneratedCode(JavaProjectRootsUtil.java:59)
 at com.intellij.openapi.roots.JavaGeneratedSourcesFilter.isGeneratedSource(JavaGeneratedSourcesFilter.java:28)
 at com.intellij.ide.GeneratedSourceFileChangeTrackerImpl.isGenerated(GeneratedSourceFileChangeTrackerImpl.java:137)
 at com.intellij.ide.GeneratedSourceFileChangeTrackerImpl.access$700(GeneratedSourceFileChangeTrackerImpl.java:41)
 at com.intellij.ide.GeneratedSourceFileChangeTrackerImpl$5.run(GeneratedSourceFileChangeTrackerImpl.java:113)
 at com.intellij.openapi.application.RunResult.run(RunResult.java:38)
 at com.intellij.openapi.application.ReadAction$1.compute(ReadAction.java:29)
 at com.intellij.openapi.application.ReadAction$1.compute(ReadAction.java:26)
 at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:932)
 at com.intellij.openapi.application.ReadAction.execute(ReadAction.java:26)
 at com.intellij.ide.GeneratedSourceFileChangeTrackerImpl.checkFiles(GeneratedSourceFileChangeTrackerImpl.java:109)
 at com.intellij.ide.GeneratedSourceFileChangeTrackerImpl.access$000(GeneratedSourceFileChangeTrackerImpl.java:41)
 at com.intellij.ide.GeneratedSourceFileChangeTrackerImpl$1.run(GeneratedSourceFileChangeTrackerImpl.java:65)
 at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
 at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
 at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
 at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
 at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
 at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
 at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
 at com.intellij.util.Alarm$Request$1.run(Alarm.java:327)
 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
 at java.util.concurrent.FutureTask.run(FutureTask.java:262)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
 at java.lang.Thread.run(Thread.java:745)

7 comments
Comment actions Permalink

Why exactly do you need to read workspace.xml? As I said, all the data in workspace.xml can be accessed through components with a proper API.


0
Comment actions Permalink

I want to suppress the "Clear Read-Only Status Dialog" via plugin and adding below to workspace.xml file

<component name="ReadonlyStatusHandler">
    <option name="SHOW_DIALOG" value="false" />
  </component>

Not sure on any API availability for this.

0
Comment actions Permalink

Generally speaking, overriding user settings based on the assumption that the only reason why the user uses IntelliJ IDEA is your plugin is not the right thing to do.

0
Comment actions Permalink

I agree. I intend to make this for internal use for specific people.

0
Comment actions Permalink

You can change the value of this setting through this call:

((ReadonlyStatusHandlerImpl) ReadonlyStatusHandler.getInstance(project)).getState().SHOW_DIALOG = false;

0
Comment actions Permalink
 
I have imported below:
  
import com.intellij.openapi.vfs.ReadonlyStatusHandler;



But not able to resolve symbol ReadonlyStatusHandlerImpl. Not sure what to import for this.

((ReadonlyStatusHandlerImpl) ReadonlyStatusHandler.getInstance(project)).getState().SHOW_DIALOG = false;
0
Comment actions Permalink

Please make sure that idea.jar is added to the classpath of your IntelliJ IDEA SDK.


0

Please sign in to leave a comment.