Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/parser/DifferentialChangesetParser.php
<?php | <?php | ||||
final class DifferentialChangesetParser extends Phobject { | final class DifferentialChangesetParser extends Phobject { | ||||
const HIGHLIGHT_BYTE_LIMIT = 262144; | const HIGHLIGHT_BYTE_LIMIT = 262144; | ||||
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 $depthOnlyLines = array(); | |||||
protected $newRender = null; | protected $newRender = null; | ||||
protected $oldRender = null; | protected $oldRender = null; | ||||
protected $filename = null; | protected $filename = null; | ||||
protected $hunkStartLines = array(); | protected $hunkStartLines = array(); | ||||
protected $comments = array(); | protected $comments = array(); | ||||
protected $specialAttributes = array(); | protected $specialAttributes = array(); | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | switch ($renderer) { | ||||
default: | default: | ||||
$this->setRenderer(new DifferentialChangesetTwoUpRenderer()); | $this->setRenderer(new DifferentialChangesetTwoUpRenderer()); | ||||
break; | break; | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
const CACHE_VERSION = 11; | const CACHE_VERSION = 12; | ||||
const CACHE_MAX_SIZE = 8e6; | const CACHE_MAX_SIZE = 8e6; | ||||
const ATTR_GENERATED = 'attr:generated'; | const ATTR_GENERATED = 'attr:generated'; | ||||
const ATTR_DELETED = 'attr:deleted'; | const ATTR_DELETED = 'attr:deleted'; | ||||
const ATTR_UNCHANGED = 'attr:unchanged'; | const ATTR_UNCHANGED = 'attr:unchanged'; | ||||
const ATTR_WHITELINES = 'attr:white'; | const ATTR_WHITELINES = 'attr:white'; | ||||
const ATTR_MOVEAWAY = 'attr:moveaway'; | const ATTR_MOVEAWAY = 'attr:moveaway'; | ||||
Show All 17 Lines | public function setSpecialAttributes(array $attributes) { | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setIntraLineDiffs(array $diffs) { | public function setIntraLineDiffs(array $diffs) { | ||||
$this->intra = $diffs; | $this->intra = $diffs; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setDepthOnlyLines(array $lines) { | |||||
$this->depthOnlyLines = $lines; | |||||
return $this; | |||||
} | |||||
public function getDepthOnlyLines() { | |||||
return $this->depthOnlyLines; | |||||
} | |||||
public function setVisibileLinesMask(array $mask) { | public function setVisibileLinesMask(array $mask) { | ||||
$this->visible = $mask; | $this->visible = $mask; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setLinesOfContext($lines_of_context) { | public function setLinesOfContext($lines_of_context) { | ||||
$this->linesOfContext = $lines_of_context; | $this->linesOfContext = $lines_of_context; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 210 Lines • ▼ Show 20 Lines | final class DifferentialChangesetParser extends Phobject { | ||||
} | } | ||||
protected static function getCacheableProperties() { | protected static function getCacheableProperties() { | ||||
return array( | return array( | ||||
'visible', | 'visible', | ||||
'new', | 'new', | ||||
'old', | 'old', | ||||
'intra', | 'intra', | ||||
'depthOnlyLines', | |||||
'newRender', | 'newRender', | ||||
'oldRender', | 'oldRender', | ||||
'specialAttributes', | 'specialAttributes', | ||||
'hunkStartLines', | 'hunkStartLines', | ||||
'cacheVersion', | 'cacheVersion', | ||||
'cacheHost', | 'cacheHost', | ||||
'highlightingDisabled', | 'highlightingDisabled', | ||||
); | ); | ||||
▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | private function process() { | ||||
$lines_context = $this->getLinesOfContext(); | $lines_context = $this->getLinesOfContext(); | ||||
$hunk_parser->generateIntraLineDiffs(); | $hunk_parser->generateIntraLineDiffs(); | ||||
$hunk_parser->generateVisibileLinesMask($lines_context); | $hunk_parser->generateVisibileLinesMask($lines_context); | ||||
$this->setOldLines($hunk_parser->getOldLines()); | $this->setOldLines($hunk_parser->getOldLines()); | ||||
$this->setNewLines($hunk_parser->getNewLines()); | $this->setNewLines($hunk_parser->getNewLines()); | ||||
$this->setIntraLineDiffs($hunk_parser->getIntraLineDiffs()); | $this->setIntraLineDiffs($hunk_parser->getIntraLineDiffs()); | ||||
$this->setDepthOnlyLines($hunk_parser->getDepthOnlyLines()); | |||||
$this->setVisibileLinesMask($hunk_parser->getVisibleLinesMask()); | $this->setVisibileLinesMask($hunk_parser->getVisibleLinesMask()); | ||||
$this->hunkStartLines = $hunk_parser->getHunkStartLines( | $this->hunkStartLines = $hunk_parser->getHunkStartLines( | ||||
$changeset->getHunks()); | $changeset->getHunks()); | ||||
$new_corpus = $hunk_parser->getNewCorpus(); | $new_corpus = $hunk_parser->getNewCorpus(); | ||||
$new_corpus_block = implode('', $new_corpus); | $new_corpus_block = implode('', $new_corpus); | ||||
$this->markGenerated($new_corpus_block); | $this->markGenerated($new_corpus_block); | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | $renderer = $this->getRenderer() | ||||
->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()) | ||||
->setObjectOwnerPHID($this->getObjectOwnerPHID()) | ->setObjectOwnerPHID($this->getObjectOwnerPHID()) | ||||
->setHighlightingDisabled($this->highlightingDisabled); | ->setHighlightingDisabled($this->highlightingDisabled) | ||||
->setDepthOnlyLines($this->getDepthOnlyLines()); | |||||
$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 526 Lines • Show Last 20 Lines |