boolean (PsiExpression expression) { if (expression instanceof PsiMethodCallExpression methodCallExpression) { final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); @NonNls final String methodName = methodExpression.getReferenceName(); if (!"accept".equals(methodName)) { return false; } final PsiExpression qualifier = methodExpression.getQualifierExpression(); if (qualifier == null || !TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.net.ServerSocket")) { return false; } return TypeUtils.expressionHasTypeOrSubtype(methodCallExpression, "java.net.Socket"); } else if (expression instanceof PsiNewExpression) { return TypeUtils.expressionHasTypeOrSubtype(expression, "java.net.Socket", "java.net.DatagramSocket", "java.net.ServerSocket") != null; } return false; }