List<Value> (PsiExpression expression, PsiType type) { CommonDataflow.DataflowResult dfr = CommonDataflow.getDataflowResult(expression); if (dfr != null) { LongRangeSet range = DfIntType.extractRange(dfr.getDfType(expression)); if (type != null && PsiTypes.intType().isAssignableFrom(type) && !range.isCardinalityBigger(MAX_NUMBER_OF_BRANCHES)) { return range.stream().mapToObj(c -> Value.fromConstant(TypeConversionUtil.computeCastTo(c, type))).collect(Collectors.toList()); } Set<Object> values = dfr.getExpressionValues(expression); if (!values.isEmpty() && values.size() <= MAX_NUMBER_OF_BRANCHES && ContainerUtil.and(values, v -> v instanceof String)) { return values.stream().map(Value::fromConstant).sorted(Comparator.comparing(v -> (String)v.myValue)).collect(Collectors.toList()); } } if (expression instanceof PsiReferenceExpression ref) { PsiModifierListOwner target = ObjectUtils.tryCast(ref.resolve(), PsiModifierListOwner.class); List<Value> values = getValues(target, type, expression); if (values != null) return values; } else if (expression instanceof PsiMethodCallExpression call) { PsiModifierListOwner target = call.resolveMethod(); List<Value> values = getValues(target, type, expression); if (values != null) return values; } return Collections.emptyList(); }