use of com.intellij.codeInsight.completion.OffsetMap in project intellij-community by JetBrains.
the class TemplateExpressionLookupElement method createInsertionContext.
private static InsertionContext createInsertionContext(LookupElement item, PsiFile psiFile, List<? extends LookupElement> elements, Editor editor, final char completionChar) {
final OffsetMap offsetMap = new OffsetMap(editor.getDocument());
final InsertionContext context = new InsertionContext(offsetMap, completionChar, elements.toArray(new LookupElement[elements.size()]), psiFile, editor, false);
context.setTailOffset(editor.getCaretModel().getOffset());
offsetMap.addOffset(CompletionInitializationContext.START_OFFSET, context.getTailOffset() - item.getLookupString().length());
offsetMap.addOffset(CompletionInitializationContext.SELECTION_END_OFFSET, context.getTailOffset());
offsetMap.addOffset(CompletionInitializationContext.IDENTIFIER_END_OFFSET, context.getTailOffset());
return context;
}
Aggregations