void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { for (String[] completion : RegExpLanguageHosts.getInstance().getPosixCharacterClasses(parameters.getPosition())) { result.addElement( LookupElementBuilder.create(completion[0]).withTypeText((completion.length > 1) ? completion[1] : null).withIcon(emptyIcon) .withInsertHandler(new InsertHandler<>() { @Override public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) { context.setAddCompletionChar(false); final Editor editor = context.getEditor(); final Document document = editor.getDocument(); final int tailOffset = context.getTailOffset(); if (document.getTextLength() < tailOffset + 2 || !document.getText(new TextRange(tailOffset, tailOffset + 2)).equals(":]")) { document.insertString(tailOffset, ":]"); } editor.getCaretModel().moveCaretRelatively(2, 0, false, false, true); } })); } }