3 final class PhabricatorSourceDocumentEngine
4 extends PhabricatorTextDocumentEngine
{
6 const ENGINEKEY
= 'source';
8 public function getViewAsLabel(PhabricatorDocumentRef
$ref) {
9 return pht('View as Source');
12 public function canConfigureHighlighting(PhabricatorDocumentRef
$ref) {
16 public function canBlame(PhabricatorDocumentRef
$ref) {
20 protected function getDocumentIconIcon(PhabricatorDocumentRef
$ref) {
24 protected function getContentScore(PhabricatorDocumentRef
$ref) {
28 protected function newDocumentContent(PhabricatorDocumentRef
$ref) {
29 $content = $this->loadTextData($ref);
33 $highlighting = $this->getHighlightingConfiguration();
34 if ($highlighting !== null) {
35 $content = PhabricatorSyntaxHighlighter
::highlightWithLanguage(
39 $highlight_limit = DifferentialChangesetParser
::HIGHLIGHT_BYTE_LIMIT
;
40 if (strlen($content) > $highlight_limit) {
41 $messages[] = $this->newMessage(
43 'This file is larger than %s, so syntax highlighting was skipped.',
44 phutil_format_bytes($highlight_limit)));
46 $content = PhabricatorSyntaxHighlighter
::highlightWithFilename(
53 if ($ref->getBlameURI() && $this->getBlameEnabled()) {
54 $content = phutil_split_lines($content);
55 $blame = range(1, count($content));
56 $blame = array_fuse($blame);
57 $options['blame'] = $blame;
60 if ($ref->getCoverage()) {
61 $options['coverage'] = $ref->getCoverage();
66 $this->newTextDocumentContent($ref, $content, $options),