@@ -223,9 +223,8 @@ public static Optional<PsiMethodCallExpression> findCallUpwardsInChain(@NotNull
223223 * @since 0.3.0
224224 */
225225 public static Optional <PsiMethodCallExpression > findCallDownwardsInChain (@ NotNull PsiExpression aCallInChain , String methodNameToFind ) {
226- var callsInChain = PsiTreeUtil .collectParents (aCallInChain ,
227- PsiMethodCallExpression .class , false , e -> e instanceof PsiExpressionList || e instanceof PsiStatement );
228- return callsInChain .stream ()
226+ return collectCallsInChainFromFirst (aCallInChain )
227+ .stream ()
229228 .filter (call -> methodNameToFind .equals (getMethodName (call )))
230229 .findFirst ();
231230 }
@@ -248,7 +247,7 @@ public static List<PsiMethodCallExpression> collectCallsInChainFromLast(@NotNull
248247 return calls .stream ().map (PsiMethodCallExpression .class ::cast ).collect (toList ());
249248 }
250249
251- public static List <PsiMethodCallExpression > collectCallsInChainFromFirst (PsiMethodCallExpression expression , boolean includeMySelf ) {
250+ public static List <PsiMethodCallExpression > collectCallsInChainFromFirst (PsiExpression expression , boolean includeMySelf ) {
252251 return PsiTreeUtil .collectParents (expression ,
253252 PsiMethodCallExpression .class , includeMySelf , e -> e instanceof PsiExpressionList || e instanceof PsiStatement );
254253 }
@@ -257,6 +256,10 @@ public static List<PsiMethodCallExpression> collectCallsInChainFromFirst(PsiMeth
257256 return collectCallsInChainFromFirst (expression , false );
258257 }
259258
259+ public static List <PsiMethodCallExpression > collectCallsInChainFromFirst (PsiExpression expression ) {
260+ return collectCallsInChainFromFirst (expression , false );
261+ }
262+
260263 /**
261264 * Returns whether the provided set of expressions contain any {@link PsiNewExpression} that references
262265 * a non-default constructor call.
0 commit comments