@Nullable
 public static PsiType getLeastUpperBound(PsiType type1, PsiType type2, PsiManager manager) {
   if (TypeConversionUtil.isPrimitiveAndNotNull(type1)
       || TypeConversionUtil.isPrimitiveAndNotNull(type2)) return null;
   if (TypeConversionUtil.isNullType(type1)) return type2;
   if (TypeConversionUtil.isNullType(type2)) return type1;
   if (Comparing.equal(type1, type2)) return type1;
   return getLeastUpperBound(type1, type2, new LinkedHashSet<Pair<PsiType, PsiType>>(), manager);
 }
Example #2
0
  @Override
  public boolean isAvailable(
      @NotNull Project project,
      @NotNull PsiFile file,
      @NotNull PsiElement startElement,
      @NotNull PsiElement endElement) {
    final PsiMethod myMethod = (PsiMethod) startElement;

    PsiType myReturnType = myReturnTypePointer.getType();
    return myMethod.isValid()
        && myMethod.getManager().isInProject(myMethod)
        && myReturnType != null
        && myReturnType.isValid()
        && !TypeConversionUtil.isNullType(myReturnType)
        && myMethod.getReturnType() != null
        && !Comparing.equal(myReturnType, myMethod.getReturnType());
  }