void (@NotNull PsiLocalVariable psiVariable, @NotNull String cleanupName, @NotNull ProblemValidationSink problemNewBuilder) { final PsiType psiType = psiVariable.getType(); if (psiType instanceof PsiClassType psiClassType) { final PsiClass psiClassOfField = psiClassType.resolve(); final PsiMethod[] methods; if (psiClassOfField != null) { methods = psiClassOfField.findMethodsByName(cleanupName, true); boolean hasCleanupMethod = false; for (PsiMethod method : methods) { if (0 == method.getParameterList().getParametersCount()) { hasCleanupMethod = true; } } if (!hasCleanupMethod) { problemNewBuilder.addErrorMessage("inspection.message.cleanup.method.s.not.found.on.target.class", cleanupName); } } } else { problemNewBuilder.addErrorMessage("inspection.message.cleanup.legal.only.on.local.variable.declaration.inside.block"); } }