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;
|
|
|
|
|
2015-01-09 22:29:08 +01:00
|
|
|
protected function processDiffusionRequest(AphrontRequest $request) {
|
2011-09-05 19:43:24 +02:00
|
|
|
$user = $request->getUser();
|
2015-01-09 22:29:08 +01:00
|
|
|
$this->name = $request->getURIData('name');
|
2011-09-05 19:43:24 +02:00
|
|
|
|
2015-02-01 03:36:36 +01:00
|
|
|
$query = id(new DiffusionSymbolQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->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'));
|
|
|
|
}
|
|
|
|
|
2015-05-03 02:11:17 +02:00
|
|
|
if ($request->getStr('repositories')) {
|
|
|
|
$phids = $request->getStr('repositories');
|
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
|
|
|
$phids = explode(',', $phids);
|
|
|
|
$phids = array_filter($phids);
|
|
|
|
|
|
|
|
if ($phids) {
|
2015-05-03 02:11:17 +02:00
|
|
|
$repos = id(new PhabricatorRepositoryQuery())
|
|
|
|
->setViewer($request->getUser())
|
|
|
|
->withPHIDs($phids)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
$repos = mpull($repos, 'getPHID');
|
|
|
|
if ($repos) {
|
|
|
|
$query->withRepositoryPHIDs($repos);
|
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
|
|
|
$query->needPaths(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) {
|
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(),
|
2015-05-03 02:11:17 +02:00
|
|
|
$repo->getMonogram(),
|
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'),
|
2015-05-03 02:11:17 +02:00
|
|
|
pht('Repository'),
|
2013-05-11 17:23:19 +02:00
|
|
|
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(
|
2015-05-18 15:29:47 +02:00
|
|
|
pht('No matching symbol could be found in any indexed repository.'));
|
2011-09-05 19:43:24 +02:00
|
|
|
|
2015-03-07 00:32:12 +01:00
|
|
|
$panel = new PHUIObjectBoxView();
|
|
|
|
$panel->setHeaderText(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(
|
2015-03-07 00:32:12 +01:00
|
|
|
$panel,
|
2011-09-05 19:43:24 +02:00
|
|
|
array(
|
2013-05-11 17:23:19 +02:00
|
|
|
'title' => pht('Find Symbol'),
|
2011-09-05 19:43:24 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|