mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-inspections] Java8MapForEachInspection: disable when entry getter is used in void context
Also avoid replacing expression with identifier, as this creates illegal PSI Fixes EA-537547 - IOE: PsiExpressionStatementImpl.replaceChildInternal GitOrigin-RevId: 7fd9c0f98165a2f5b6ad74154fa1b5b701610ee7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3067399dc0
commit
da261a7705
+2
-2
@@ -73,7 +73,7 @@ public class Java8MapForEachInspection extends AbstractBaseJavaLocalInspectionTo
|
||||
return ReferencesSearch.search(entry).allMatch(entryRef -> {
|
||||
PsiMethodCallExpression entryCall =
|
||||
ExpressionUtils.getCallForQualifier(ObjectUtils.tryCast(entryRef.getElement(), PsiExpression.class));
|
||||
return ENTRY_GETTER.test(entryCall);
|
||||
return ENTRY_GETTER.test(entryCall) && !ExpressionUtils.isVoidContext(entryCall);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class Java8MapForEachInspection extends AbstractBaseJavaLocalInspectionTo
|
||||
if (!expression.isValid()) continue;
|
||||
PsiMethodCallExpression entryCall = ExpressionUtils.getCallForQualifier(expression);
|
||||
if (ENTRY_GETTER.test(entryCall)) {
|
||||
ct.replace(entryCall, factory.createIdentifier(ParameterCandidate.select(entryCall, key, value).myName));
|
||||
ct.replace(entryCall, ParameterCandidate.select(entryCall, key, value).myName);
|
||||
}
|
||||
}
|
||||
String lambdaBody;
|
||||
|
||||
@@ -92,4 +92,11 @@ public class Test {
|
||||
//long comment
|
||||
});
|
||||
}
|
||||
|
||||
void expressionStatement(Map<String, String> map) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,4 +114,11 @@ public class Test {
|
||||
//long comment
|
||||
}
|
||||
}
|
||||
|
||||
void expressionStatement(Map<String, String> map) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String value = entry.getValue();
|
||||
entry.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user