void ( @NotNull PsiMethodCallExpression expression) { super.visitMethodCallExpression(expression); final PsiReferenceExpression methodExpression = expression.getMethodExpression(); @NonNls final String methodName = methodExpression.getReferenceName(); if (!"sleep".equals(methodName)) { return; } final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class); boolean isSynced = false; if (containingMethod != null && containingMethod.hasModifierProperty(PsiModifier.SYNCHRONIZED)) { isSynced = true; } final PsiSynchronizedStatement containingSyncStatement = PsiTreeUtil.getParentOfType(expression, PsiSynchronizedStatement.class, true, PsiClass.class, PsiLambdaExpression.class); if (containingSyncStatement != null) { isSynced = true; } if (!isSynced) { return; } final PsiMethod method = expression.resolveMethod(); if (method == null) { return; } final PsiClass methodClass = method.getContainingClass(); if (methodClass == null || !InheritanceUtil.isInheritor(methodClass, "java.lang.Thread")) { return; } registerMethodCallError(expression); }