Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15417648
D9904.id23774.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D9904.id23774.diff
View Options
diff --git a/resources/sql/autopatches/20140711.diviner.1.sql b/resources/sql/autopatches/20140711.diviner.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140711.diviner.1.sql
@@ -0,0 +1,8 @@
+ALTER TABLE {$NAMESPACE}_diviner.diviner_livesymbol
+ CHANGE title displayName LONGTEXT COLLATE utf8_general_ci;
+
+ALTER TABLE {$NAMESPACE}_diviner.diviner_livesymbol
+ ADD displayContext LONGTEXT COLLATE utf8_general_ci AFTER context;
+
+ALTER TABLE {$NAMESPACE}_diviner.diviner_livesymbol
+ ADD language VARCHAR(32) COLLATE utf8_bin AFTER bookPHID;
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
@@ -322,17 +322,16 @@
}
public function getRef() {
- $title = null;
+ $display_name = null;
if ($this->docblockMeta) {
- $title = $this->getDocblockMetaValue('title');
+ $display_name = $this->getDocblockMetaValue('title');
}
return id(new DivinerAtomRef())
->setBook($this->getBook())
->setContext($this->getContext())
->setType($this->getType())
- ->setName($this->getName())
- ->setTitle($title)
+ ->setName($this->getName(), $display_name)
->setGroup($this->getProperty('group'));
}
diff --git a/src/applications/diviner/atom/DivinerAtomRef.php b/src/applications/diviner/atom/DivinerAtomRef.php
--- a/src/applications/diviner/atom/DivinerAtomRef.php
+++ b/src/applications/diviner/atom/DivinerAtomRef.php
@@ -6,10 +6,10 @@
private $context;
private $type;
private $name;
+ private $displayName;
private $group;
private $summary;
private $index;
- private $title;
public function getSortKey() {
return implode(
@@ -41,7 +41,7 @@
return $this->summary;
}
- public function setName($name) {
+ public function setName($name, $display_name = null) {
$normal_name = self::normalizeString($name);
if (preg_match('/^@[0-9]+\z/', $normal_name)) {
throw new Exception(
@@ -49,6 +49,13 @@
"reserved for disambiguating atoms with similar names.");
}
$this->name = $normal_name;
+
+ if ($display_name !== null) {
+ $this->displayName = $display_name;
+ } else {
+ $this->displayName = $name;
+ }
+
return $this;
}
@@ -71,6 +78,9 @@
} else {
$this->context = self::normalizeString($context);
}
+
+ $this->displayContext = $context;
+
return $this;
}
@@ -100,29 +110,25 @@
return $this->group;
}
- public function setTitle($title) {
- $this->title = $title;
- return $this;
- }
-
- public function getTitle() {
- return $this->title;
+ public function getDisplayName() {
+ return $this->displayName;
}
- public function getTitleSlug() {
- return self::normalizeTitleString($this->getTitle());
+ public function getDisplayContext() {
+ return $this->displayContext;
}
public function toDictionary() {
return array(
- 'book' => $this->getBook(),
+ 'book' => $this->getBook(),
'context' => $this->getContext(),
- 'type' => $this->getType(),
- 'name' => $this->getName(),
- 'group' => $this->getGroup(),
- 'index' => $this->getIndex(),
+ 'displayContext' => $this->getDisplayContext(),
+ 'type' => $this->getType(),
+ 'name' => $this->getName(),
+ 'displayName' => $this->getDisplayName(),
+ 'group' => $this->getGroup(),
+ 'index' => $this->getIndex(),
'summary' => $this->getSummary(),
- 'title' => $this->getTitle(),
);
}
@@ -132,7 +138,6 @@
unset($dict['group']);
unset($dict['index']);
unset($dict['summary']);
- unset($dict['title']);
ksort($dict);
return md5(serialize($dict)).'S';
@@ -141,13 +146,17 @@
public static function newFromDictionary(array $dict) {
$obj = new DivinerAtomRef();
$obj->setBook(idx($dict, 'book'));
- $obj->setContext(idx($dict, 'context'));
$obj->setType(idx($dict, 'type'));
- $obj->setName(idx($dict, 'name'));
+
+ $obj->context = idx($dict, 'context');
+ $obj->displayContext = idx($dict, 'displayContext');
+
+ $obj->name = idx($dict, 'name');
+ $obj->displayName = idx($dict, 'displayName');
+
$obj->group = idx($dict, 'group');
$obj->index = idx($dict, 'index');
$obj->summary = idx($dict, 'summary');
- $obj->title = idx($dict, 'title');
return $obj;
}
diff --git a/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php b/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php
--- a/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php
+++ b/src/applications/diviner/markup/DivinerRemarkupRuleSymbol.php
@@ -94,7 +94,7 @@
foreach ($data as $token => $ref_dict) {
$ref = DivinerAtomRef::newFromDictionary($ref_dict);
- $title = $ref->getTitle();
+ $display_name = $ref->getName();
$href = null;
if ($renderer) {
@@ -104,7 +104,7 @@
$ref = $renderer->normalizeAtomRef($ref);
if ($ref) {
- $title = nonempty($ref->getTitle(), $ref->getName());
+ $display_name = $ref->getDisplayName();
$href = $renderer->getHrefForAtomRef($ref);
}
} else {
@@ -128,16 +128,17 @@
switch ($ref->getType()) {
case 'function':
case 'method':
- $title = $title.'()';
+ $display_name = $display_name.'()';
break;
}
}
if ($this->getEngine()->isTextMode()) {
if ($href) {
- $link = $title.' <'.PhabricatorEnv::getProductionURI($href).'>';
+ $link = $display_name.
+ ' <'.PhabricatorEnv::getProductionURI($href).'>';
} else {
- $link = $title;
+ $link = $display_name;
}
} else if ($href) {
$link = $this->newTag(
@@ -146,14 +147,14 @@
'class' => 'atom-ref',
'href' => $href,
),
- $title);
+ $display_name);
} else {
$link = $this->newTag(
'span',
array(
'class' => 'atom-ref-invalid',
),
- $title);
+ $display_name);
}
$engine->overwriteStoredText($token, $link);
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
@@ -26,12 +26,14 @@
}
private function loadSymbolForAtom(DivinerAtom $atom) {
+ $ref = $atom->getRef();
+
$symbol = id(new DivinerAtomQuery())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withBookPHIDs(array($this->loadBook()->getPHID()))
->withTypes(array($atom->getType()))
- ->withNames(array($atom->getName()))
- ->withContexts(array($atom->getContext()))
+ ->withNames(array($ref->getName()))
+ ->withContexts(array($ref->getContext()))
->withIndexes(array($this->getAtomSimilarIndex($atom)))
->withIncludeUndocumentable(true)
->withIncludeGhosts(true)
@@ -44,8 +46,8 @@
return id(new DivinerLiveSymbol())
->setBookPHID($this->loadBook()->getPHID())
->setType($atom->getType())
- ->setName($atom->getName())
- ->setContext($atom->getContext())
+ ->setName($ref->getName())
+ ->setContext($ref->getContext())
->setAtomIndex($this->getAtomSimilarIndex($atom));
}
@@ -111,9 +113,11 @@
$is_documentable = $this->shouldGenerateDocumentForAtom($atom);
$symbol
+ ->setDisplayName($ref->getDisplayName())
+ ->setDisplayContext($ref->getDisplayContext())
+ ->setLanguage($atom->getLanguage())
->setGraphHash($hash)
->setIsDocumentable((int)$is_documentable)
- ->setTitle($ref->getTitle())
->setGroupName($ref->getGroup())
->setNodeHash($atom->getHash());
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
@@ -4,15 +4,18 @@
implements PhabricatorPolicyInterface, PhabricatorMarkupInterface {
protected $bookPHID;
+ protected $language;
protected $context;
+ protected $displayContext;
protected $type;
protected $name;
+ protected $displayName;
+
protected $atomIndex;
protected $graphHash;
protected $identityHash;
protected $nodeHash;
- protected $title;
protected $titleSlugHash;
protected $groupName;
protected $summary;
@@ -79,7 +82,7 @@
return sprintf(
'%c:%s',
($this->getType() == DivinerAtom::TYPE_ARTICLE ? '0' : '1'),
- phutil_utf8_strtolower($this->getTitle()));
+ phutil_utf8_strtolower($this->getDisplayName()));
}
public function save() {
@@ -104,15 +107,15 @@
}
public function getTitle() {
- $title = parent::getTitle();
+ $title = $this->getDisplayName();
if (!strlen($title)) {
$title = $this->getName();
}
return $title;
}
- public function setTitle($value) {
- $this->writeField('title', $value);
+ public function setDisplayName($value) {
+ $this->writeField('displayName', $value);
if (strlen($value)) {
$slug = DivinerAtomRef::normalizeTitleString($value);
$hash = PhabricatorHash::digestForIndex($slug);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 21, 5:46 PM (1 d, 12 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7382389
Default Alt Text
D9904.id23774.diff (9 KB)
Attached To
Mode
D9904: Separate display name/context from normalized name/context in Diviner
Attached
Detach File
Event Timeline
Log In to Comment