@Override
  public void visitTypeDefinition(@NotNull GrTypeDefinition typeDefinition) {
    final PsiElement parent = typeDefinition.getParent();
    if (!(typeDefinition.isAnonymous() ||
          parent instanceof GrTypeDefinitionBody ||
          parent instanceof GroovyFile ||
          typeDefinition instanceof GrTypeParameter)) {
      final TextRange range = GrHighlightUtil.getClassHeaderTextRange(typeDefinition);

        myHolder.newAnnotation(HighlightSeverity.ERROR, GroovyBundle.message("class.definition.is.not.expected.here")).range(range)
      .withFix(new GrMoveClassToCorrectPlaceFix(typeDefinition)).create();
    }
    checkTypeDefinition(myHolder, typeDefinition);

    // enum constants are not handled here because their getTextOffset() is crazy - outside their own getTextRange()
    if (!(typeDefinition instanceof PsiEnumConstantInitializer)) {
      checkImplementedMethodsOfClass(myHolder, typeDefinition);
    }
    checkConstructors(myHolder, typeDefinition);

    checkAnnotationCollector(myHolder, typeDefinition);

    checkSameNameMethodsWithDifferentAccessModifiers(myHolder, typeDefinition.getCodeMethods());
    checkInheritorOfSelfTypes(myHolder, typeDefinition);
  }
@Override
  public void visitTypeDefinition(@NotNull GrTypeDefinition typeDefinition)