1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 14:00:56 +01:00

Miscellaneous updates for scoped symbols

Summary: Update Conduit, jump nav, and docs to handle symbol contexts.

Test Plan: Call conduit, use jump nav.

Reviewers: epriestley

Reviewed By: epriestley

CC: nh, aran, Korvin

Maniphest Tasks: T1602

Differential Revision: https://secure.phabricator.com/D3172
This commit is contained in:
Alan Huang 2012-08-07 09:29:34 -07:00
parent a8d6af0f42
commit 7f98e3a8bd
3 changed files with 25 additions and 7 deletions

View file

@ -30,6 +30,7 @@ final class ConduitAPI_diffusion_findsymbols_Method
return array(
'name' => 'optional string',
'namePrefix' => 'optional string',
'context' => 'optional string',
'language' => 'optional string',
'type' => 'optional string',
);
@ -47,6 +48,7 @@ final class ConduitAPI_diffusion_findsymbols_Method
protected function execute(ConduitAPIRequest $request) {
$name = $request->getValue('name');
$name_prefix = $request->getValue('namePrefix');
$context = $request->getValue('context');
$language = $request->getValue('language');
$type = $request->getValue('type');
@ -57,6 +59,9 @@ final class ConduitAPI_diffusion_findsymbols_Method
if ($name_prefix !== null) {
$query->setNamePrefix($name_prefix);
}
if ($context !== null) {
$query->setContext($context);
}
if ($language !== null) {
$query->setLanguage($language);
}
@ -80,6 +85,7 @@ final class ConduitAPI_diffusion_findsymbols_Method
$response[] = array(
'name' => $result->getSymbolName(),
'context' => $result->getSymbolContext(),
'type' => $result->getSymbolType(),
'language' => $result->getSymbolLanguage(),
'path' => $result->getPath(),

View file

@ -75,8 +75,15 @@ final class PhabricatorJumpNavHandler {
}
break;
case 'find-symbol':
$context = '';
$symbol = $matches[1];
$parts = array();
if (preg_match('/(.*)(?:\\.|::|->)(.*)/', $symbol, $parts)) {
$context = '&context='.phutil_escape_uri($parts[1]);
$symbol = $parts[2];
}
return id(new AphrontRedirectResponse())
->setURI('/diffusion/symbol/'.$matches[1].'/?jump=true');
->setURI("/diffusion/symbol/$symbol/?jump=true$context");
case 'create-task':
return id(new AphrontRedirectResponse())
->setURI('/maniphest/task/create/?title='

View file

@ -38,16 +38,21 @@ script which can export them (for example, maybe by parsing a ##ctags## file).
The output format of the script should be one symbol per line:
<name> <type> <lang> <line> <path>
<context> <name> <type> <lang> <line> <path>
For example:
ExampleClass class php 13 /src/classes/ExampleClass.php
ExampleClass exampleMethod function php 13 /src/classes/ExampleClass.php
Context is, broadly speaking, the scope or namespace where the symbol is
defined. For object-oriented languages, this is probably a class name. The
symbols with that context are class constants, methods, properties, nested
classes, etc. When printing symbols without a context (those that are defined
globally, for instance), the ##<context>## field should be empty (that is, the
line should start with a space).
Your script should enumerate all the symbols in your project, and provide paths
from the project root (where ".arcconfig" is) beginning with a "/". If there are
any duplicate symbols, it should include logic to pick the "best" one -- symbol
names must be unique within a project, type and language.
from the project root (where ".arcconfig" is) beginning with a "/".
You can look at ##generate_php_symbols.php## for an example of how you might
write such a script, and run this command to see its output:
@ -87,4 +92,4 @@ automatically link symbols in Differential.
NOTE: Because this feature depends on the syntax highlighter, it will work
better for some languages than others. It currently works fairly well for PHP,
but your milage may vary for other languages.
but your mileage may vary for other languages.