2011-09-05 19:43:24 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class DiffusionSymbolController extends DiffusionController {
|
2011-09-05 19:43:24 +02:00
|
|
|
|
|
|
|
private $name;
|
|
|
|
|
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->name = $data['name'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
|
|
|
$query = new DiffusionSymbolQuery();
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
$query->setName($this->name);
|
2011-09-05 19:43:24 +02:00
|
|
|
|
2012-08-07 18:28:49 +02:00
|
|
|
if ($request->getStr('context') !== null) {
|
|
|
|
$query->setContext($request->getStr('context'));
|
|
|
|
}
|
|
|
|
|
2011-09-05 19:43:24 +02:00
|
|
|
if ($request->getStr('type')) {
|
|
|
|
$query->setType($request->getStr('type'));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->getStr('lang')) {
|
|
|
|
$query->setLanguage($request->getStr('lang'));
|
|
|
|
}
|
|
|
|
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
if ($request->getStr('projects')) {
|
|
|
|
$phids = $request->getStr('projects');
|
|
|
|
$phids = explode(',', $phids);
|
|
|
|
$phids = array_filter($phids);
|
|
|
|
|
|
|
|
if ($phids) {
|
|
|
|
$projects = id(new PhabricatorRepositoryArcanistProject())
|
|
|
|
->loadAllWhere(
|
|
|
|
'phid IN (%Ls)',
|
|
|
|
$phids);
|
|
|
|
$projects = mpull($projects, 'getID');
|
|
|
|
if ($projects) {
|
|
|
|
$query->setProjectIDs($projects);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-21 18:39:33 +01:00
|
|
|
$query->needPaths(true);
|
|
|
|
$query->needArcanistProjects(true);
|
|
|
|
$query->needRepositories(true);
|
|
|
|
|
2011-09-05 19:43:24 +02:00
|
|
|
$symbols = $query->execute();
|
|
|
|
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
// For PHP builtins, jump to php.net documentation.
|
|
|
|
if ($request->getBool('jump') && count($symbols) == 0) {
|
2012-08-16 02:47:04 +02:00
|
|
|
if ($request->getStr('lang', 'php') == 'php') {
|
|
|
|
if ($request->getStr('type', 'function') == 'function') {
|
|
|
|
$functions = get_defined_functions();
|
|
|
|
if (in_array($this->name, $functions['internal'])) {
|
|
|
|
return id(new AphrontRedirectResponse())
|
2014-08-21 23:45:51 +02:00
|
|
|
->setIsExternal(true)
|
2012-08-16 02:47:04 +02:00
|
|
|
->setURI('http://www.php.net/function.'.$this->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($request->getStr('type', 'class') == 'class') {
|
|
|
|
if (class_exists($this->name, false) ||
|
|
|
|
interface_exists($this->name, false)) {
|
|
|
|
if (id(new ReflectionClass($this->name))->isInternal()) {
|
2012-03-21 20:18:05 +01:00
|
|
|
return id(new AphrontRedirectResponse())
|
2014-08-21 23:45:51 +02:00
|
|
|
->setIsExternal(true)
|
2012-08-16 02:47:04 +02:00
|
|
|
->setURI('http://www.php.net/class.'.$this->name);
|
2012-03-21 20:18:05 +01:00
|
|
|
}
|
2012-08-16 02:47:04 +02:00
|
|
|
}
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 19:43:24 +02:00
|
|
|
$rows = array();
|
|
|
|
foreach ($symbols as $symbol) {
|
2011-12-21 18:39:33 +01:00
|
|
|
$project = $symbol->getArcanistProject();
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
if ($project) {
|
|
|
|
$project_name = $project->getName();
|
|
|
|
} else {
|
|
|
|
$project_name = '-';
|
|
|
|
}
|
|
|
|
|
2013-02-13 23:50:15 +01:00
|
|
|
$file = $symbol->getPath();
|
|
|
|
$line = $symbol->getLineNumber();
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
|
2011-12-21 18:39:33 +01:00
|
|
|
$repo = $symbol->getRepository();
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
if ($repo) {
|
2011-12-21 18:39:33 +01:00
|
|
|
$href = $symbol->getURI();
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
|
|
|
|
if ($request->getBool('jump') && count($symbols) == 1) {
|
|
|
|
// If this is a clickthrough from Differential, just jump them
|
|
|
|
// straight to the target if we got a single hit.
|
|
|
|
return id(new AphrontRedirectResponse())->setURI($href);
|
|
|
|
}
|
|
|
|
|
2013-01-18 03:43:35 +01:00
|
|
|
$location = phutil_tag(
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $href,
|
|
|
|
),
|
2013-01-18 03:43:35 +01:00
|
|
|
$file.':'.$line);
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
} else if ($file) {
|
2013-02-13 23:50:15 +01:00
|
|
|
$location = $file.':'.$line;
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
} else {
|
|
|
|
$location = '?';
|
|
|
|
}
|
|
|
|
|
2011-09-05 19:43:24 +02:00
|
|
|
$rows[] = array(
|
2013-02-13 23:50:15 +01:00
|
|
|
$symbol->getSymbolType(),
|
|
|
|
$symbol->getSymbolContext(),
|
|
|
|
$symbol->getSymbolName(),
|
|
|
|
$symbol->getSymbolLanguage(),
|
|
|
|
$project_name,
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
$location,
|
2011-09-05 19:43:24 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$table = new AphrontTableView($rows);
|
|
|
|
$table->setHeaders(
|
|
|
|
array(
|
2013-05-11 17:23:19 +02:00
|
|
|
pht('Type'),
|
|
|
|
pht('Context'),
|
|
|
|
pht('Name'),
|
|
|
|
pht('Language'),
|
|
|
|
pht('Project'),
|
|
|
|
pht('File'),
|
2011-09-05 19:43:24 +02:00
|
|
|
));
|
|
|
|
$table->setColumnClasses(
|
|
|
|
array(
|
2012-08-07 18:28:49 +02:00
|
|
|
'',
|
2011-09-05 19:43:24 +02:00
|
|
|
'',
|
|
|
|
'pri',
|
|
|
|
'',
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
'',
|
|
|
|
'',
|
2011-09-05 19:43:24 +02:00
|
|
|
));
|
Tie all the pieces for symbol cross-references together
Summary:
This makes symbol cross-references work in Differential. You need to do a little
legwork but I'll document that once the change has baked for a little while.
Basically:
- Projects are annotated with indexed languages, and "shared library" projects
(for example, symbols in Phabricator should be searched for in Arcanist and
libphutil).
- When we render a changeset, we check if its language is an indexed one. If
it is, we invoke the decorator Javascript.
- The Javascript takes you to a lookup page, which either gives you a list of
matching symbols (if several match) or redirects you instantly to the
definition.
Test Plan: Clicked class and function symbols in a diff, got jumped into
sensible sorts of places in Diffusion.
Reviewers: jungejason, nh, tuomaspelkonen, aran
Reviewed By: jungejason
CC: aran, jungejason
Differential Revision: 980
2011-10-03 01:02:56 +02:00
|
|
|
$table->setNoDataString(
|
2014-06-09 20:36:49 +02:00
|
|
|
pht('No matching symbol could be found in any indexed project.'));
|
2011-09-05 19:43:24 +02:00
|
|
|
|
|
|
|
$panel = new AphrontPanelView();
|
2013-05-11 17:23:19 +02:00
|
|
|
$panel->setHeader(pht('Similar Symbols'));
|
2011-09-05 19:43:24 +02:00
|
|
|
$panel->appendChild($table);
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
return $this->buildApplicationPage(
|
2011-09-05 19:43:24 +02:00
|
|
|
array(
|
|
|
|
$panel,
|
|
|
|
),
|
|
|
|
array(
|
2013-05-11 17:23:19 +02:00
|
|
|
'title' => pht('Find Symbol'),
|
2011-09-05 19:43:24 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|