void (@NotNull PsiReferenceExpression referenceExpression) { // check if resource is closed in a method like IOUtils.silentClose() super.visitReferenceExpression(referenceExpression); if (containsClose) { return; } final String text = referenceExpression.getText(); if (text == null || !text.equals(resourceName)) { return; } final PsiElement parent = referenceExpression.getParent(); if (!(parent instanceof PsiExpressionList argumentList)) { return; } final PsiExpression[] arguments = argumentList.getExpressions(); if (arguments.length != 1) { return; } final PsiElement grandParent = parent.getParent(); if (!(grandParent instanceof PsiMethodCallExpression methodCallExpression)) { return; } final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); final String methodName = methodExpression.getReferenceName(); if (methodName == null || !methodName.contains(HardcodedMethodConstants.CLOSE)) { return; } final PsiElement target = referenceExpression.resolve(); if (target == null || !target.equals(resource)) { return; } // handle any call to a method with "close" in the name and // a resource argument inside the finally block as closing the resource. // like e.g. org.apache.commons.io.IOUtils.closeQuietly() // and com.google.common.io.Closeables.closeQuietly() containsClose = true; }