WebIde 94.149 causes NullPointerException
Hi guys,
My plugin references Project thru the following call:
Project project = LangDataKeys.PROJECT.getData(DataManager.getInstance().getDataContext());
it works for builds IDEA CE 92.105, WebIDe 94.5/53, etc but the fresh build - WebIde 94.149
stops working. Sometimes LangDataKeys.PROJECT.getData(...) returns NULL sometimes reference is correct - 50/50.
Is this a bug or there is another legal way to access a reference to the Project object?
Thanks.
Serhiy
Please sign in to leave a comment.
Hello sky,
Getting the Project from DataManager is a "last resort" way - in almost all
of the places there are better ways to get the project.
In which context do you need to get the project?
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"
Plugin uses Project as a data holder for a set of objects that can be considered as services: data cache, connection manager, etc.
They can be referenced from lots of places initiated from UI or background tasks. I do not know another way to work in the multiframe mode, except binding to Project. So, not using DataManager I have to pass project thru call stack to give a chance somewhere deeply to request an appropriate service instance.
In my opinion, having different classloader for a plugin running in different frame might make things easier, at least services could be accessible just thru static reference.
Serhiy
Hello sky,
This is the correct thing to do, and our own code does this as well.
This would require a nearly complete rewrite of IntelliJ IDEA.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"