void (PsiElement element, PsiTypeParameter target) { PsiClass containingClass = method.getContainingClass(); PsiTypeParameter[] psiTypeParameters = containingClass.getTypeParameters(); for(int i=0; i<psiTypeParameters.length; i++) { if (psiTypeParameters [i] == target) { PsiType substType = substitutedParameters[i]; if (substType == null) { substType = PsiType.getJavaLangObject(element.getManager(), ProjectScope.getAllScope(element.getProject())); } if (element instanceof PsiJavaCodeReferenceElement) { LOG.assertTrue(substType instanceof PsiClassType); elementsToReplace.put(element, myElementFactory.createReferenceElementByType((PsiClassType)substType)); } else { elementsToReplace.put(element, myElementFactory.createTypeElement(substType)); } } } }