From 7f98e3a8bdad181dd98544ba22a6b4eb68300e9e Mon Sep 17 00:00:00 2001 From: Alan Huang Date: Tue, 7 Aug 2012 09:29:34 -0700 Subject: [PATCH] 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 --- .../ConduitAPI_diffusion_findsymbols_Method.php | 6 ++++++ .../search/engine/PhabricatorJumpNavHandler.php | 9 ++++++++- src/docs/userguide/diffusion_symbols.diviner | 17 +++++++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/applications/conduit/method/diffusion/ConduitAPI_diffusion_findsymbols_Method.php b/src/applications/conduit/method/diffusion/ConduitAPI_diffusion_findsymbols_Method.php index e818063df8..eebf2dce39 100644 --- a/src/applications/conduit/method/diffusion/ConduitAPI_diffusion_findsymbols_Method.php +++ b/src/applications/conduit/method/diffusion/ConduitAPI_diffusion_findsymbols_Method.php @@ -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(), diff --git a/src/applications/search/engine/PhabricatorJumpNavHandler.php b/src/applications/search/engine/PhabricatorJumpNavHandler.php index 5dc911b822..8daa95b03e 100644 --- a/src/applications/search/engine/PhabricatorJumpNavHandler.php +++ b/src/applications/search/engine/PhabricatorJumpNavHandler.php @@ -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=' diff --git a/src/docs/userguide/diffusion_symbols.diviner b/src/docs/userguide/diffusion_symbols.diviner index f0f0131960..3ca381bac1 100644 --- a/src/docs/userguide/diffusion_symbols.diviner +++ b/src/docs/userguide/diffusion_symbols.diviner @@ -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: - + 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 #### 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.