void (@NotNull final InsertionContext context, @NotNull LookupElement item) { String s = item.getLookupString(); int idx = s.indexOf(':'); String groupId = s.substring(0, idx); String artifactId = s.substring(idx + 1); int startOffset = context.getStartOffset(); PsiFile psiFile = context.getFile(); PsiElement psiElement = psiFile.findElementAt(startOffset); consumeDependencyElement(psiElement, closableBlock -> { int textOffset = closableBlock.getTextOffset(); String value = "{groupId '" + groupId + "'\n" + "artifactId '" + artifactId + "'\n" + "version ''}"; context.getDocument().replaceString(textOffset, textOffset + closableBlock.getTextLength(), value); context.getEditor().getCaretModel().moveToOffset(textOffset + value.length() - 2); context.commitDocument(); new ReformatCodeProcessor(psiFile.getProject(), psiFile, closableBlock.getTextRange(), false).run(); MavenDependencyCompletionUtil.invokeCompletion(context, CompletionType.BASIC); }, element -> { int textOffset = element.getTextOffset(); String value = '\'' + groupId + ":" + artifactId + ":'"; context.getDocument().replaceString(textOffset, textOffset + element.getTextLength(), value); context.getEditor().getCaretModel().moveToOffset(textOffset + value.length() - 1); MavenDependencyCompletionUtil.invokeCompletion(context, CompletionType.BASIC); }); }