private static String getPackageName(PsiElement element) {
    String packageName = null;
    if (element instanceof PsiPackage pkg) {
      packageName = pkg.getQualifiedName();
    }
    else {
      PsiFile file = element.getContainingFile();
      if (file instanceof PsiClassOwner classOwner) {
        packageName = classOwner.getPackageName();
      }
    }
    return packageName;
  }
private static String getPackageName(PsiElement element)