mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Update Phabricator for split syntax highlighting API
Summary: I'll clean some of this stuff up in a followup too, but update the callers to use the new explicit filename-based API. Test Plan: Looked at paste, Diffusion and Differential. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, codeblock, jungejason, aran CC: aran, tuomaspelkonen Differential Revision: 600
This commit is contained in:
parent
f123abcc5a
commit
70cd8b1b34
3 changed files with 21 additions and 14 deletions
|
@ -27,7 +27,6 @@ class DifferentialChangesetParser {
|
||||||
protected $parsedHunk = false;
|
protected $parsedHunk = false;
|
||||||
|
|
||||||
protected $filename = null;
|
protected $filename = null;
|
||||||
protected $filetype = null;
|
|
||||||
protected $missingOld = array();
|
protected $missingOld = array();
|
||||||
protected $missingNew = array();
|
protected $missingNew = array();
|
||||||
|
|
||||||
|
@ -161,10 +160,7 @@ class DifferentialChangesetParser {
|
||||||
|
|
||||||
public function setFilename($filename) {
|
public function setFilename($filename) {
|
||||||
$this->filename = $filename;
|
$this->filename = $filename;
|
||||||
if (strpos($filename, '.', 1) !== false) {
|
return $this;
|
||||||
$parts = explode('.', $filename);
|
|
||||||
$this->filetype = end($parts);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setHandles(array $handles) {
|
public function setHandles(array $handles) {
|
||||||
|
@ -723,7 +719,7 @@ class DifferentialChangesetParser {
|
||||||
|
|
||||||
protected function getHighlightFuture($corpus) {
|
protected function getHighlightFuture($corpus) {
|
||||||
return $this->highlightEngine->getHighlightFuture(
|
return $this->highlightEngine->getHighlightFuture(
|
||||||
$this->filetype,
|
$this->highlightEngine->getLanguageFromFilename($this->filename),
|
||||||
$corpus);
|
$corpus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,13 +179,16 @@ class DiffusionBrowseFileController extends DiffusionController {
|
||||||
|
|
||||||
list($text_list, $rev_list, $blame_dict) = $file_query->getBlameData();
|
list($text_list, $rev_list, $blame_dict) = $file_query->getBlameData();
|
||||||
|
|
||||||
$highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
|
$highlight_engine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||||
$highlightEngine->setConfig(
|
$highlight_engine->setConfig(
|
||||||
'pygments.enabled',
|
'pygments.enabled',
|
||||||
PhabricatorEnv::getEnvConfig('pygments.enabled'));
|
PhabricatorEnv::getEnvConfig('pygments.enabled'));
|
||||||
|
|
||||||
$text_list = explode("\n", $highlightEngine->highlightSource($path,
|
$text_list = explode(
|
||||||
implode("\n", $text_list)));
|
"\n",
|
||||||
|
$highlight_engine->highlightSource(
|
||||||
|
$highlight_engine->getLanguageFromFilename($path),
|
||||||
|
implode("\n", $text_list)));
|
||||||
|
|
||||||
$rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict,
|
$rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict,
|
||||||
$needs_blame, $drequest, $file_query, $selected);
|
$needs_blame, $drequest, $file_query, $selected);
|
||||||
|
|
|
@ -89,14 +89,22 @@ class PhabricatorPasteViewController extends PhabricatorPasteController {
|
||||||
require_celerity_resource('diffusion-source-css');
|
require_celerity_resource('diffusion-source-css');
|
||||||
require_celerity_resource('syntax-highlighting-css');
|
require_celerity_resource('syntax-highlighting-css');
|
||||||
|
|
||||||
$highlightEngine = new PhutilDefaultSyntaxHighlighterEngine();
|
$highlight_engine = new PhutilDefaultSyntaxHighlighterEngine();
|
||||||
$highlightEngine->setConfig(
|
$highlight_engine->setConfig(
|
||||||
'pygments.enabled',
|
'pygments.enabled',
|
||||||
PhabricatorEnv::getEnvConfig('pygments.enabled'));
|
PhabricatorEnv::getEnvConfig('pygments.enabled'));
|
||||||
|
|
||||||
|
|
||||||
|
$language = $paste->getLanguage();
|
||||||
|
if (empty($language)) {
|
||||||
|
$language = $highlight_engine->getLanguageFromFilename(
|
||||||
|
$paste->getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
$text_list = explode(
|
$text_list = explode(
|
||||||
"\n", $highlightEngine->highlightSource(
|
"\n",
|
||||||
nonempty($paste->getLanguage(), $paste->getTitle()),
|
$highlight_engine->highlightSource(
|
||||||
|
$language,
|
||||||
$file->loadFileData()));
|
$file->loadFileData()));
|
||||||
|
|
||||||
$rows = $this->buildDisplayRows($text_list);
|
$rows = $this->buildDisplayRows($text_list);
|
||||||
|
|
Loading…
Reference in a new issue