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?

0
3 comments

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

0
ProblemsHolder.getProject()
0

Or

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

Can use anywhere.

1

Please sign in to leave a comment.