projectOpened

Is it possible to get notification that project is fully opened and it can
be used ( Psi elements can be accessed)?

Now, when I have tried to access PsiElements in "projectOpened" (method
implementation from ProjectComponent) I get following exception:

Assertion failed: Access to psi files should be performed only after startup
activity

at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:114)
at com.intellij.psi.impl.d.a.k.b(k.java:155)
at com.intellij.psi.impl.d.a.k.a(k.java:392)
at com.intellij.psi.impl.d.a.k.a(k.java:76)
at com.intellij.psi.impl.cc.findFile(cc.java:123)
...


The same result I have got with ProjectManagerListener implementation. Seems
that method should be named "projectOpening" instead "projectOpened".

--
Egidijus Vaisnora




2 comments
Comment actions Permalink

Check out the JUnitTest Plugin, it prints out a debug message when the project is loaded, so there may be some code of interest there (I'm actually not sure if the source is available or not, though).

(i have no connection with the development of this plugin, though, so I don't really know what I'm talking about)

Tobin

0
Comment actions Permalink

The JUnitTestPlugin does not use Psi in projectOpened. It isn't possible.
And yes I agree with you it would be nice to have a 2 phase initialization which intuitively would have been
initComponent
projectOpened

However the problem here is the non-management of dependencies by IDEA component framework. The current component initialization mechanism doesn't have the information to manage dependencies so that the order in which components are initialized guarantees that on projectOpened() all dependent components are initialized completely.

So you have to revert back to lazy initialization.
If you need an active plugin maybe you could listen to commands, file events...

Anyway I tried to stir up some discussion about it a few month ago to no avail (http://www.intellij.net/forums/thread.jsp?forum=23&thread=25434&message=458974&q=646570656e64656e6379#458974)
So now I filed a formal request : http://www.intellij.net/tracker/idea/viewSCR?publicId=14726. You can vote for it.

Jacques

0

Please sign in to leave a comment.