private static boolean isVarContext(PsiVariable variable) {
    if (PsiUtil.isAvailable(JavaFeature.LVTI, variable)) {
      PsiTypeElement typeElement = variable.getTypeElement();
      if (typeElement != null && typeElement.isInferredType()) {
        return true;
      }
    }
    return false;
  }
private static boolean isVarContext(PsiVariable variable)