void () { final JavaPsiFacadeEx psiManager = getJavaFacade(); final PsiElementFactory factory = psiManager.getElementFactory(); final PsiClass classA = psiManager.findClass("A"); assertNotNull(classA); final PsiMethod method = classA.getMethods()[0]; final PsiStatement[] methodStatements = method.getBody().getStatements(); final PsiVariable variable = (PsiVariable) ((PsiDeclarationStatement) methodStatements[0]).getDeclaredElements()[0]; final PsiClassType type = (PsiClassType) variable.getType(); final PsiClassType.ClassResolveResult resolveClassTypeResult = type.resolveGenerics(); assertNotNull(resolveClassTypeResult.getElement()); final PsiReferenceExpression methodExpression = ((PsiMethodCallExpression) ((PsiExpressionStatement) methodStatements[2]).getExpression()).getMethodExpression(); final PsiExpression qualifierExpression = methodExpression.getQualifierExpression(); final PsiClassType qualifierType = (PsiClassType) qualifierExpression.getType(); assertFalse(qualifierType.hasParameters()); final PsiType typeFromText = factory.createTypeFromText("test.List", null); assertEquals(qualifierType, typeFromText); final PsiElement psiElement = ((PsiReferenceExpression) qualifierExpression).resolve(); assertTrue(psiElement instanceof PsiVariable); final JavaResolveResult resolveResult = methodExpression.advancedResolve(false); assertTrue(resolveResult.getElement() instanceof PsiMethod); final PsiMethod methodFromList = (PsiMethod) resolveResult.getElement(); assertEquals("add", methodFromList.getName()); assertEquals("test.List", methodFromList.getContainingClass().getQualifiedName()); }