public static int compareMethods(@NotNull GroovyMethodResult result1, @NotNull GroovyMethodResult result2, @NotNull Context context) {
    final PsiMethod method1 = result1.getElement();
    final PsiMethod method2 = result2.getElement();

    if (!method1.getName().equals(method2.getName())) return 0;

    boolean firstIsPreferable = checkDominated(result2, result1, context);
    boolean secondIsPreferable = checkDominated(result1, result2, context);

    if (firstIsPreferable == secondIsPreferable) {
      if (method1 instanceof GrGdkMethod && !(method2 instanceof GrGdkMethod)) {
        return 1;
      }
      if (!(method1 instanceof GrGdkMethod) && method2 instanceof GrGdkMethod) {
        return -1;
      }
      if (secondIsPreferable) {
        return 1;
      }
      else {
        return 0;
      }
    }
    else if (firstIsPreferable) {
      return -1;
    }
    else {
      return 1;
    }
  }
public static int compareMethods(@NotNull GroovyMethodResult result1, @NotNull GroovyMethodResult result2, @NotNull Context context)