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 @@ -8,9 +8,7 @@ if (!$this->book) { $book_name = $this->getConfig('name'); - $book = id(new DivinerLiveBook())->loadOneWhere( - 'name = %s', - $book_name); + $book = id(new DivinerLiveBook())->loadOneWhere('name = %s', $book_name); if (!$book) { $book = id(new DivinerLiveBook()) ->setName($book_name) @@ -19,9 +17,9 @@ } $book->setConfigurationData($this->getConfigurationData())->save(); - $this->book = $book; } + return $this->book; } @@ -75,7 +73,6 @@ protected function deleteDocumentsByHash(array $hashes) { $atom_table = new DivinerLiveAtom(); $symbol_table = new DivinerLiveSymbol(); - $conn_w = $symbol_table->establishConnection('w'); $strings = array(); @@ -149,7 +146,6 @@ public function findAtomByRef(DivinerAtomRef $ref) { // TODO: Actually implement this. - return null; } diff --git a/src/applications/diviner/publisher/DivinerPublisher.php b/src/applications/diviner/publisher/DivinerPublisher.php --- a/src/applications/diviner/publisher/DivinerPublisher.php +++ b/src/applications/diviner/publisher/DivinerPublisher.php @@ -10,51 +10,51 @@ private $symbolReverseMap; private $dropCaches; - public function setDropCaches($drop_caches) { + public final function setDropCaches($drop_caches) { $this->dropCaches = $drop_caches; return $this; } - public function setRenderer(DivinerRenderer $renderer) { + public final function setRenderer(DivinerRenderer $renderer) { $renderer->setPublisher($this); $this->renderer = $renderer; return $this; } - public function getRenderer() { + public final function getRenderer() { return $this->renderer; } - public function setConfig(array $config) { + public final function setConfig(array $config) { $this->config = $config; return $this; } - public function getConfig($key, $default = null) { + public final function getConfig($key, $default = null) { return idx($this->config, $key, $default); } - public function getConfigurationData() { + public final function getConfigurationData() { return $this->config; } - public function setAtomCache(DivinerAtomCache $cache) { + public final function setAtomCache(DivinerAtomCache $cache) { $this->atomCache = $cache; $graph_map = $this->atomCache->getGraphMap(); $this->atomGraphHashToNodeHashMap = array_flip($graph_map); return $this; } - protected function getAtomFromGraphHash($graph_hash) { + protected final function getAtomFromGraphHash($graph_hash) { if (empty($this->atomGraphHashToNodeHashMap[$graph_hash])) { - throw new Exception("No such atom '{$graph_hash}'!"); + throw new Exception(pht("No such atom '%s'!", $graph_hash)); } return $this->getAtomFromNodeHash( $this->atomGraphHashToNodeHashMap[$graph_hash]); } - protected function getAtomFromNodeHash($node_hash) { + protected final function getAtomFromNodeHash($node_hash) { if (empty($this->atomMap[$node_hash])) { $dict = $this->atomCache->getAtom($node_hash); $this->atomMap[$node_hash] = DivinerAtom::newFromDictionary($dict); @@ -62,7 +62,7 @@ return $this->atomMap[$node_hash]; } - protected function getSimilarAtoms(DivinerAtom $atom) { + protected final function getSimilarAtoms(DivinerAtom $atom) { if ($this->symbolReverseMap === null) { $rmap = array(); $smap = $this->atomCache->getSymbolMap(); @@ -75,7 +75,7 @@ $shash = $atom->getRef()->toHash(); if (empty($this->symbolReverseMap[$shash])) { - throw new Exception('Atom has no symbol map entry!'); + throw new Exception(pht('Atom has no symbol map entry!')); } $hashes = $this->symbolReverseMap[$shash]; @@ -91,10 +91,10 @@ /** * If a book contains multiple definitions of some atom, like some function - * "f()", we assign them an arbitrary (but fairly stable) order and publish - * them as "function/f/1/", "function/f/2/", etc., or similar. + * `f()`, we assign them an arbitrary (but fairly stable) order and publish + * them as `function/f/1/`, `function/f/2/`, etc., or similar. */ - protected function getAtomSimilarIndex(DivinerAtom $atom) { + protected final function getAtomSimilarIndex(DivinerAtom $atom) { $atoms = $this->getSimilarAtoms($atom); if (count($atoms) == 1) { return 0; @@ -108,16 +108,15 @@ $index++; } - throw new Exception('Expected to find atom while disambiguating!'); + throw new Exception(pht('Expected to find atom while disambiguating!')); } - abstract protected function loadAllPublishedHashes(); abstract protected function deleteDocumentsByHash(array $hashes); abstract protected function createDocumentsByHash(array $hashes); abstract public function findAtomByRef(DivinerAtomRef $ref); - final public function publishAtoms(array $hashes) { + public final function publishAtoms(array $hashes) { $existing = $this->loadAllPublishedHashes(); if ($this->dropCaches) { @@ -141,7 +140,7 @@ $this->createDocumentsByHash($created); } - protected function shouldGenerateDocumentForAtom(DivinerAtom $atom) { + protected final function shouldGenerateDocumentForAtom(DivinerAtom $atom) { switch ($atom->getType()) { case DivinerAtom::TYPE_METHOD: case DivinerAtom::TYPE_FILE: diff --git a/src/applications/diviner/publisher/DivinerStaticPublisher.php b/src/applications/diviner/publisher/DivinerStaticPublisher.php --- a/src/applications/diviner/publisher/DivinerStaticPublisher.php +++ b/src/applications/diviner/publisher/DivinerStaticPublisher.php @@ -59,7 +59,6 @@ protected function createDocumentsByHash(array $hashes) { $indexes = array(); - $cache = $this->getPublishCache(); foreach ($hashes as $hash) { @@ -89,7 +88,6 @@ } $this->publishIndex(); - $cache->writePathMap(); $cache->writeIndex(); } @@ -97,6 +95,7 @@ private function publishIndex() { $index = $this->getPublishCache()->getIndex(); $refs = array(); + foreach ($index as $hash => $dictionary) { $refs[$hash] = DivinerAtomRef::newFromDictionary($dictionary); }