Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/parser/DifferentialChangesetParser.php
<?php | <?php | ||||
final class DifferentialChangesetParser { | final class DifferentialChangesetParser { | ||||
const HIGHLIGHT_BYTE_LIMIT = 262144; | |||||
btrahan: 64kb is 64000 bytes i thought? | |||||
protected $visible = array(); | protected $visible = array(); | ||||
protected $new = array(); | protected $new = array(); | ||||
protected $old = array(); | protected $old = array(); | ||||
protected $intra = array(); | protected $intra = array(); | ||||
protected $newRender = null; | protected $newRender = null; | ||||
protected $oldRender = null; | protected $oldRender = null; | ||||
protected $filename = null; | protected $filename = null; | ||||
Show All 18 Lines | final class DifferentialChangesetParser { | ||||
private $originalLeft; | private $originalLeft; | ||||
private $originalRight; | private $originalRight; | ||||
private $renderingReference; | private $renderingReference; | ||||
private $isSubparser; | private $isSubparser; | ||||
private $isTopLevel; | private $isTopLevel; | ||||
private $coverage; | private $coverage; | ||||
private $markupEngine; | private $markupEngine; | ||||
private $highlightErrors; | private $highlightErrors; | ||||
private $disableCache; | private $disableCache; | ||||
private $renderer; | private $renderer; | ||||
private $characterEncoding; | private $characterEncoding; | ||||
private $highlightAs; | private $highlightAs; | ||||
private $highlightingDisabled; | |||||
private $showEditAndReplyLinks = true; | private $showEditAndReplyLinks = true; | ||||
private $canMarkDone; | private $canMarkDone; | ||||
private $rangeStart; | private $rangeStart; | ||||
private $rangeEnd; | private $rangeEnd; | ||||
private $mask; | private $mask; | ||||
public function setRange($start, $end) { | public function setRange($start, $end) { | ||||
Show All 10 Lines | final class DifferentialChangesetParser { | ||||
public function renderChangeset() { | public function renderChangeset() { | ||||
return $this->render($this->rangeStart, $this->rangeEnd, $this->mask); | return $this->render($this->rangeStart, $this->rangeEnd, $this->mask); | ||||
} | } | ||||
public function setShowEditAndReplyLinks($bool) { | public function setShowEditAndReplyLinks($bool) { | ||||
$this->showEditAndReplyLinks = $bool; | $this->showEditAndReplyLinks = $bool; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getShowEditAndReplyLinks() { | public function getShowEditAndReplyLinks() { | ||||
return $this->showEditAndReplyLinks; | return $this->showEditAndReplyLinks; | ||||
} | } | ||||
public function setHighlightAs($highlight_as) { | public function setHighlightAs($highlight_as) { | ||||
$this->highlightAs = $highlight_as; | $this->highlightAs = $highlight_as; | ||||
return $this; | return $this; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | return array( | ||||
'old', | 'old', | ||||
'intra', | 'intra', | ||||
'newRender', | 'newRender', | ||||
'oldRender', | 'oldRender', | ||||
'specialAttributes', | 'specialAttributes', | ||||
'hunkStartLines', | 'hunkStartLines', | ||||
'cacheVersion', | 'cacheVersion', | ||||
'cacheHost', | 'cacheHost', | ||||
'highlightingDisabled', | |||||
); | ); | ||||
} | } | ||||
public function saveCache() { | public function saveCache() { | ||||
if ($this->highlightErrors) { | if ($this->highlightErrors) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | final class DifferentialChangesetParser { | ||||
} | } | ||||
private function getHighlightFuture($corpus) { | private function getHighlightFuture($corpus) { | ||||
$language = $this->highlightAs; | $language = $this->highlightAs; | ||||
if (!$language) { | if (!$language) { | ||||
$language = $this->highlightEngine->getLanguageFromFilename( | $language = $this->highlightEngine->getLanguageFromFilename( | ||||
$this->filename); | $this->filename); | ||||
if (($language != 'txt') && | |||||
(strlen($corpus) > self::HIGHLIGHT_BYTE_LIMIT)) { | |||||
$this->highlightingDisabled = true; | |||||
$language = 'txt'; | |||||
} | |||||
} | } | ||||
return $this->highlightEngine->getHighlightFuture( | return $this->highlightEngine->getHighlightFuture( | ||||
$language, | $language, | ||||
$corpus); | $corpus); | ||||
} | } | ||||
protected function processHighlightedSource($data, $result) { | protected function processHighlightedSource($data, $result) { | ||||
▲ Show 20 Lines • Show All 277 Lines • ▼ Show 20 Lines | $renderer = $this->getRenderer() | ||||
->setCodeCoverage($this->getCoverage()) | ->setCodeCoverage($this->getCoverage()) | ||||
->setRenderingReference($this->getRenderingReference()) | ->setRenderingReference($this->getRenderingReference()) | ||||
->setMarkupEngine($this->markupEngine) | ->setMarkupEngine($this->markupEngine) | ||||
->setHandles($this->handles) | ->setHandles($this->handles) | ||||
->setOldLines($this->old) | ->setOldLines($this->old) | ||||
->setNewLines($this->new) | ->setNewLines($this->new) | ||||
->setOriginalCharacterEncoding($encoding) | ->setOriginalCharacterEncoding($encoding) | ||||
->setShowEditAndReplyLinks($this->getShowEditAndReplyLinks()) | ->setShowEditAndReplyLinks($this->getShowEditAndReplyLinks()) | ||||
->setCanMarkDone($this->getCanMarkDone()); | ->setCanMarkDone($this->getCanMarkDone()) | ||||
->setHighlightingDisabled($this->highlightingDisabled); | |||||
$shield = null; | $shield = null; | ||||
if ($this->isTopLevel && !$this->comments) { | if ($this->isTopLevel && !$this->comments) { | ||||
if ($this->isGenerated()) { | if ($this->isGenerated()) { | ||||
$shield = $renderer->renderShield( | $shield = $renderer->renderShield( | ||||
pht( | pht( | ||||
'This file contains generated code, which does not normally '. | 'This file contains generated code, which does not normally '. | ||||
'need to be reviewed.')); | 'need to be reviewed.')); | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if ($this->isTopLevel && !$this->comments) { | ||||
$lines)); | $lines)); | ||||
} | } | ||||
} | } | ||||
if ($shield !== null) { | if ($shield !== null) { | ||||
return $renderer->renderChangesetTable($shield); | return $renderer->renderChangesetTable($shield); | ||||
} | } | ||||
// This request should render the "undershield" headers if it's a top-level | |||||
// request which made it this far (indicating the changeset has no shield) | |||||
// or it's a request with no mask information (indicating it's the request | |||||
// that removes the rendering shield). Possibly, this second class of | |||||
// request might need to be made more explicit. | |||||
$is_undershield = (empty($mask_force) || $this->isTopLevel); | |||||
$renderer->setIsUndershield($is_undershield); | |||||
$old_comments = array(); | $old_comments = array(); | ||||
$new_comments = array(); | $new_comments = array(); | ||||
$old_mask = array(); | $old_mask = array(); | ||||
$new_mask = array(); | $new_mask = array(); | ||||
$feedback_mask = array(); | $feedback_mask = array(); | ||||
if ($this->comments) { | if ($this->comments) { | ||||
foreach ($this->comments as $comment) { | foreach ($this->comments as $comment) { | ||||
▲ Show 20 Lines • Show All 482 Lines • Show Last 20 Lines |
64kb is 64000 bytes i thought?