PsiReferenceList (@NotNull PsiFileFactory factory, @NotNull String permitsClause) { PsiJavaFile javaFile = (PsiJavaFile)factory.createFileFromText(JavaLanguage.INSTANCE, "class __Dummy " + permitsClause + "{}"); PsiClass newClass = javaFile.getClasses()[0]; return Objects.requireNonNull(newClass.getPermitsList()); }