@NotNull private LookupImpl obtainLookup(Editor editor) { CompletionAssertions.checkEditorValid(editor); LookupImpl existing = (LookupImpl) LookupManager.getActiveLookup(editor); if (existing != null && existing.isCompletion()) { existing.markReused(); if (!autopopup) { existing.setFocusDegree(LookupImpl.FocusDegree.FOCUSED); } return existing; } LookupImpl lookup = (LookupImpl) LookupManager.getInstance(editor.getProject()) .createLookup( editor, LookupElement.EMPTY_ARRAY, "", new LookupArranger.DefaultArranger()); if (editor.isOneLineMode()) { lookup.setCancelOnClickOutside(true); lookup.setCancelOnOtherWindowOpen(true); } lookup.setFocusDegree( autopopup ? LookupImpl.FocusDegree.UNFOCUSED : LookupImpl.FocusDegree.FOCUSED); return lookup; }