String (@NotNull PsiMethodCallExpression prevCall, @NotNull PsiMethodCallExpression nextCall) { PsiMethod nextMethod = nextCall.resolveMethod(); if (nextMethod == null) return null; String nextName = nextMethod.getName(); PsiMethod method = prevCall.resolveMethod(); if (method == null) return null; PsiClass prevClass = method.getContainingClass(); if (prevClass == null) return null; String prevClassName = prevClass.getQualifiedName(); if (prevClassName == null) return null; String prevName = method.getName(); if (nextName.endsWith("Match") || nextName.startsWith("forEach")) return nextName; if (nextName.equals("map")) { return translateMap(prevName); } if (prevName.equals("map")) { return translateMap(nextName); } if(Holder.MAP_METHODS.contains(nextName)) { PsiType type = nextMethod.getReturnType(); if(!(type instanceof PsiClassType)) return null; PsiClass nextClass = ((PsiClassType)type).resolve(); if(nextClass == null) return null; String nextClassName = nextClass.getQualifiedName(); if(nextClassName == null) return null; if(prevClassName.equals(nextClassName)) return "map"; return switch (nextClassName) { case CommonClassNames.JAVA_UTIL_STREAM_INT_STREAM -> "mapToInt"; case CommonClassNames.JAVA_UTIL_STREAM_LONG_STREAM -> "mapToLong"; case CommonClassNames.JAVA_UTIL_STREAM_DOUBLE_STREAM -> "mapToDouble"; case CommonClassNames.JAVA_UTIL_STREAM_STREAM -> "mapToObj"; default -> null; }; } if(nextName.equals("flatMap") && prevClassName.equals(CommonClassNames.JAVA_UTIL_STREAM_STREAM)) { return mapToFlatMap(prevName); } return null; }