private static boolean isStaticContext(PsiElement context) {
    PsiElement parent = context;
    while (parent != null) {
      if (parent instanceof PsiMember) {
        return ((PsiMember)parent).hasModifierProperty(PsiModifier.STATIC);
      }
      if (parent instanceof GroovyFile && parent.isPhysical()) return false;
      if (parent instanceof GrFunctionalExpression) return false;

      parent = parent.getContext();
    }

    return false;
  }
private static boolean isStaticContext(PsiElement context)