public void testReferenceElement() throws Exception { final JavaPsiFacade manager = getJavaFacade(); final PsiClass classA = manager .getElementFactory() .createClassFromText("class A extends List<String>{}", null) .getInnerClasses()[0]; final PsiClass classTestList = manager.findClass( "test.List", GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(myModule)); assertNotNull(classTestList); classA.getExtendsList().getReferenceElements()[0].bindToElement(classTestList); assertEquals("class A extends test.List<String>{}", classA.getText()); }