List<PsiElement> (@NotNull PsiElement context, @NotNull Document document, int offset) { boolean isEnhancedSwitchAvailable = HighlightingFeature.ENHANCED_SWITCH.isAvailable(context); List<PsiElement> result = new ArrayList<>(); for (PsiElement element = PsiTreeUtil.getNonStrictParentOfType(context, PsiExpression.class, PsiStatement.class); element instanceof PsiExpression; element = element.getParent()) { PsiElement parent = element.getParent(); if (parent instanceof PsiExpressionStatement) { result.add(element); } else if (isEnhancedSwitchAvailable && (isVariableInitializer(element, parent) || isRightSideOfAssignment(element, parent) || isReturnValue(element, parent) || isArgumentList(parent))) { result.add(element); } } return result; }