mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 21:55:01 +07:00
OptionalUtil#getMapTypeArgument: support PsiEmptyExpressionImpl input
Fixes EA-125157 - IOE: PsiJavaParserFacadeImpl.createExpressionFromText
This commit is contained in:
@@ -228,8 +228,10 @@ public class OptionalUtil {
|
||||
@NotNull
|
||||
private static String getMapTypeArgument(PsiExpression expression, PsiType type, PsiExpression falseExpression) {
|
||||
if (!(type instanceof PsiClassType)) return "";
|
||||
PsiExpression copy =
|
||||
JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(expression.getText(), expression);
|
||||
String text = expression.getText();
|
||||
// PsiEmptyExpressionImpl might be passed here
|
||||
if (text.isEmpty()) return "";
|
||||
PsiExpression copy = JavaPsiFacade.getElementFactory(expression.getProject()).createExpressionFromText(text, expression);
|
||||
PsiType exprType = copy.getType();
|
||||
if (exprType != null &&
|
||||
!exprType.equals(PsiType.NULL) &&
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
List<String> result = list.stream().map(s ->).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// "Replace with collect" "true"
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Main {
|
||||
void test(List<String> list) {
|
||||
List<String> result = new ArrayList<>();
|
||||
f<caret>or (String s : list) {
|
||||
result.add(;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user