PsiType (PsiType type, Project project, PsiMethod containingMethod) { PsiClass parentClass = containingMethod.getContainingClass(); final PsiClass typeClass = PsiUtil.resolveClassInType(type); if (typeClass != null) { if (typeClass instanceof PsiTypeParameter) { if (ArrayUtil.find(parentClass.getTypeParameters(), typeClass) == -1) { //unknown type parameter return PsiType.getJavaLangObject(PsiManager.getInstance(project), GlobalSearchScope.allScope(project)); } } else if (PsiTreeUtil.isAncestor(containingMethod, typeClass, true)) { //local class type final int nextTypeIdx = ArrayUtil.find(myTypesForAll, type) + 1; if (nextTypeIdx < myTypesForAll.length) { return checkIfTypeAccessible(myTypesForAll[nextTypeIdx], project, containingMethod); } } } return type; }