PsiTypeParameterList (@NotNull String text, Project project) { PsiJavaFile javaFile = (PsiJavaFile)PsiFileFactory.getInstance(project) .createFileFromText("_DUMMY_", JavaFileType.INSTANCE, "class __DUMMY__ " + text + " {}"); PsiClass[] classes = javaFile.getClasses(); return classes[0].getTypeParameterList(); }