public static PsiType getTargetTypeByParent(PsiElement context) {
    PsiType targetType = getTargetTypeFromParent(context, new Ref<>(), false);
    if (targetType instanceof PsiClassType) {
      return ((PsiClassType)targetType).setLanguageLevel(PsiUtil.getLanguageLevel(context));
    }
    return targetType;
  }
public static PsiType getTargetTypeByParent(PsiElement context)