void (ASTNode typeElement, PsiType type) { if (type instanceof PsiPrimitiveType) return; LOG.assertTrue(typeElement.getElementType() == JavaElementType.TYPE); if (type instanceof PsiArrayType) { final ASTNode firstChild = typeElement.getFirstChildNode(); LOG.assertTrue(firstChild.getElementType() == JavaElementType.TYPE); encodeInfoInTypeElement(firstChild, type.getDeepComponentType()); } else if (type instanceof PsiWildcardType) { final PsiType bound = ((PsiWildcardType)type).getBound(); if (bound == null) return; final ASTNode lastChild = typeElement.getLastChildNode(); if (lastChild.getElementType() != JavaElementType.TYPE) return; encodeInfoInTypeElement(lastChild, bound); } else if (type instanceof PsiCapturedWildcardType) { final PsiType bound = ((PsiCapturedWildcardType)type).getWildcard().getBound(); if (bound == null) return; final ASTNode lastChild = typeElement.getLastChildNode(); if (lastChild.getElementType() != JavaElementType.TYPE) return; encodeInfoInTypeElement(lastChild, bound); } else if (type instanceof PsiIntersectionType) { encodeInfoInTypeElement(typeElement, ((PsiIntersectionType)type).getRepresentative()); } else if (type instanceof PsiClassType) { final PsiClassType classType = (PsiClassType)type; final PsiClassType.ClassResolveResult resolveResult = classType.resolveGenerics(); PsiClass referencedClass = resolveResult.getElement(); if (referencedClass == null) return; if (referencedClass instanceof PsiAnonymousClass) { encodeInfoInTypeElement(typeElement, ((PsiAnonymousClass)referencedClass).getBaseClassType()); } else { final ASTNode reference = typeElement.findChildByType(JavaElementType.JAVA_CODE_REFERENCE); // can be not the case for "? name" if (reference instanceof CompositeElement) { encodeClassTypeInfoInReference((CompositeElement)reference, resolveResult.getElement(), resolveResult.getSubstitutor()); } } } }