void ( @NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); if (!MethodCallUtils.isCallToMethod(expression, "java.lang.Thread", PsiTypes.voidType(), "sleep", PsiTypes.longType()) && !MethodCallUtils.isCallToMethod(expression, "java.lang.Thread", PsiTypes.voidType(), "sleep", PsiTypes.longType(), PsiTypes.intType())) { return; } PsiElement context = expression; while (true) { PsiConditionalLoopStatement loopStatement = PsiTreeUtil.getParentOfType(context, PsiConditionalLoopStatement.class, true, PsiClass.class, PsiLambdaExpression.class); if (loopStatement == null) return; context = loopStatement; PsiStatement body = loopStatement.getBody(); if (!PsiTreeUtil.isAncestor(body, expression, true)) continue; PsiExpression loopCondition = loopStatement.getCondition(); if (isLocallyBoundLoop(loopCondition)) { // Condition depends on locals only: likely they are changed in the loop (or another inspection should fire) // so this is not a classic busy wait. continue; } registerMethodCallError(expression); return; } }