From 32d67cfe544365c36446cb75aa7b8f5db3e0b757 Mon Sep 17 00:00:00 2001 From: Evie Lau <689163+evie-lau@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:21:27 -0500 Subject: [PATCH] Shorten call to get enclosing method declaration --- .../openrewrite/java/migrate/javax/HttpSessionInvalidate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/openrewrite/java/migrate/javax/HttpSessionInvalidate.java b/src/main/java/org/openrewrite/java/migrate/javax/HttpSessionInvalidate.java index 6845f5dc4c..fd53d872aa 100644 --- a/src/main/java/org/openrewrite/java/migrate/javax/HttpSessionInvalidate.java +++ b/src/main/java/org/openrewrite/java/migrate/javax/HttpSessionInvalidate.java @@ -56,7 +56,7 @@ public TreeVisitor getVisitor() { public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) { if (invalidateMethodMatcher.matches(method)) { // Get index of param for HttpServletRequest, from the encapsulating method declaration TODO: would like to make this cleaner... - J.MethodDeclaration parentMethod = getCursor().dropParentUntil(parent -> parent instanceof J.MethodDeclaration).getValue(); + J.MethodDeclaration parentMethod = getCursor().firstEnclosing(J.MethodDeclaration.class); Integer servletReqParamIndex = getServletRequestIndex(parentMethod); // Failed to find HttpServletRequest from parent MethodDeclaration