コード例 #1
0
  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);
  }
コード例 #2
0
 public static InsertionContext newContext(
     InsertionContext oldContext, LookupElement forElement, int startOffset, int tailOffset) {
   final InsertionContext context = newContext(oldContext, forElement);
   setOffsets(context, startOffset, tailOffset);
   return context;
 }