public static <T extends PsiElement> Location<T> fromPsiElement(T element, Module module) {
    if (element == null) return null;
    PsiUtilCore.ensureValid(element);
    return module != null ? new PsiLocation<>(element.getProject(), module, element) : new PsiLocation<>(element.getProject(), element);
  }
public static <T extends PsiElement> Location<T> fromPsiElement(T element, Module module)