@Override
  public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation) {
    if (GroovyCommonClassNames.GROOVY_TRANSFORM_BASE_SCRIPT.equals(annotation.getQualifiedName())) {
      PsiFile file = annotation.getContainingFile();
      if (file instanceof GroovyFile && !(((GroovyFile)file).isScript())) {
        holder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("base.script.annotation.is.allowed.only.inside.scripts")).range(annotation).create();
        return true;
      }

      PsiElement pparent = annotation.getParent().getParent();
      if (pparent instanceof GrVariableDeclaration) {
        GrTypeElement typeElement = ((GrVariableDeclaration)pparent).getTypeElementGroovy();
        PsiType type = typeElement != null ? typeElement.getType() : null;

        if (!InheritanceUtil.isInheritor(type, GroovyCommonClassNames.GROOVY_LANG_SCRIPT)) {
          String typeText = type != null ? type.getCanonicalText() : CommonClassNames.JAVA_LANG_OBJECT;
          holder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("declared.type.0.have.to.extend.script", typeText)).range(annotation).create();
          return true;
        }
        if (file instanceof GroovyFile && ((GroovyFile)file).isScript()) {
          String thisScriptQualifiedName = Objects.requireNonNull(((GroovyFile)file).getScriptClass()).getQualifiedName();
          if (thisScriptQualifiedName != null && InheritanceUtil.isInheritor(type, thisScriptQualifiedName)) {
            String typeText = type.getCanonicalText();
            holder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("declared.type.0.extends.1.which.is.circular.inheritance", typeText, thisScriptQualifiedName))
              .range(annotation)
              .create();
          }
        }
      }
      else if (pparent instanceof GrPackageDefinition || pparent instanceof GrImportStatement) {
        PsiClass clazz = GrAnnotationUtil.inferClassAttribute(annotation, "value");
        if (!InheritanceUtil.isInheritor(clazz, GroovyCommonClassNames.GROOVY_LANG_SCRIPT)) {
          String typeText = getTypeText(clazz);
          holder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("declared.type.0.have.to.extend.script", typeText)).range(annotation).create();
        }
      }
    }

    return false;
  }
@Override
  public boolean checkApplicability(@NotNull AnnotationHolder holder, @NotNull GrAnnotation annotation)