コード例 #1
0
  /**
   * @return if method could be made abstract? (that means "create abstract version if method in
   *     parent class")
   */
  private static boolean couldBeAbstract(@NotNull final PyFunction function) {
    if (PyUtil.isInit(function)) {
      return false; // Who wants to make __init__ abstract?!
    }
    final PyUtil.MethodFlags flags = PyUtil.MethodFlags.of(function);
    assert flags != null : "Function should be called on method!";

    final boolean py3K = LanguageLevel.forElement(function).isPy3K();

    // TODO: use strategy because we already has the same check in #addMetaAbcIfNeeded
    return flags.isInstanceMethod() || py3K; // Any method could be made abstract in py3
  }
コード例 #2
0
 @NotNull
 @Override
 public PyMemberInfo<PyFunction> apply(@NotNull final PyFunction pyFunction) {
   final PyUtil.MethodFlags flags = PyUtil.MethodFlags.of(pyFunction);
   assert flags != null : "No flags return while element is function " + pyFunction;
   final boolean isStatic = flags.isStaticMethod() || flags.isClassMethod();
   return new PyMemberInfo<PyFunction>(
       pyFunction,
       isStatic,
       buildDisplayMethodName(pyFunction),
       isOverrides(pyFunction),
       this,
       couldBeAbstract(pyFunction));
 }