List<PsiElement> (@NotNull PsiElement context, @NotNull Document document, int offset) { if (DumbService.getInstance(context.getProject()).isDumb()) return Collections.emptyList(); if (!PsiUtil.getLanguageLevel(context).isAtLeast(myMinimumLanguageLevel)) { return Collections.emptyList(); } List<PsiElement> expressions; if (myUseTopmostExpression) { expressions = ContainerUtil.createMaybeSingletonList(JavaPostfixTemplatesUtils.getTopmostExpression(context)); } else { PsiFile file = context.getContainingFile(); expressions = new ArrayList<>(CommonJavaRefactoringUtil.collectExpressions(file, document, Math.max(offset - 1, 0), false)); } return ContainerUtil.filter(expressions, Conditions.and(e -> PSI_ERROR_FILTER.value(e) && e instanceof PsiExpression && e.getTextRange().getEndOffset() == offset, getExpressionCompositeCondition())); }