private static VirtualFile findSourceRoot(PsiElement element) {
    if (element == null) return null;

    final PsiFile psiFile = element.getContainingFile();
    if (psiFile == null) return null;

    final VirtualFile file = psiFile.getOriginalFile().getVirtualFile();
    if (file == null) return null;

    return ProjectFileIndex.getInstance(element.getProject()).getSourceRootForFile(file);
  }
private static VirtualFile findSourceRoot(PsiElement element)