DetectResult (@NotNull VirtualFile virtualFile, byte @NotNull [] content, int length) { AutoDetectionReason detectedFromBytes = null; try { DetectResult info; if (GUESS_UTF) { info = guessFromBytes(content, length, getDefaultCharsetFromEncodingManager(virtualFile)); if (info.BOM != null) { detectedFromBytes = AutoDetectionReason.FROM_BOM; } else if (info.guessed == CharsetToolkit.GuessedEncoding.VALID_UTF8) { detectedFromBytes = AutoDetectionReason.FROM_BYTES; } } else { info = new DetectResult(null, null, null); } return info; } finally { setCharsetAutoDetectionReason(virtualFile, detectedFromBytes); } }