void (@NotNull Project project, @NotNull final Editor editor) { AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, file -> { int offset = editor.getCaretModel().getOffset(); PsiElement lastElement = file.findElementAt(offset - 1); if (lastElement == null) { return false; } //do not show lookup when typing varargs ellipsis final PsiElement prevSibling = PsiTreeUtil.prevVisibleLeaf(lastElement); if (prevSibling == null || ".".equals(prevSibling.getText())) return false; PsiElement parent = prevSibling; do { parent = parent.getParent(); } while (parent instanceof PsiJavaCodeReferenceElement || parent instanceof PsiTypeElement); if (parent instanceof PsiParameterList || (parent instanceof PsiParameter && !(parent instanceof PsiPatternVariable))) { return false; } if (!".".equals(lastElement.getText()) && !"#".equals(lastElement.getText())) { return JavaClassReferenceCompletionContributor.findJavaClassReference(file, offset - 1) != null; } else { final PsiElement element = file.findElementAt(offset); return element == null || !"#".equals(lastElement.getText()) || PsiTreeUtil.getParentOfType(element, PsiDocComment.class) != null; } }); }