@Nullable
  public static PsiClass getContextClass(@Nullable PsiElement element) {
    PsiElement context = element;
    while (context != null) {
      if (context instanceof GrAnonymousClassDefinition
          && PsiTreeUtil.isAncestor(((GrAnonymousClassDefinition)context).getArgumentListGroovy(), element, false)) {
        context = context.getContext();
        continue;
      }

      if (context instanceof PsiClass && !isInDummyFile(context)) {
        return (PsiClass)context;
      }
      else if (context instanceof GroovyFileBase && !isInDummyFile(context)) {
        return ((GroovyFileBase)context).getScriptClass();
      }

      context = context.getContext();
    }
    return null;
  }
@Nullable
  public static PsiClass getContextClass(@Nullable PsiElement element)