void (@NotNull PsiTypeCastExpression expression) { super.visitTypeCastExpression(expression); PsiExpression operand = expression.getOperand(); while (operand instanceof PsiPrefixExpression) { operand = ((PsiPrefixExpression)operand).getOperand(); } if (!(operand instanceof PsiMethodCallExpression methodCallExpression)) { return; } final PsiTypeElement castType = expression.getCastType(); if (castType == null) { return; } final PsiType type = castType.getType(); if (!(type instanceof PsiPrimitiveType) || PsiTypes.doubleType().equals(type) || PsiTypes.floatType().equals(type) || PsiTypes.booleanType() .equals(type)) { return; } final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression(); @NonNls final String referenceName = methodExpression.getReferenceName(); if (!"random".equals(referenceName)) { return; } final PsiMethod method = methodCallExpression.resolveMethod(); if (method == null) { return; } final PsiClass containingClass = method.getContainingClass(); if (containingClass == null) { return; } final String qualifiedName = containingClass.getQualifiedName(); if (!CommonClassNames.JAVA_LANG_MATH.equals(qualifiedName) && !CommonClassNames.JAVA_LANG_STRICT_MATH.equals(qualifiedName)) { return; } registerError(methodCallExpression, expression, type); }