Differential D14028 Diff 34906 src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
| <?php | <?php | ||||
| final class PhabricatorXHPASTViewTreeController | final class PhabricatorXHPASTViewTreeController | ||||
| extends PhabricatorXHPASTViewPanelController { | extends PhabricatorXHPASTViewPanelController { | ||||
| public function shouldAllowPublic() { | public function shouldAllowPublic() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function handleRequest(AphrontRequest $request) { | public function handleRequest(AphrontRequest $request) { | ||||
| $storage = $this->getStorageTree(); | $storage = $this->getStorageTree(); | ||||
| $input = $storage->getInput(); | $input = $storage->getInput(); | ||||
| $err = $storage->getReturnCode(); | |||||
| $stdout = $storage->getStdout(); | $stdout = $storage->getStdout(); | ||||
| $stderr = $storage->getStderr(); | |||||
| try { | |||||
| $tree = XHPASTTree::newFromDataAndResolvedExecFuture( | $tree = XHPASTTree::newFromDataAndResolvedExecFuture( | ||||
| $input, | $input, | ||||
| array(0, $stdout, '')); | array($err, $stdout, $stderr)); | ||||
| } catch (XHPASTSyntaxErrorException $ex) { | |||||
| return $this->buildXHPASTViewPanelResponse($ex->getMessage()); | |||||
| } | |||||
| $tree = phutil_tag('ul', array(), $this->buildTree($tree->getRootNode())); | $tree = phutil_tag('ul', array(), $this->buildTree($tree->getRootNode())); | ||||
| return $this->buildXHPASTViewPanelResponse($tree); | return $this->buildXHPASTViewPanelResponse($tree); | ||||
| } | } | ||||
| protected function buildTree($root) { | protected function buildTree($root) { | ||||
| try { | try { | ||||
| $name = $root->getTypeName(); | $name = $root->getTypeName(); | ||||
| $title = $root->getDescription(); | $title = $root->getDescription(); | ||||
| } catch (Exception $ex) { | } catch (Exception $ex) { | ||||
| $name = '???'; | $name = '???'; | ||||
| $title = '???'; | $title = '???'; | ||||
| } | } | ||||
| Show All 17 Lines | |||||