void (@NotNull InsertionContext context) { final CommonCodeStyleSettings settings = CompletionStyleUtil.getCodeStyleSettings(context); String spaceWithin = settings.SPACE_WITHIN_CAST_PARENTHESES ? " " : ""; String spaceAfter = settings.SPACE_AFTER_TYPE_CAST ? " " : ""; final Editor editor = context.getEditor(); editor.getDocument().replaceString(context.getStartOffset(), context.getTailOffset(), "(" + spaceWithin + spaceWithin + ")" + spaceAfter); CompletionUtil.emulateInsertion(context, context.getStartOffset() + 1 + spaceWithin.length(), myCastItem); CompletionUtil.emulateInsertion(getDelegate(), context.getTailOffset(), context); }