DocumentContent (byte @NotNull [] content) { FileType fileType = guessFileType(); String lightFilePath = constructLightFilePath(); VirtualFile highlightFile = constructHighlightFile(); Charset charset = guessCharset(project, content, fileType, lightFilePath, highlightFile, defaultCharset); // decode bytes ourselves to detect incorrect charsets TextContent textContent = TextContent.fromBytes(content, charset); Document document = createDocument(project, textContent.text, fileType, lightFilePath, readOnly); return build(document, textContent); }