Show cross-references in diffusion
Summary: We do this in differential. To do this in diffusion, we need to know the arcanist project (which I do by loading all possible projects for the repository) and the language. Test Plan: load a php file in diffusion to see crossreferences; load a text file and check darkconsole that it didn't try to crossreference. Reviewers: epriestley, vrana, jungejason Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3020
This commit is contained in:
@@ -210,6 +210,38 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||||||
$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);
|
||||||
|
|
||||||
|
$id = celerity_generate_unique_node_id();
|
||||||
|
|
||||||
|
$projects = $drequest->loadArcanistProjects();
|
||||||
|
$langs = array();
|
||||||
|
foreach ($projects as $project) {
|
||||||
|
$ls = $project->getSymbolIndexLanguages();
|
||||||
|
if (!$ls) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$dep_projects = $project->getSymbolIndexProjects();
|
||||||
|
$dep_projects = mpull($dep_projects, 'getPHID');
|
||||||
|
$dep_projects[] = $project->getPHID();
|
||||||
|
foreach ($ls as $lang) {
|
||||||
|
if (!isset($langs[$lang])) {
|
||||||
|
$langs[$lang] = array();
|
||||||
|
}
|
||||||
|
$langs[$lang] += $dep_projects + array($project);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$lang = last(explode('.', $drequest->getPath()));
|
||||||
|
|
||||||
|
if (isset($langs[$lang])) {
|
||||||
|
Javelin::initBehavior(
|
||||||
|
'repository-crossreference',
|
||||||
|
array(
|
||||||
|
'container' => $id,
|
||||||
|
'lang' => $lang,
|
||||||
|
'projects' => $langs[$lang],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
$corpus_table = phutil_render_tag(
|
$corpus_table = phutil_render_tag(
|
||||||
'table',
|
'table',
|
||||||
array(
|
array(
|
||||||
@@ -220,6 +252,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||||||
'div',
|
'div',
|
||||||
array(
|
array(
|
||||||
'style' => 'padding: 0 2em;',
|
'style' => 'padding: 0 2em;',
|
||||||
|
'id' => $id,
|
||||||
),
|
),
|
||||||
$corpus_table);
|
$corpus_table);
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ abstract class DiffusionRequest {
|
|||||||
protected $repositoryCommit;
|
protected $repositoryCommit;
|
||||||
protected $repositoryCommitData;
|
protected $repositoryCommitData;
|
||||||
protected $stableCommitName;
|
protected $stableCommitName;
|
||||||
|
protected $arcanistProjects;
|
||||||
|
|
||||||
abstract protected function getSupportsBranches();
|
abstract protected function getSupportsBranches();
|
||||||
abstract protected function didInitialize();
|
abstract protected function didInitialize();
|
||||||
@@ -235,6 +236,16 @@ abstract class DiffusionRequest {
|
|||||||
return $this->repositoryCommit;
|
return $this->repositoryCommit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadArcanistProjects() {
|
||||||
|
if (empty($this->arcanistProjects)) {
|
||||||
|
$projects = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere(
|
||||||
|
'repositoryID = %d',
|
||||||
|
$this->getRepository()->getID());
|
||||||
|
$this->arcanistProjects = $projects;
|
||||||
|
}
|
||||||
|
return $this->arcanistProjects;
|
||||||
|
}
|
||||||
|
|
||||||
public function loadCommitData() {
|
public function loadCommitData() {
|
||||||
if (empty($this->repositoryCommitData)) {
|
if (empty($this->repositoryCommitData)) {
|
||||||
$commit = $this->loadCommit();
|
$commit = $this->loadCommit();
|
||||||
|
|||||||
Reference in New Issue
Block a user