InsertionContext (@NotNull Editor editor, @NotNull PsiFile file, @NotNull JavaPsiClassReferenceElement item, int startOffset) { Document document = editor.getDocument(); final OffsetMap offsetMap = new OffsetMap(document); final InsertionContext insertionContext = new InsertionContext(offsetMap, Lookup.AUTO_INSERT_SELECT_CHAR, new LookupElement[]{item}, file, editor, false); int offset = editor.getCaretModel().getOffset(); return CompletionUtil.newContext(insertionContext, item, startOffset, offset); }