@Override
  public @Nullable RefactoringElementListener getListener(PsiElement element) {
    if (element instanceof PsiModifierListOwner modifierListOwner) {
      Project project = element.getProject();
      ExternalAnnotationsManager externalAnnotationsManager = ExternalAnnotationsManager.getInstance(project);
      PsiAnnotation[] annotations = externalAnnotationsManager.findExternalAnnotations(modifierListOwner);
      if (annotations != null) {
        String oldExternalName = PsiFormatUtil.getExternalName(modifierListOwner, false, Integer.MAX_VALUE);
        if (oldExternalName == null) {
          return null;
        }
        return new RefactoringElementListener() {
          private void elementRenamedOrMoved(@NotNull PsiElement newElement) {
            if (newElement instanceof PsiModifierListOwner owner) {
              externalAnnotationsManager.elementRenamedOrMoved(owner, oldExternalName);
            }
          }

          @Override
          public void elementMoved(@NotNull PsiElement newElement) {
            elementRenamedOrMoved(newElement);
          }

          @Override
          public void elementRenamed(@NotNull PsiElement newElement) {
            elementRenamedOrMoved(newElement);
          }
        };
      }
    }
    return null;
  }
@Override
  public @Nullable RefactoringElementListener getListener(PsiElement element)