private void linkTypeParameterInstantiations (PsiTypeParameter typeParameter, final PsiTypeElement instantiation, final PsiClass inheritingClass) {
    final PsiTypeParameterListOwner owner = typeParameter.getOwner();
    if (owner instanceof PsiClass ownerClass) {
      final PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(ownerClass, inheritingClass, PsiSubstitutor.EMPTY);
      if (substitutor == null) return;
      ownerClass.accept(new JavaRecursiveElementVisitor() {
        @Override
        public void visitTypeElement(@NotNull PsiTypeElement parent) {
          super.visitTypeElement(parent);
          final PsiElement pparent = parent.getParent();
          if (pparent instanceof PsiMethod method && parent.equals(((PsiMethod)pparent).getReturnTypeElement())) {
            final MethodSignature signature = method.getSignature(substitutor);
            if (PsiUtil.isAccessible(method, inheritingClass, null)) {
              final PsiMethod inInheritor = MethodSignatureUtil.findMethodBySignature(inheritingClass, signature, false);
              if (inInheritor != null && inInheritor.getReturnTypeElement() != null) {
                addLink(instantiation, method.getReturnTypeElement());
                addLink(method.getReturnTypeElement(), instantiation);
              }
            }
          } else if (pparent instanceof PsiParameter parameter) {
            if (parameter.getDeclarationScope() instanceof PsiMethod method) {
              final int index = ((PsiParameterList)parameter.getParent()).getParameterIndex(parameter);
              final MethodSignature signature = method.getSignature(substitutor);
              if (PsiUtil.isAccessible(method, inheritingClass, null)) {
                final PsiMethod inInheritor = MethodSignatureUtil.findMethodBySignature(inheritingClass, signature, false);
                if (inInheritor != null) {
                  final PsiParameter[] inheritorParams = inInheritor.getParameterList().getParameters();
                  LOG.assertTrue(inheritorParams.length > index);
                  final PsiTypeElement hisTypeElement = inheritorParams[index].getTypeElement();
                  addLink(instantiation, hisTypeElement);
                  addLink(hisTypeElement, instantiation);
                }
              }
            }
          }
        }
      });
    }
  }
private void linkTypeParameterInstantiations (PsiTypeParameter typeParameter, final PsiTypeElement instantiation, final PsiClass inheritingClass)