void (@NotNull InsertionContext context, @NotNull LookupElement item) { String lookupString = item.getLookupString(); String tagName = lookupString.startsWith("@") ? lookupString.substring(1) : lookupString.startsWith("{@") ? lookupString.substring(2, lookupString.length() - 1) : lookupString; boolean hasParameter = INLINE_TAGS_WITH_PARAMETER.contains(tagName); if (hasParameter) { final Editor editor = context.getEditor(); final CaretModel caretModel = editor.getCaretModel(); int offset = caretModel.getOffset(); if (lookupString.endsWith("}")) { offset--; } if (context.getCompletionChar() != ' ') { context.getDocument().insertString(offset, " "); caretModel.moveToOffset(offset + 1); } } if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR) { final Project project = context.getProject(); PsiDocumentManager.getInstance(project).commitAllDocuments(); final Editor editor = context.getEditor(); final CaretModel caretModel = editor.getCaretModel(); final int offset = caretModel.getOffset(); final PsiElement element = context.getFile().findElementAt(offset - 1); PsiDocTag tag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class); assert tag != null; for (PsiElement child = tag.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof PsiDocToken token && token.getTokenType() == JavaDocTokenType.DOC_INLINE_TAG_END) return; } final String name = tag.getName(); final CharSequence chars = editor.getDocument().getCharsSequence(); final int currentOffset = caretModel.getOffset(); if (chars.charAt(currentOffset) == '}') { caretModel.moveToOffset(offset + 1); } else if (chars.charAt(currentOffset + 1) == '}