@NotNull
  @Override
  protected BaseInspectionVisitor buildVisitor() {
    return new BaseInspectionVisitor() {
      @Override
      public void visitReferenceExpression(@NotNull GrReferenceExpression ref) {
        super.visitReferenceExpression(ref);
        PsiElement resolveResult = getResolveElement(ref);
        checkRef(resolveResult, ref.getReferenceNameElement(), ref.getReferenceName());
      }

      @Override
      public void visitCodeReferenceElement(@NotNull GrCodeReferenceElement ref) {
        super.visitCodeReferenceElement(ref);
        PsiElement resolveResult = getResolveElement(ref);
        checkRef(resolveResult, ref.getReferenceNameElement(), ref.getReferenceName());
      }

      @Override
      public void visitArgumentLabel(@NotNull GrArgumentLabel argumentLabel) {
        super.visitArgumentLabel(argumentLabel);
        PsiElement resolveResult = getResolveElement(argumentLabel);
        if (resolveResult instanceof GrAccessorMethod) {
          resolveResult = ((GrAccessorMethod)resolveResult).getProperty();
        }
        checkRef(resolveResult, argumentLabel.getNameElement(), argumentLabel.getName());
      }

      @Override
      public void visitNewExpression(@NotNull GrNewExpression ref) {
        super.visitNewExpression(ref);
        var resolvedCall = ref.resolveMethod();
        if (resolvedCall == null || isDeprecated(resolvedCall.getContainingClass())) {
          return;
        }
        var referenceElement = ref.getReferenceElement();
        if (referenceElement != null) {
          checkRef(resolvedCall, ref.getReferenceElement(), referenceElement.getReferenceName());
        }
        else {
          checkRef(resolvedCall, ref, resolvedCall.getName());
        }
      }

      private void checkRef(PsiElement resolved, PsiElement elementToHighlight, String elementName) {
        if (isDeprecated(resolved)) {
          registerError(elementToHighlight, GroovyBundle.message("0.is.deprecated", elementName), LocalQuickFix.EMPTY_ARRAY,
                        ProblemHighlightType.LIKE_DEPRECATED);
        }
      }

      private static @Nullable PsiElement getResolveElement(GroovyReference reference) {
        GroovyResolveResult[] results = reference.multiResolve(false);
        for (GroovyResolveResult result : results) {
          PsiElement element = result.getElement();
          if (element != null) {
            return element;
          }
        }
        return null;
      }

      private static boolean isDeprecated(PsiElement resolved) {
        if (resolved instanceof PsiDocCommentOwner) {
          return ((PsiDocCommentOwner)resolved).isDeprecated();
        }
        if (resolved instanceof PsiModifierListOwner && PsiImplUtil.isDeprecatedByAnnotation((PsiModifierListOwner)resolved)) {
          return true;
        }
        return false;
      }
    };
  }
@NotNull
  @Override
  protected BaseInspectionVisitor buildVisitor()