Differential D12460 Diff 29904 src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
<?php | <?php | ||||
/** | /** | ||||
* @task functions Token Functions | * @task functions Token Functions | ||||
*/ | */ | ||||
abstract class PhabricatorTypeaheadDatasource extends Phobject { | abstract class PhabricatorTypeaheadDatasource extends Phobject { | ||||
private $viewer; | private $viewer; | ||||
private $query; | private $query; | ||||
private $rawQuery; | private $rawQuery; | ||||
private $offset; | private $offset; | ||||
private $limit; | private $limit; | ||||
private $parameters = array(); | private $parameters = array(); | ||||
private $functionStack = array(); | |||||
public function setLimit($limit) { | public function setLimit($limit) { | ||||
$this->limit = $limit; | $this->limit = $limit; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getLimit() { | public function getLimit() { | ||||
return $this->limit; | return $this->limit; | ||||
▲ Show 20 Lines • Show All 247 Lines • ▼ Show 20 Lines | public function getDatasourceFunctions() { | ||||
return array(); | return array(); | ||||
} | } | ||||
/** | /** | ||||
* @task functions | * @task functions | ||||
*/ | */ | ||||
protected function canEvaluateFunction($function) { | protected function canEvaluateFunction($function) { | ||||
return $this->shouldStripFunction($function); | |||||
} | |||||
/** | |||||
* @task functions | |||||
*/ | |||||
protected function shouldStripFunction($function) { | |||||
$functions = $this->getDatasourceFunctions(); | $functions = $this->getDatasourceFunctions(); | ||||
return isset($functions[$function]); | return isset($functions[$function]); | ||||
} | } | ||||
/** | /** | ||||
* @task functions | * @task functions | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | /* -( Token Functions )---------------------------------------------------- */ | ||||
/** | /** | ||||
* @task functions | * @task functions | ||||
*/ | */ | ||||
public function parseFunction($token, $allow_partial = false) { | public function parseFunction($token, $allow_partial = false) { | ||||
$matches = null; | $matches = null; | ||||
if ($allow_partial) { | if ($allow_partial) { | ||||
$ok = preg_match('/^([^(]+)\((.*)$/', $token, $matches); | $ok = preg_match('/^([^(]+)\((.*?)\)?$/', $token, $matches); | ||||
} else { | } else { | ||||
$ok = preg_match('/^([^(]+)\((.*)\)$/', $token, $matches); | $ok = preg_match('/^([^(]+)\((.*)\)$/', $token, $matches); | ||||
} | } | ||||
if (!$ok) { | if (!$ok) { | ||||
return null; | return null; | ||||
} | } | ||||
Show All 13 Lines | /* -( Token Functions )---------------------------------------------------- */ | ||||
/** | /** | ||||
* @task functions | * @task functions | ||||
*/ | */ | ||||
public function renderFunctionTokens($function, array $argv_list) { | public function renderFunctionTokens($function, array $argv_list) { | ||||
throw new PhutilMethodNotImplementedException(); | throw new PhutilMethodNotImplementedException(); | ||||
} | } | ||||
/** | |||||
* @task functions | |||||
*/ | |||||
public function setFunctionStack(array $function_stack) { | |||||
$this->functionStack = $function_stack; | |||||
return $this; | |||||
} | |||||
/** | |||||
* @task functions | |||||
*/ | |||||
public function getFunctionStack() { | |||||
return $this->functionStack; | |||||
} | |||||
/** | |||||
* @task functions | |||||
*/ | |||||
protected function getCurrentFunction() { | |||||
return nonempty(last($this->functionStack), null); | |||||
} | |||||
} | } |