From 09a816c5ed4cc39782ddf64d63e0e68b4e20b6c3 Mon Sep 17 00:00:00 2001 From: traceyyoshima Date: Mon, 11 Dec 2023 11:05:55 -0700 Subject: [PATCH 1/3] Polish. Clarified messaging of methodType checks in FindMissingTypes. --- .../openrewrite/java/search/FindMissingTypes.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java b/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java index 9caedf3e751..7d15c320343 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java @@ -140,8 +140,10 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu } else if (!type.getName().equals(mi.getSimpleName()) && !type.isConstructor()) { mi = SearchResult.found(mi, "type information has a different method name '" + type.getName() + "'"); } - if (mi.getName().getType() != null && type != mi.getName().getType()) { - mi = SearchResult.found(mi, "MethodInvocation#name type is not the MethodType of MethodInvocation."); + if (mi.getName().getType() != null && type != null && type != mi.getName().getType()) { + // The MethodDeclaration#name#type and the methodType field should be the same object. + // A different object in one implies a type has changed, either in the method signature or deeper in the type tree. + mi = SearchResult.found(mi, "MethodInvocation#name#type is not a referentially object to the MethodType of MethodInvocation."); } } return mi; @@ -177,8 +179,10 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex } else if (!md.getSimpleName().equals(type.getName()) && !type.isConstructor()) { md = SearchResult.found(md, "type information has a different method name '" + type.getName() + "'"); } - if (md.getName().getType() != null && type != md.getName().getType()) { - md = SearchResult.found(md, "MethodDeclaration#name type is not the MethodType of MethodDeclaration."); + if (md.getName().getType() != null && type != null && type != md.getName().getType()) { + // The MethodDeclaration#name#type and the methodType field should be the same object. + // A different object in one implies a type has changed, either in the method signature or deeper in the type tree. + md = SearchResult.found(md, "MethodDeclaration#name#type is not a referentially object to the MethodType of MethodDeclaration."); } return md; } From b255fd5487a5a944138ce0ad6f5da8fb221b33de Mon Sep 17 00:00:00 2001 From: Tracey Yoshima Date: Wed, 13 Dec 2023 15:00:14 -0700 Subject: [PATCH 2/3] Update rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java Co-authored-by: Tim te Beek --- .../main/java/org/openrewrite/java/search/FindMissingTypes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java b/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java index 7d15c320343..04ecdda0139 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java @@ -182,7 +182,7 @@ public J.MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, Ex if (md.getName().getType() != null && type != null && type != md.getName().getType()) { // The MethodDeclaration#name#type and the methodType field should be the same object. // A different object in one implies a type has changed, either in the method signature or deeper in the type tree. - md = SearchResult.found(md, "MethodDeclaration#name#type is not a referentially object to the MethodType of MethodDeclaration."); + md = SearchResult.found(md, "MethodDeclaration#name#type is not the same instance as the MethodType of MethodDeclaration."); } return md; } From c9c01d062dba15d4aee0e76115c1461f2ee65c9b Mon Sep 17 00:00:00 2001 From: Tracey Yoshima Date: Wed, 13 Dec 2023 15:00:20 -0700 Subject: [PATCH 3/3] Update rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java Co-authored-by: Tim te Beek --- .../main/java/org/openrewrite/java/search/FindMissingTypes.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java b/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java index 04ecdda0139..6e5bba1a436 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/search/FindMissingTypes.java @@ -143,7 +143,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu if (mi.getName().getType() != null && type != null && type != mi.getName().getType()) { // The MethodDeclaration#name#type and the methodType field should be the same object. // A different object in one implies a type has changed, either in the method signature or deeper in the type tree. - mi = SearchResult.found(mi, "MethodInvocation#name#type is not a referentially object to the MethodType of MethodInvocation."); + mi = SearchResult.found(mi, "MethodInvocation#name#type is not the same instance as the MethodType of MethodInvocation."); } } return mi;