void (PsiNewExpression expression, PsiJavaCodeReferenceElement baseClassReference) { final PsiElement referent = baseClassReference.resolve(); if (!(referent instanceof PsiClass referencedClass)) { return; } if (!InheritanceUtil.isInheritor(referencedClass, "java.lang.Thread")) { return; } final String referencedClassName = referencedClass.getQualifiedName(); if ("java.lang.Thread".equals(referencedClassName)) { checkThreadCreation(expression); return; } //it is an inheritor //check there is `run` method or call constructor of Thread with Runnable PsiClass currentClass = referencedClass; while (currentClass != null && !("java.lang.Thread".equals(currentClass.getQualifiedName()) || CommonClassNames.JAVA_LANG_OBJECT.equals(currentClass.getQualifiedName()))) { if (definesRun(currentClass)) { return; } PsiClass superClass = currentClass.getSuperClass(); if (superClass != null && "java.lang.Thread".equals(superClass.getQualifiedName())) { if (hasCallSuperWithRunnable(currentClass)) { return; } } currentClass = superClass; } registerNewExpressionError(expression); }