Result (char charTyped, @NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { if (!(file instanceof PsiJavaFile)) return Result.CONTINUE; int offset = editor.getCaretModel().getOffset(); if (charTyped == ' ' && StringUtil.endsWith(editor.getDocument().getImmutableCharSequence(), 0, offset, PsiKeyword.NEW)) { AutoPopupController.getInstance(project).scheduleAutoPopup(editor, CompletionType.BASIC, f -> { PsiElement leaf = f.findElementAt(offset - PsiKeyword.NEW.length()); return leaf instanceof PsiKeyword && leaf.textMatches(PsiKeyword.NEW) && !PsiJavaPatterns.psiElement().insideStarting(PsiJavaPatterns.psiExpressionStatement()).accepts(leaf); }); return Result.STOP; } return super.checkAutoPopup(charTyped, project, editor, file); }