void (@NotNull InsertionContext context) { PsiFile file = context.getFile(); CommonCodeStyleSettings settings = CodeStyle.getLanguageSettings(file); String callSpace = getSpace(settings.SPACE_WITHIN_METHOD_CALL_PARENTHESES); String insertString = myMethod.getName() + "(" + callSpace + myArgument + callSpace + ")"; int offset = context.getStartOffset(); context.getDocument().replaceString(offset, context.getTailOffset(), insertString); context.commitDocument(); JavaCodeStyleManager.getInstance(context.getProject()) .shortenClassReferences(file, offset, offset + insertString.length()); }