Changeset View
Changeset View
Standalone View
Standalone View
src/applications/differential/parser/DifferentialChangesetParser.php
| Show All 39 Lines | final class DifferentialChangesetParser extends Phobject { | ||||
| 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 $highlightingDisabled; | private $highlightingDisabled; | ||||
| private $showEditAndReplyLinks = true; | private $showEditAndReplyLinks = true; | ||||
| private $canMarkDone; | private $canMarkDone; | ||||
| private $objectOwnerPHID; | private $objectOwnerPHID; | ||||
| private $offsetMode; | private $offsetMode; | ||||
| private $rangeStart; | private $rangeStart; | ||||
| private $rangeEnd; | private $rangeEnd; | ||||
| private $mask; | private $mask; | ||||
| private $linesOfContext = 8; | private $linesOfContext = 8; | ||||
| private $highlightEngine; | private $highlightEngine; | ||||
| private $viewer; | private $viewer; | ||||
| private $documentEngineKey; | private $documentEngineKey; | ||||
| private $viewState; | |||||
| public function setRange($start, $end) { | public function setRange($start, $end) { | ||||
| $this->rangeStart = $start; | $this->rangeStart = $start; | ||||
| $this->rangeEnd = $end; | $this->rangeEnd = $end; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setMask(array $mask) { | public function setMask(array $mask) { | ||||
| $this->mask = $mask; | $this->mask = $mask; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| 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 setViewState(PhabricatorChangesetViewState $view_state) { | ||||
| $this->highlightAs = $highlight_as; | $this->viewState = $view_state; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getHighlightAs() { | public function getViewState() { | ||||
| return $this->highlightAs; | return $this->viewState; | ||||
| } | } | ||||
| public function setCharacterEncoding($character_encoding) { | public function setCharacterEncoding($character_encoding) { | ||||
| $this->characterEncoding = $character_encoding; | $this->characterEncoding = $character_encoding; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getCharacterEncoding() { | public function getCharacterEncoding() { | ||||
| ▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | if ($is_unified) { | ||||
| return '1up'; | return '1up'; | ||||
| } | } | ||||
| return null; | return null; | ||||
| } | } | ||||
| public function readParametersFromRequest(AphrontRequest $request) { | public function readParametersFromRequest(AphrontRequest $request) { | ||||
| $this->setCharacterEncoding($request->getStr('encoding')); | $this->setCharacterEncoding($request->getStr('encoding')); | ||||
| $this->setHighlightAs($request->getStr('highlight')); | |||||
| $this->setDocumentEngineKey($request->getStr('engine')); | $this->setDocumentEngineKey($request->getStr('engine')); | ||||
| $renderer = null; | $renderer = null; | ||||
| // If the viewer prefers unified diffs, always set the renderer to unified. | // If the viewer prefers unified diffs, always set the renderer to unified. | ||||
| // Otherwise, we leave it unspecified and the client will choose a | // Otherwise, we leave it unspecified and the client will choose a | ||||
| // renderer based on the screen size. | // renderer based on the screen size. | ||||
| ▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | public function setHandles(array $handles) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setMarkupEngine(PhabricatorMarkupEngine $engine) { | public function setMarkupEngine(PhabricatorMarkupEngine $engine) { | ||||
| $this->markupEngine = $engine; | $this->markupEngine = $engine; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setUser(PhabricatorUser $user) { | |||||
| $this->user = $user; | |||||
| return $this; | |||||
| } | |||||
| public function getUser() { | |||||
| return $this->user; | |||||
| } | |||||
| public function setCoverage($coverage) { | public function setCoverage($coverage) { | ||||
| $this->coverage = $coverage; | $this->coverage = $coverage; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| private function getCoverage() { | private function getCoverage() { | ||||
| return $this->coverage; | return $this->coverage; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | foreach ($render as $key => $text) { | ||||
| $result = $this->adjustRenderedLineForDisplay($result); | $result = $this->adjustRenderedLineForDisplay($result); | ||||
| $render[$key] = $result; | $render[$key] = $result; | ||||
| } | } | ||||
| } | } | ||||
| private function getHighlightFuture($corpus) { | private function getHighlightFuture($corpus) { | ||||
| $language = $this->highlightAs; | $language = $this->getViewState()->getHighlightLanguage(); | ||||
| if (!$language) { | if (!$language) { | ||||
| $language = $this->highlightEngine->getLanguageFromFilename( | $language = $this->highlightEngine->getLanguageFromFilename( | ||||
| $this->filename); | $this->filename); | ||||
| if (($language != 'txt') && | if (($language != 'txt') && | ||||
| (strlen($corpus) > self::HIGHLIGHT_BYTE_LIMIT)) { | (strlen($corpus) > self::HIGHLIGHT_BYTE_LIMIT)) { | ||||
| $this->highlightingDisabled = true; | $this->highlightingDisabled = true; | ||||
| Show All 13 Lines | foreach ($data as $key => $info) { | ||||
| if (!$info) { | if (!$info) { | ||||
| unset($result_lines[$key]); | unset($result_lines[$key]); | ||||
| } | } | ||||
| } | } | ||||
| return $result_lines; | return $result_lines; | ||||
| } | } | ||||
| private function tryCacheStuff() { | private function tryCacheStuff() { | ||||
| $viewstate = $this->getViewState(); | |||||
| $skip_cache = false; | $skip_cache = false; | ||||
| if ($this->disableCache) { | if ($this->disableCache) { | ||||
| $skip_cache = true; | $skip_cache = true; | ||||
| } | } | ||||
| if ($this->characterEncoding) { | if ($this->characterEncoding) { | ||||
| $skip_cache = true; | $skip_cache = true; | ||||
| } | } | ||||
| if ($this->highlightAs) { | $highlight_language = $viewstate->getHighlightLanguage(); | ||||
| if ($highlight_language !== null) { | |||||
| $skip_cache = true; | $skip_cache = true; | ||||
| } | } | ||||
| $changeset = $this->changeset; | $changeset = $this->changeset; | ||||
| if ($changeset->getFileType() != DifferentialChangeType::FILE_TEXT && | if ($changeset->getFileType() != DifferentialChangeType::FILE_TEXT && | ||||
| $changeset->getFileType() != DifferentialChangeType::FILE_SYMLINK) { | $changeset->getFileType() != DifferentialChangeType::FILE_SYMLINK) { | ||||
| ▲ Show 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | public function render( | ||||
| $render_pch = $this->shouldRenderPropertyChangeHeader($this->changeset); | $render_pch = $this->shouldRenderPropertyChangeHeader($this->changeset); | ||||
| $rows = max( | $rows = max( | ||||
| count($this->old), | count($this->old), | ||||
| count($this->new)); | count($this->new)); | ||||
| $renderer = $this->getRenderer() | $renderer = $this->getRenderer() | ||||
| ->setUser($this->getUser()) | ->setUser($this->getViewer()) | ||||
| ->setChangeset($this->changeset) | ->setChangeset($this->changeset) | ||||
| ->setRenderPropertyChangeHeader($render_pch) | ->setRenderPropertyChangeHeader($render_pch) | ||||
| ->setIsTopLevel($this->isTopLevel) | ->setIsTopLevel($this->isTopLevel) | ||||
| ->setOldRender($this->oldRender) | ->setOldRender($this->oldRender) | ||||
| ->setNewRender($this->newRender) | ->setNewRender($this->newRender) | ||||
| ->setHunkStartLines($this->hunkStartLines) | ->setHunkStartLines($this->hunkStartLines) | ||||
| ->setOldChangesetID($this->leftSideChangesetID) | ->setOldChangesetID($this->leftSideChangesetID) | ||||
| ->setNewChangesetID($this->rightSideChangesetID) | ->setNewChangesetID($this->rightSideChangesetID) | ||||
| ▲ Show 20 Lines • Show All 1,049 Lines • Show Last 20 Lines | |||||