DataContext (Project project, @Nullable SmartPsiElementPointer<PsiElement> psiContext) { DataContext parentContext = project == null ? null : SimpleDataContext.getProjectContext(project); PsiElement context = psiContext != null ? psiContext.getElement() : null; PsiFile file = context == null ? null : context.getContainingFile(); return SimpleDataContext.builder() .setParent(parentContext) .add(CommonDataKeys.PSI_ELEMENT, context) .add(CommonDataKeys.PSI_FILE, file) .build(); }