private static @Nullable PsiElement getAttributeCandidate(@NotNull Editor editor, @NotNull PsiFile file, boolean typed) {
    int newOffset = editor.getCaretModel().getOffset() - (typed ? 2 : 1);
    if (newOffset < 0) return null;

    PsiElement at = file.findElementAt(newOffset);
    return at != null ? at.getParent() : null;
  }
private static @Nullable PsiElement getAttributeCandidate(@NotNull Editor editor, @NotNull PsiFile file, boolean typed)