PsiFile (@NotNull Project project, @NotNull Language language, @NotNull String text) { LanguageFileType fileType = language.getAssociatedFileType(); CharSequence fileSnippet = StringUtil.first(text, 10 * 1024, false); PsiFileFactory fileFactory = PsiFileFactory.getInstance(project); return fileFactory.createFileFromText( PathUtil.makeFileName("a", fileType == null ? "" : fileType.getDefaultExtension()), language, fileSnippet); }