void (MapCheckCondition condition, PsiStatement noneBranch) { PsiAssignmentExpression assignment = ExpressionUtils.getAssignment(noneBranch); if(assignment != null && mySuggestMapGetOrDefault && condition.isContainsKey()) { /* value = map.get(key); if(value == null) { value = ... } */ PsiExpression rValue = assignment.getRExpression(); if (ExpressionUtils.isSafelyRecomputableExpression(rValue) && condition.isValueReference(assignment.getLExpression()) && !condition.isValueReference(rValue) && condition.isMapValueType(rValue.getType())) { register(condition, holder, false, ReplaceWithSingleMapOperation.fromIf("getOrDefault", condition, rValue)); } } else if (condition.isGetNull()) { /* value = map.get(key); if(value == null) { value = ... map.put(key, value); } */ PsiExpression lambdaCandidate = extractLambdaCandidate(condition, noneBranch); if (lambdaCandidate != null && mySuggestMapComputeIfAbsent) { if (NullabilityUtil.getExpressionNullability(lambdaCandidate) == Nullability.NULLABLE) return; boolean informationLevel = !mySideEffects && SideEffectChecker.mayHaveSideEffects(lambdaCandidate); register(condition, holder, informationLevel, ReplaceWithSingleMapOperation.fromIf("computeIfAbsent", condition, lambdaCandidate)); } if (lambdaCandidate == null) { PsiExpression expression = extractPutValue(condition, noneBranch); if(expression != null) { String replacement = null; boolean informationLevel = false; if (mySuggestMapPutIfAbsent && ExpressionUtils.isSafelyRecomputableExpression(expression) && !condition.isValueReference(expression)) { replacement = "putIfAbsent"; } else if (mySuggestMapComputeIfAbsent && !condition.hasVariable()) { informationLevel = !mySideEffects && SideEffectChecker.mayHaveSideEffects(expression); replacement = "computeIfAbsent"; } if(replacement != null) { if(condition.hasVariable()) { register(condition, holder, informationLevel, ReplaceWithSingleMapOperation.fromIf(replacement, condition, expression)); } else { PsiMethodCallExpression call = PsiTreeUtil.getParentOfType(expression, PsiMethodCallExpression.class); LOG.assertTrue(call != null); register(condition, holder, informationLevel, new ReplaceWithSingleMapOperation(replacement, call, expression, noneBranch)); } } } } } }