mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
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:
parent
293199b5d3
commit
0a3e49cd76
2 changed files with 44 additions and 0 deletions
|
@ -210,6 +210,38 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||
$rows = $this->buildDisplayRows($text_list, $rev_list, $blame_dict,
|
||||
$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(
|
||||
'table',
|
||||
array(
|
||||
|
@ -220,6 +252,7 @@ final class DiffusionBrowseFileController extends DiffusionController {
|
|||
'div',
|
||||
array(
|
||||
'style' => 'padding: 0 2em;',
|
||||
'id' => $id,
|
||||
),
|
||||
$corpus_table);
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ abstract class DiffusionRequest {
|
|||
protected $repositoryCommit;
|
||||
protected $repositoryCommitData;
|
||||
protected $stableCommitName;
|
||||
protected $arcanistProjects;
|
||||
|
||||
abstract protected function getSupportsBranches();
|
||||
abstract protected function didInitialize();
|
||||
|
@ -235,6 +236,16 @@ abstract class DiffusionRequest {
|
|||
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() {
|
||||
if (empty($this->repositoryCommitData)) {
|
||||
$commit = $this->loadCommit();
|
||||
|
|
Loading…
Reference in a new issue