public static @Nullable Character getCharBeforeCursorInPsiElement(PsiElement psiElement, int cursorPosition) {
    TextRange elementRange = psiElement.getTextRange();
    int index = cursorPosition - elementRange.getStartOffset() - 1;
    String elementText = psiElement.getText();
    if (index < 0 || index >= elementText.length()) return null;
    return elementText.charAt(index);
  }
public static @Nullable Character getCharBeforeCursorInPsiElement(PsiElement psiElement, int cursorPosition)