@Override
  protected void processIntention(@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater) {
    if (!(element instanceof GrReferenceElement<?> ref)) return;
    final PsiElement resolved = ref.resolve();
    if (!(resolved instanceof PsiClass psiClass)) return;

    final String qname = psiClass.getQualifiedName();

    final GrImportStatement importStatement =
      GroovyPsiElementFactory.getInstance(context.project()).createImportStatementFromText(qname, true, true, null);

    final PsiFile containingFile = element.getContainingFile();
    if (!(containingFile instanceof GroovyFile)) return;
    ((GroovyFile)containingFile).addImport(importStatement);

    for (PsiReference reference : ReferencesSearch.search(resolved, new LocalSearchScope(containingFile))) {
      final PsiElement refElement = reference.getElement();
      final PsiElement parent = refElement.getParent();
      if (parent instanceof GrQualifiedReference<?>) {
        GrReferenceAdjuster.shortenReference((GrQualifiedReference<?>)parent);
      }
    }
  }
@Override
  protected void processIntention(@NotNull PsiElement element, @NotNull ActionContext context, @NotNull ModPsiUpdater updater)