@Nullable
  static HighlightInfo.Builder checkOutsideDeclaredCantBeAssignmentInGuard(@Nullable PsiExpression expressionVariable) {
    if (expressionVariable == null) {
      return null;
    }
    if (!PsiUtil.isAccessedForWriting(expressionVariable)) {
      return null;
    }
    PsiSwitchLabelStatementBase label = PsiTreeUtil.getParentOfType(expressionVariable, PsiSwitchLabelStatementBase.class);
    if (label == null) {
      return null;
    }
    PsiExpression guardingExpression = label.getGuardExpression();
    if (!PsiTreeUtil.isAncestor(guardingExpression, expressionVariable, false)) {
      return null;
    }
    if (!(expressionVariable instanceof PsiReferenceExpression referenceExpression &&
          referenceExpression.resolve() instanceof PsiVariable psiVariable)) {
      return null;
    }
    if (PsiTreeUtil.isAncestor(guardingExpression, psiVariable, false)) {
      return null;
    }
    String message = JavaErrorBundle.message("impossible.assign.declared.outside.guard", psiVariable.getName());
    return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
      .range(expressionVariable)
      .descriptionAndTooltip(message);
  }
@Nullable
  static HighlightInfo.Builder checkOutsideDeclaredCantBeAssignmentInGuard(@Nullable PsiExpression expressionVariable)