@NotNull
  @Override
  protected BaseInspectionVisitor buildVisitor() {
    return new BaseInspectionVisitor() {
      @Override
      public void visitDocMethodReference(@NotNull GrDocMethodReference reference) {
        checkGrDocMemberReference(reference);
      }

      @Override
      public void visitDocFieldReference(@NotNull GrDocFieldReference reference) {
        checkGrDocMemberReference(reference);
      }

      @Override
      public void visitCodeReferenceElement(@NotNull GrCodeReferenceElement refElement) {
        GroovyResolveResult resolveResult = refElement.advancedResolve();
        if (refElement.getReferenceName() == null) return;

        if (PsiTreeUtil.getParentOfType(refElement, GroovyDocPsiElement.class, true, GrMember.class, GrCodeBlock.class) == null) return;

        final PsiElement resolved = resolveResult.getElement();
        if (resolved != null) return;

        final PsiElement toHighlight = refElement.getReferenceNameElement();

        registerError(toHighlight, GroovyBundle.message("cannot.resolve", refElement.getReferenceName()));
      }

      private void checkGrDocMemberReference(final GrDocMemberReference reference) {
        if (reference.resolve() != null) return;

        registerError(reference.getReferenceNameElement(), GroovyBundle.message("cannot.resolve", reference.getReferenceName()));
      }
    };
  }
@NotNull
  @Override
  protected BaseInspectionVisitor buildVisitor()