Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15559969
D9791.id23502.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D9791.id23502.diff
View Options
diff --git a/src/applications/diviner/application/PhabricatorApplicationDiviner.php b/src/applications/diviner/application/PhabricatorApplicationDiviner.php
--- a/src/applications/diviner/application/PhabricatorApplicationDiviner.php
+++ b/src/applications/diviner/application/PhabricatorApplicationDiviner.php
@@ -29,7 +29,7 @@
'/book/'.
'(?P<book>[^/]+)/'.
'(?P<type>[^/]+)/'.
- '(?:(?P<context>[^/]+)/)?'.
+ '(?P<context>[^/]+)/'.
'(?P<name>[^/]+)/'.
'(?:(?P<index>\d+)/)?' => 'DivinerAtomController',
);
diff --git a/src/applications/diviner/atom/DivinerAtom.php b/src/applications/diviner/atom/DivinerAtom.php
--- a/src/applications/diviner/atom/DivinerAtom.php
+++ b/src/applications/diviner/atom/DivinerAtom.php
@@ -294,6 +294,13 @@
return implode('/', $parts);
}
+ public function getNormalizedContext() {
+ $context = $this->getContext();
+ if (!$context) {
+ return $context;
+ }
+ return rtrim(str_replace('\\', ':', $context), ':');
+ }
public function toDictionary() {
// NOTE: If you change this format, bump the format version in
diff --git a/src/applications/diviner/controller/DivinerAtomController.php b/src/applications/diviner/controller/DivinerAtomController.php
--- a/src/applications/diviner/controller/DivinerAtomController.php
+++ b/src/applications/diviner/controller/DivinerAtomController.php
@@ -16,7 +16,7 @@
$this->bookName = $data['book'];
$this->atomType = $data['type'];
$this->atomName = $data['name'];
- $this->atomContext = nonempty(idx($data, 'context'), null);
+ $this->atomContext = $data['context'];
$this->atomIndex = nonempty(idx($data, 'index'), null);
}
@@ -513,6 +513,17 @@
break;
}
+ switch ($symbol->getType()) {
+ case DivinerAtom::TYPE_CLASS:
+ case DivinerAtom::TYPE_INTERFACE:
+ case DivinerAtom::TYPE_FUNCTION:
+ $name = $symbol->getAtom()->getContext().$symbol->getName();
+ break;
+ default:
+ $name = $symbol->getName();
+ break;
+ }
+
$out[] = phutil_tag(
$anchor ? 'a' : 'span',
array(
@@ -520,7 +531,7 @@
'href' => $anchor ? '#'.$anchor : null,
'name' => $is_link ? null : $anchor,
),
- $symbol->getName());
+ $name);
$out = phutil_implode_html(' ', $out);
diff --git a/src/applications/diviner/controller/DivinerBookController.php b/src/applications/diviner/controller/DivinerBookController.php
--- a/src/applications/diviner/controller/DivinerBookController.php
+++ b/src/applications/diviner/controller/DivinerBookController.php
@@ -43,6 +43,7 @@
$properties = $this->buildPropertyList($book);
$atoms = id(new DivinerAtomQuery())
+ ->needAtoms(true)
->setViewer($viewer)
->withBookPHIDs(array($book->getPHID()))
->execute();
diff --git a/src/applications/diviner/controller/DivinerController.php b/src/applications/diviner/controller/DivinerController.php
--- a/src/applications/diviner/controller/DivinerController.php
+++ b/src/applications/diviner/controller/DivinerController.php
@@ -30,17 +30,23 @@
$list = array();
foreach ($symbols as $symbol) {
+ $context = '';
switch ($symbol->getType()) {
case DivinerAtom::TYPE_FUNCTION:
$title = $symbol->getTitle().'()';
+ $context = $symbol->getAtom()->getContext();
break;
+ case DivinerAtom::TYPE_CLASS:
+ case DivinerAtom::TYPE_INTERFACE:
+ $context = $symbol->getAtom()->getContext();
+ // fall through
default:
$title = $symbol->getTitle();
break;
}
$item = id(new DivinerBookItemView())
- ->setTitle($title)
+ ->setTitle($context.$title)
->setHref($symbol->getURI())
->setSubtitle($symbol->getSummary())
->setType(DivinerAtom::getAtomTypeNameString(
diff --git a/src/applications/diviner/publisher/DivinerLivePublisher.php b/src/applications/diviner/publisher/DivinerLivePublisher.php
--- a/src/applications/diviner/publisher/DivinerLivePublisher.php
+++ b/src/applications/diviner/publisher/DivinerLivePublisher.php
@@ -31,7 +31,7 @@
->withBookPHIDs(array($this->loadBook()->getPHID()))
->withTypes(array($atom->getType()))
->withNames(array($atom->getName()))
- ->withContexts(array($atom->getContext()))
+ ->withContexts(array($atom->getNormalizedContext()))
->withIndexes(array($this->getAtomSimilarIndex($atom)))
->withIncludeUndocumentable(true)
->withIncludeGhosts(true)
@@ -45,7 +45,7 @@
->setBookPHID($this->loadBook()->getPHID())
->setType($atom->getType())
->setName($atom->getName())
- ->setContext($atom->getContext())
+ ->setContext($atom->getNormalizedContext())
->setAtomIndex($this->getAtomSimilarIndex($atom));
}
diff --git a/src/applications/diviner/query/DivinerAtomQuery.php b/src/applications/diviner/query/DivinerAtomQuery.php
--- a/src/applications/diviner/query/DivinerAtomQuery.php
+++ b/src/applications/diviner/query/DivinerAtomQuery.php
@@ -46,6 +46,12 @@
}
public function withContexts(array $contexts) {
+
+ foreach ($contexts as $i => $context) {
+ if ($context === ':') {
+ unset($contexts[$i]);
+ }
+ }
$this->contexts = $contexts;
return $this;
}
diff --git a/src/applications/diviner/storage/DivinerLiveSymbol.php b/src/applications/diviner/storage/DivinerLiveSymbol.php
--- a/src/applications/diviner/storage/DivinerLiveSymbol.php
+++ b/src/applications/diviner/storage/DivinerLiveSymbol.php
@@ -63,6 +63,9 @@
if ($this->getContext()) {
$parts[] = $this->getContext();
}
+ else {
+ $parts[] = ':';
+ }
$parts[] = $this->getName();
@@ -79,7 +82,7 @@
return sprintf(
'%c:%s',
($this->getType() == DivinerAtom::TYPE_ARTICLE ? '0' : '1'),
- phutil_utf8_strtolower($this->getTitle()));
+ phutil_utf8_strtolower($this->getContext().$this->getTitle()));
}
public function save() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 30, 12:14 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7360366
Default Alt Text
D9791.id23502.diff (5 KB)
Attached To
Mode
D9791: Get diviner to correctly handle contexts
Attached
Detach File
Event Timeline
Log In to Comment