FileContent (final @NotNull VirtualFile file, final @NotNull CharSequence contentAsText, @Nullable Project project) { FileType fileType = FileTypeRegistry.getInstance().getFileTypeByFile(file); FileContentImpl content = new FileContentImpl(file, fileType, contentAsText, () -> { throw new IllegalStateException("Content must be converted from 'contentAsText'"); }, true); if (project != null) { content.setProject(project); } return content; }