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?
Please sign in to leave a comment.
Answer: PsiElement has a getProject() method. Feeling dumb.
Or
DataManager.getInstance().getDataContextFromFocusAsync().then(context -> {Project project = context.getData(CommonDataKeys.PROJECT);
return null;
});
Can use anywhere.