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
|
|
|
|
2016-01-05 19:34:04 +01:00
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
$name = $request->getURIData('name');
|
2011-09-05 19:43:24 +02:00
|
|
|
|
2015-02-01 03:36:36 +01:00
|
|
|
$query = id(new DiffusionSymbolQuery())
|
2016-01-05 19:34:04 +01:00
|
|
|
->setViewer($viewer)
|
|
|
|
->setName($name);
|
2011-09-05 19:43:24 +02:00
|
|
|
|
2015-05-31 16:36:54 +02:00
|
|
|
if ($request->getStr('context')) {
|
2012-08-07 18:28:49 +02:00
|
|
|
$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();
|
|
|
|
|
2015-05-31 16:36:54 +02:00
|
|
|
|
|
|
|
$external_query = id(new DiffusionExternalSymbolQuery())
|
2016-01-05 19:34:04 +01:00
|
|
|
->withNames(array($name));
|
2015-05-31 16:36:54 +02:00
|
|
|
|
|
|
|
if ($request->getStr('context')) {
|
|
|
|
$external_query->withContexts(array($request->getStr('context')));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->getStr('type')) {
|
|
|
|
$external_query->withTypes(array($request->getStr('type')));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($request->getStr('lang')) {
|
|
|
|
$external_query->withLanguages(array($request->getStr('lang')));
|
|
|
|
}
|
|
|
|
|
2015-08-13 23:49:00 +02:00
|
|
|
$external_sources = id(new PhutilClassMapQuery())
|
2015-05-31 16:36:54 +02:00
|
|
|
->setAncestorClass('DiffusionExternalSymbolsSource')
|
2015-08-13 23:49:00 +02:00
|
|
|
->execute();
|
|
|
|
|
2015-05-31 16:36:54 +02:00
|
|
|
$results = array($symbols);
|
|
|
|
foreach ($external_sources as $source) {
|
|
|
|
$results[] = $source->executeQuery($external_query);
|
|
|
|
}
|
|
|
|
$symbols = array_mergev($results);
|
|
|
|
|
|
|
|
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.
|
|
|
|
$symbol = head($symbols);
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setIsExternal($symbol->isExternal())
|
|
|
|
->setURI($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
|
|
|
}
|
|
|
|
|
2011-09-05 19:43:24 +02:00
|
|
|
$rows = array();
|
|
|
|
foreach ($symbols as $symbol) {
|
2015-05-31 16:36:54 +02: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
|
|
|
|
2015-05-31 16:36:54 +02:00
|
|
|
if ($symbol->isExternal()) {
|
|
|
|
$source = $symbol->getSource();
|
|
|
|
$location = $symbol->getLocation();
|
|
|
|
} else {
|
|
|
|
$repo = $symbol->getRepository();
|
|
|
|
$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
|
|
|
|
2015-05-31 16:36:54 +02:00
|
|
|
$source = $repo->getMonogram();
|
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
|
|
|
}
|
2015-05-31 16:36:54 +02:00
|
|
|
$location = phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $href,
|
|
|
|
),
|
|
|
|
$location);
|
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(
|
2013-02-13 23:50:15 +01:00
|
|
|
$symbol->getSymbolType(),
|
|
|
|
$symbol->getSymbolContext(),
|
|
|
|
$symbol->getSymbolName(),
|
|
|
|
$symbol->getSymbolLanguage(),
|
2015-05-31 16:36:54 +02:00
|
|
|
$source,
|
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-31 16:36:54 +02:00
|
|
|
pht('Source'),
|
|
|
|
pht('Location'),
|
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
|
|
|
|
2016-01-05 19:34:04 +01:00
|
|
|
$panel = id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Similar Symbols'))
|
|
|
|
->setTable($table);
|
2011-09-05 19:43:24 +02:00
|
|
|
|
2016-01-05 19:34:04 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
|
|
$crumbs->addTextCrumb(pht('Find Symbol'));
|
|
|
|
|
|
|
|
return $this->newPage()
|
|
|
|
->setTitle(pht('Find Symbol'))
|
|
|
|
->setCrumbs($crumbs)
|
|
|
|
->appendChild($panel);
|
2011-09-05 19:43:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|