Page MenuHomePhabricator

D18937.diff
No OneTemporary

D18937.diff

diff --git a/src/applications/diffusion/controller/DiffusionSymbolController.php b/src/applications/diffusion/controller/DiffusionSymbolController.php
--- a/src/applications/diffusion/controller/DiffusionSymbolController.php
+++ b/src/applications/diffusion/controller/DiffusionSymbolController.php
@@ -22,6 +22,7 @@
$query->setLanguage($request->getStr('lang'));
}
+ $repos = array();
if ($request->getStr('repositories')) {
$phids = $request->getStr('repositories');
$phids = explode(',', $phids);
@@ -33,9 +34,9 @@
->withPHIDs($phids)
->execute();
- $repos = mpull($repos, 'getPHID');
- if ($repos) {
- $query->withRepositoryPHIDs($repos);
+ $repo_phids = mpull($repos, 'getPHID');
+ if ($repo_phids) {
+ $query->withRepositoryPHIDs($repo_phids);
}
}
}
@@ -45,7 +46,6 @@
$symbols = $query->execute();
-
$external_query = id(new DiffusionExternalSymbolQuery())
->withNames(array($name));
@@ -61,13 +61,44 @@
$external_query->withLanguages(array($request->getStr('lang')));
}
+ if ($request->getStr('path')) {
+ $external_query->withPaths(array($request->getStr('path')));
+ }
+
+ if ($request->getInt('line')) {
+ $external_query->withLines(array($request->getInt('line')));
+ }
+
+ if ($repos) {
+ $external_query->withRepositories($repos);
+ }
+
$external_sources = id(new PhutilClassMapQuery())
->setAncestorClass('DiffusionExternalSymbolsSource')
->execute();
$results = array($symbols);
foreach ($external_sources as $source) {
- $results[] = $source->executeQuery($external_query);
+ $source_results = $source->executeQuery($external_query);
+
+ if (!is_array($source_results)) {
+ throw new Exception(
+ pht(
+ 'Expected a list of results from external symbol source "%s".',
+ get_class($source)));
+ }
+
+ try {
+ assert_instances_of($source_results, 'PhabricatorRepositorySymbol');
+ } catch (InvalidArgumentException $ex) {
+ throw new Exception(
+ pht(
+ 'Expected a list of PhabricatorRepositorySymbol objects '.
+ 'from external symbol source "%s".',
+ get_class($source)));
+ }
+
+ $results[] = $source_results;
}
$symbols = array_mergev($results);
diff --git a/src/applications/diffusion/symbol/DiffusionExternalSymbolQuery.php b/src/applications/diffusion/symbol/DiffusionExternalSymbolQuery.php
--- a/src/applications/diffusion/symbol/DiffusionExternalSymbolQuery.php
+++ b/src/applications/diffusion/symbol/DiffusionExternalSymbolQuery.php
@@ -1,45 +1,83 @@
<?php
final class DiffusionExternalSymbolQuery extends Phobject {
+
private $languages = array();
private $types = array();
private $names = array();
private $contexts = array();
+ private $paths = array();
+ private $lines = array();
+ private $repositories = array();
public function withLanguages(array $languages) {
$this->languages = $languages;
return $this;
}
+
public function withTypes(array $types) {
$this->types = $types;
return $this;
}
+
public function withNames(array $names) {
$this->names = $names;
return $this;
}
+
public function withContexts(array $contexts) {
$this->contexts = $contexts;
return $this;
}
+ public function withPaths(array $paths) {
+ $this->paths = $paths;
+ return $this;
+ }
+
+ public function withLines(array $lines) {
+ $this->lines = $lines;
+ return $this;
+ }
+
+ public function withRepositories(array $repositories) {
+ assert_instances_of($repositories, 'PhabricatorRepository');
+ $this->repositories = $repositories;
+ return $this;
+ }
public function getLanguages() {
return $this->languages;
}
+
public function getTypes() {
return $this->types;
}
+
public function getNames() {
return $this->names;
}
+
public function getContexts() {
return $this->contexts;
}
+ public function getPaths() {
+ return $this->paths;
+ }
+
+ public function getLines() {
+ return $this->lines;
+ }
+
+ public function getRepositories() {
+ return $this->repositories;
+ }
+
public function matchesAnyLanguage(array $languages) {
return (!$this->languages) || array_intersect($languages, $this->languages);
}
+
public function matchesAnyType(array $types) {
return (!$this->types) || array_intersect($types, $this->types);
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 16, 11:14 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7654000
Default Alt Text
D18937.diff (4 KB)

Event Timeline