Detecting library changes in project

Hi,

I want to listen to changes in library configuration for the current project/module.

The only working way I found so far was to install a ModuleRootListener - it works, most times :(

In this Listener I want to check presence of a certain class to determine plugin state, following call is wrapped in

:

PsiManager.getInstance(project).findClass(clazzName, GlobalSearchScope.allScope(project));

this sometimes fails with the following error:





Or is there a better way? Installing a LibraryTable.Listener always failed with UnsupportedOperation ..

Thanks,
Yann

0

Hello Yann,

YC> I want to listen to changes in library configuration for the current
YC> project/module.
YC>
YC> The only working way I found so far was to install a
YC> ModuleRootListener - it works, most times :(
YC>
YC> In this Listener I want to check presence of a certain class to
YC> determine plugin state, following call is wrapped in
YC>

 PsiExternalChangeAction() ]]>

:

You shouldn't access the PSI directly from your rootsChanged event handler,
as it can be in an inconsistent state. You should either use the LaterInvocator
class to postpone the event processing, or simply invalidate the state in
rootsChanged and recalculate it when you need to access it.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

Dmitry,

thanks again for your fast reply, it works now as expected (I already had the feeling there was something going wrong wrg to syncing Settings<->PSI).

Btw, in ApplicationManager-JavaDoc there's a reference to "readwriteactions.html", which I could not find?!

Cheers,
Yann

0

Hello Yann,

YC> Btw, in ApplicationManager-JavaDoc there's a reference to
YC> "readwriteactions.html", which I could not find?!

This javadoc is quite old and hasn't been updated yet. It will be updated
with proper references to external documentation later.

--
Dmitry Jemerov
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"


0

请先登录再写评论。