void (InsertionContext context, int refEnd) { PsiTypeElement typeElem = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), refEnd, PsiTypeElement.class, false); if (typeElem != null) { int typeEnd = typeElem.getTextRange().getEndOffset(); context.getDocument().insertString(typeEnd, ">"); context.getEditor().getCaretModel().moveToOffset(typeEnd + 1); context.getDocument().insertString(refEnd, "<"); context.setAddCompletionChar(false); } }