void (@NotNull InsertionContext context, @NotNull JavaMethodCallElement item) { PsiDocumentManager.getInstance(context.getProject()).commitDocument(context.getEditor().getDocument()); final Editor editor = context.getEditor(); final PsiMethod method = item.getObject(); Document document = editor.getDocument(); final CharSequence chars = document.getCharsSequence(); int endOffset = editor.getCaretModel().getOffset(); final Project project = context.getProject(); int afterSharp = CharArrayUtil.shiftBackwardUntil(chars, endOffset - 1, "#") + 1; int signatureOffset = afterSharp; PsiElement element = context.getFile().findElementAt(signatureOffset - 1); final CodeStyleSettings styleSettings = CodeStyle.getSettings(context.getFile()); PsiDocTag tag = PsiTreeUtil.getParentOfType(element, PsiDocTag.class); if (context.getCompletionChar() == Lookup.REPLACE_SELECT_CHAR && tag != null) { PsiDocTagValue valueElement = tag.getValueElement(); int valueEnd = valueElement != null ? valueElement.getTextRange().getEndOffset() : -1; if (valueEnd >= afterSharp) { endOffset = valueEnd; context.setTailOffset(endOffset); } } document.deleteString(afterSharp, endOffset); editor.getCaretModel().moveToOffset(signatureOffset); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); editor.getSelectionModel().removeSelection(); String methodName = method.getName(); int beforeParenth = signatureOffset + methodName.length(); PsiParameter[] parameters = method.getParameterList().getParameters(); String signature = "(" + StringUtil.join(parameters, p -> TypeConversionUtil.erasure(p.getType()).getCanonicalText(), "," + (styleSettings.getCommonSettings(JavaLanguage.INSTANCE).SPACE_AFTER_COMMA ? " " : "")) + ")"; String insertString = methodName + signature; if (!(tag instanceof PsiInlineDocTag)) { insertString += " "; } else { if (chars.charAt(signatureOffset) == '}') { afterSharp++; } else { insertString += "} "; }