public static void emulateInsertion(LookupElement item, int offset, InsertionContext context) { setOffsets(context, offset, offset); final Editor editor = context.getEditor(); final Document document = editor.getDocument(); final String lookupString = item.getLookupString(); document.insertString(offset, lookupString); editor.getCaretModel().moveToOffset(context.getTailOffset()); PsiDocumentManager.getInstance(context.getProject()).commitDocument(document); item.handleInsert(context); }
public static InsertionContext newContext( InsertionContext oldContext, LookupElement forElement, int startOffset, int tailOffset) { final InsertionContext context = newContext(oldContext, forElement); setOffsets(context, startOffset, tailOffset); return context; }