PsiSubstitutor (PsiJavaCodeReferenceElement referenceElement) { PsiType[] typeArguments = referenceElement.getTypeParameters(); PsiSubstitutor usageSubstitutor = PsiSubstitutor.EMPTY; PsiTypeParameter[] typeParameters = myClass.getTypeParameters(); if (typeParameters.length == typeArguments.length) { for (int i = 0; i < typeParameters.length; i++) { usageSubstitutor = usageSubstitutor.put(typeParameters[i], typeArguments[i]); } } return usageSubstitutor; }