Getting current project in an inspection

I have an inspection where I'd like to use PhpIndex (in PhpStorm).
For now, I use ProjectManager.getInstance().getOpenProject()[0] to get project in my visitor, but that's not quite good... Would anyone be able to provide me with the correct way?

3 comments
Comment actions Permalink

Answer: PsiElement has a getProject() method. Feeling dumb.

0
Comment actions Permalink
ProblemsHolder.getProject()
0
Comment actions Permalink

Or

DataManager.getInstance().getDataContextFromFocusAsync().then(context -> {
Project project = context.getData(CommonDataKeys.PROJECT);
return null;
});

Can use anywhere.

0

Please sign in to leave a comment.