void (@NotNull InsertionContext context, @NotNull LookupElement item) { FeatureUsageTracker.getInstance().triggerFeatureUsed("editing.completion.smarttype.casting"); final Editor editor = context.getEditor(); final Document document = editor.getDocument(); if (overwrite) { document.deleteString(context.getSelectionEndOffset(), context.getOffsetMap().getOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET)); } final CommonCodeStyleSettings csSettings = CodeStyle.getLanguageSettings(context.getFile(), GroovyLanguage.INSTANCE); final int oldTail = context.getTailOffset(); context.setTailOffset(GroovyCompletionUtil.addRParenth(editor, oldTail, csSettings.SPACE_WITHIN_CAST_PARENTHESES)); if (csSettings.SPACE_AFTER_TYPE_CAST) { context.setTailOffset(TailType.insertChar(editor, context.getTailOffset(), ' ')); } editor.getCaretModel().moveToOffset(context.getTailOffset()); editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE); GroovyCompletionUtil.addImportForItem(context.getFile(), context.getStartOffset(), item); }