|
22 | 22 | import com.intellij.psi.util.MethodSignatureBackedByPsiMethod; |
23 | 23 | import com.intellij.util.Processor; |
24 | 24 | import com.intellij.util.Query; |
| 25 | +import org.apache.log4j.Logger; |
25 | 26 | import org.jetbrains.annotations.NotNull; |
26 | 27 | import org.jetbrains.annotations.Nullable; |
27 | 28 |
|
28 | 29 | import java.util.*; |
29 | 30 | import java.util.regex.Pattern; |
30 | 31 |
|
31 | 32 | public final class MethodUtils { |
32 | | - |
33 | | - static List<String> getterPrefixes = Arrays.asList("get", "is", "has"); |
| 33 | + private static final @NotNull Logger LOGGER = Logger.getLogger(MethodUtils.class); |
| 34 | + private static List<String> getterPrefixes = Arrays.asList("get", "is", "has"); |
34 | 35 |
|
35 | 36 | private MethodUtils() {} |
36 | 37 |
|
@@ -289,8 +290,13 @@ private static void processSupers(@NotNull PsiMethod method, @NotNull PsiClass c |
289 | 290 | public static List<PsiMethod> getOverloads(@NotNull PsiMethod method, @NotNull PsiClass containingClass, |
290 | 291 | boolean considerSupers) { |
291 | 292 | List<PsiMethod> overloads = getAllRootOverloads(method, containingClass, considerSupers); |
292 | | - if (!overloads.remove(isOverriding(method) ? method.findDeepestSuperMethods()[0] : method)) { |
293 | | - throw new IllegalStateException("Set of overloaded methods must contain original method"); |
| 293 | + PsiMethod methodThatWasAsked = isOverriding(method) ? method.findDeepestSuperMethods()[0] : method; |
| 294 | + if (overloads.stream() |
| 295 | + .filter(method1 -> calculateSignature(methodThatWasAsked).equals(calculateSignature(method1))) |
| 296 | + .count() != 1) { |
| 297 | + String errorMessage = "Set of overloaded methods must contain original method.\n" + |
| 298 | + "Overloads was searched for " + calculateSignature(method); |
| 299 | + LOGGER.error(errorMessage); |
294 | 300 | } |
295 | 301 | return overloads; |
296 | 302 | } |
|
0 commit comments