private static XmlTag getTag(@Nullable Editor editor, PsiFile file) {
    if (!(file instanceof XmlFile)) return null;
    
    int offset = editor.getCaretModel().getOffset();
    PsiElement element = file.findElementAt(offset);
    XmlTag parent = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (parent != null) return parent;

    element = file.findElementAt(offset - 1);
    parent = PsiTreeUtil.getParentOfType(element, XmlTag.class);
    if (parent != null) return parent;
    return null;
  }
private static XmlTag getTag(@Nullable Editor editor, PsiFile file)