int (@NotNull InsertionContext context, int offset) { int result = offset + 2; PsiCall call = PsiTreeUtil.findElementOfClassAtOffset(context.getFile(), offset, PsiCall.class, false); if (call == null || call.getArgumentList() == null) return result; int argumentListEnd = call.getArgumentList().getTextRange().getEndOffset(); if (argumentListEnd <= result && isAnonymous(call)) return offset + 1; return argumentListEnd - 1; }