String (PsiVariable variable, @Nullable PsiType outType, PsiElement mapper) { if (!(mapper instanceof PsiExpression)) return null; PsiExpression expression = PsiUtil.skipParenthesizedExprDown(((PsiExpression)mapper)); PsiType inType = variable.getType(); if (expression instanceof PsiTypeCastExpression && inType instanceof PsiPrimitiveType && Objects.equals(expression.getType(), outType)) { expression = ((PsiTypeCastExpression)expression).getOperand(); } if (ExpressionUtils.isReferenceTo(expression, variable)) { if (!(outType instanceof PsiPrimitiveType)) { return inType instanceof PsiPrimitiveType ? "boxed" : ""; } if (outType.equals(inType)) { return ""; } if (PsiTypes.longType().equals(outType) && PsiTypes.intType().equals(inType)) { return "asLongStream"; } if (PsiTypes.doubleType().equals(outType) && (PsiTypes.longType().equals(inType) || PsiTypes.intType().equals(inType))) { return "asDoubleStream"; } } return null; }