public void itemSelected(LookupEvent event) { finishCompletionProcess(false); LookupElement item = event.getItem(); if (item == null) return; setMergeCommand(); CodeCompletionHandlerBase.lookupItemSelected( CompletionProgressIndicator.this, item, event.getCompletionChar(), myLookup.getItems()); }
public void addSparedChars( CompletionProgressIndicator indicator, LookupElement item, InsertionContext context, char completionChar) { String textInserted; if (context.getStartOffset() >= 0 && context.getTailOffset() >= context.getStartOffset()) { textInserted = context .getDocument() .getText() .substring(context.getStartOffset(), context.getTailOffset()); } else { textInserted = item.getLookupString(); } String withoutSpaces = StringUtil.replace( textInserted, new String[] {" ", "\t", "\n"}, new String[] {"", "", ""}); int spared = withoutSpaces.length() - indicator.getLookup().itemPattern(item).length(); if (!LookupEvent.isSpecialCompletionChar(completionChar) && withoutSpaces.contains(String.valueOf(completionChar))) { spared--; } if (spared > 0) { mySpared += spared; } }