boolean (@NotNull PsiFile file, @NotNull Editor editor, @NotNull String selectedText, char c) { if (selectedText.startsWith("<") && selectedText.endsWith(">")) { SelectionModel model = editor.getSelectionModel(); int startIndex = model.getSelectionStart(); PsiElement start = file.findElementAt(startIndex); int endIndex = model.getSelectionEnd(); PsiElement end = file.findElementAt(endIndex > 0 ? endIndex - 1 : endIndex); if (start != null && (start.getNode().getElementType() == XmlTokenType.XML_START_TAG_START || start.getNode().getElementType() == XmlTokenType.XML_END_TAG_START) && end != null && (end.getNode().getElementType() == XmlTokenType.XML_TAG_END || end.getNode().getElementType() == XmlTokenType.XML_EMPTY_ELEMENT_END)) { return true; } } return false; }