10
10
private $symbolReverseMap;
11
11
private $dropCaches;
13
public final function setDropCaches($drop_caches) {
13
final public function setDropCaches($drop_caches) {
14
14
$this->dropCaches = $drop_caches;
18
public final function setRenderer(DivinerRenderer $renderer) {
18
final public function setRenderer(DivinerRenderer $renderer) {
19
19
$renderer->setPublisher($this);
20
20
$this->renderer = $renderer;
24
public final function getRenderer() {
24
final public function getRenderer() {
25
25
return $this->renderer;
28
public final function setConfig(array $config) {
28
final public function setConfig(array $config) {
29
29
$this->config = $config;
33
public final function getConfig($key, $default = null) {
33
final public function getConfig($key, $default = null) {
34
34
return idx($this->config, $key, $default);
37
public final function getConfigurationData() {
37
final public function getConfigurationData() {
38
38
return $this->config;
41
public final function setAtomCache(DivinerAtomCache $cache) {
41
final public function setAtomCache(DivinerAtomCache $cache) {
42
42
$this->atomCache = $cache;
43
43
$graph_map = $this->atomCache->getGraphMap();
44
44
$this->atomGraphHashToNodeHashMap = array_flip($graph_map);
48
protected final function getAtomFromGraphHash($graph_hash) {
48
final protected function getAtomFromGraphHash($graph_hash) {
49
49
if (empty($this->atomGraphHashToNodeHashMap[$graph_hash])) {
50
50
throw new Exception(pht("No such atom '%s'!", $graph_hash));
54
54
$this->atomGraphHashToNodeHashMap[$graph_hash]);
57
protected final function getAtomFromNodeHash($node_hash) {
57
final protected function getAtomFromNodeHash($node_hash) {
58
58
if (empty($this->atomMap[$node_hash])) {
59
59
$dict = $this->atomCache->getAtom($node_hash);
60
60
$this->atomMap[$node_hash] = DivinerAtom::newFromDictionary($dict);
62
62
return $this->atomMap[$node_hash];
65
protected final function getSimilarAtoms(DivinerAtom $atom) {
65
final protected function getSimilarAtoms(DivinerAtom $atom) {
66
66
if ($this->symbolReverseMap === null) {
68
68
$smap = $this->atomCache->getSymbolMap();
94
94
* `f()`, we assign them an arbitrary (but fairly stable) order and publish
95
95
* them as `function/f/1/`, `function/f/2/`, etc., or similar.
97
protected final function getAtomSimilarIndex(DivinerAtom $atom) {
97
final protected function getAtomSimilarIndex(DivinerAtom $atom) {
98
98
$atoms = $this->getSimilarAtoms($atom);
99
99
if (count($atoms) == 1) {
116
116
abstract protected function createDocumentsByHash(array $hashes);
117
117
abstract public function findAtomByRef(DivinerAtomRef $ref);
119
public final function publishAtoms(array $hashes) {
119
final public function publishAtoms(array $hashes) {
120
120
$existing = $this->loadAllPublishedHashes();
122
122
if ($this->dropCaches) {
140
140
$this->createDocumentsByHash($created);
143
protected final function shouldGenerateDocumentForAtom(DivinerAtom $atom) {
143
final protected function shouldGenerateDocumentForAtom(DivinerAtom $atom) {
144
144
switch ($atom->getType()) {
145
145
case DivinerAtom::TYPE_METHOD:
146
146
case DivinerAtom::TYPE_FILE: