Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2892063
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
12 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/resources/sql/autopatches/20151108.xhpast.stderr.sql b/resources/sql/autopatches/20151108.xhpast.stderr.sql
new file mode 100644
index 0000000000..1721505658
--- /dev/null
+++ b/resources/sql/autopatches/20151108.xhpast.stderr.sql
@@ -0,0 +1,5 @@
+ALTER TABLE {$NAMESPACE}_xhpastview.xhpastview_parsetree
+ ADD returnCode INT NOT NULL AFTER input;
+
+ALTER TABLE {$NAMESPACE}_xhpastview.xhpastview_parsetree
+ ADD stderr longtext NOT NULL AFTER stdout;
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewController.php
index 7d3ccf8187..2ef34fb36f 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewController.php
@@ -1,19 +1,18 @@
<?php
abstract class PhabricatorXHPASTViewController extends PhabricatorController {
public function buildStandardPageResponse($view, array $data) {
-
$page = $this->buildStandardPageView();
$page->setApplicationName('XHPASTView');
$page->setBaseURI('/xhpast/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x96\xA0");
$page->appendChild($view);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
}
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewFrameController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewFrameController.php
index 2c5a43687c..89f5b8fd7d 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewFrameController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewFrameController.php
@@ -1,26 +1,26 @@
<?php
final class PhabricatorXHPASTViewFrameController
extends PhabricatorXHPASTViewController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$id = $request->getURIData('id');
return $this->buildStandardPageResponse(
phutil_tag(
'iframe',
array(
- 'src' => '/xhpast/frameset/'.$id.'/',
+ 'src' => "/xhpast/frameset/{$id}/",
'frameborder' => '0',
'style' => 'width: 100%; height: 800px;',
'',
)),
array(
'title' => pht('XHPAST View'),
));
}
}
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php
index de446b5e44..6f186fb3f8 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewFramesetController.php
@@ -1,26 +1,24 @@
<?php
final class PhabricatorXHPASTViewFramesetController
extends PhabricatorXHPASTViewController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$id = $request->getURIData('id');
- $response = new AphrontWebpageResponse();
- $response->setFrameable(true);
- $response->setContent(phutil_tag(
- 'frameset',
- array('cols' => '33%, 34%, 33%'),
- array(
- phutil_tag('frame', array('src' => "/xhpast/input/{$id}/")),
- phutil_tag('frame', array('src' => "/xhpast/tree/{$id}/")),
- phutil_tag('frame', array('src' => "/xhpast/stream/{$id}/")),
- )));
-
- return $response;
+ return id(new AphrontWebpageResponse())
+ ->setFrameable(true)
+ ->setContent(phutil_tag(
+ 'frameset',
+ array('cols' => '33%, 34%, 33%'),
+ array(
+ phutil_tag('frame', array('src' => "/xhpast/input/{$id}/")),
+ phutil_tag('frame', array('src' => "/xhpast/tree/{$id}/")),
+ phutil_tag('frame', array('src' => "/xhpast/stream/{$id}/")),
+ )));
}
}
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php
index 8f824dc03f..7238b36381 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewPanelController.php
@@ -1,74 +1,74 @@
<?php
abstract class PhabricatorXHPASTViewPanelController
extends PhabricatorXHPASTViewController {
private $id;
private $storageTree;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->id = $data['id'];
$this->storageTree = id(new PhabricatorXHPASTViewParseTree())
->load($this->id);
+
if (!$this->storageTree) {
throw new Exception(pht('No such AST!'));
}
}
protected function getStorageTree() {
return $this->storageTree;
}
protected function buildXHPASTViewPanelResponse($content) {
$content = hsprintf(
'<!DOCTYPE html>'.
'<html>'.
'<head>'.
'<style type="text/css">
body {
white-space: pre;
font: 10px "Monaco";
cursor: pointer;
}
.token {
padding: 2px 4px;
margin: 2px 2px;
border: 1px solid #bbbbbb;
line-height: 24px;
}
ul {
margin: 0 0 0 1em;
padding: 0;
list-style: none;
line-height: 1em;
}
li {
margin: 0;
padding: 0;
}
li span {
background: #dddddd;
padding: 3px 6px;
}
</style>'.
'</head>'.
'<body>%s</body>'.
'</html>',
$content);
- $response = new AphrontWebpageResponse();
- $response->setFrameable(true);
- $response->setContent($content);
- return $response;
+ return id(new AphrontWebpageResponse())
+ ->setFrameable(true)
+ ->setContent($content);
}
}
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php
index dd9cf85433..dc2224d291 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php
@@ -1,55 +1,59 @@
<?php
final class PhabricatorXHPASTViewRunController
extends PhabricatorXHPASTViewController {
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
if ($request->isFormPost()) {
$source = $request->getStr('source');
$future = PhutilXHPASTBinary::getParserFuture($source);
$resolved = $future->resolve();
// This is just to let it throw exceptions if stuff is broken.
- $parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture(
- $source,
- $resolved);
+ try {
+ XHPASTTree::newFromDataAndResolvedExecFuture($source, $resolved);
+ } catch (XHPASTSyntaxErrorException $ex) {
+ // This is possibly expected.
+ }
list($err, $stdout, $stderr) = $resolved;
- $storage_tree = new PhabricatorXHPASTViewParseTree();
- $storage_tree->setInput($source);
- $storage_tree->setStdout($stdout);
- $storage_tree->setAuthorPHID($viewer->getPHID());
- $storage_tree->save();
+ $storage_tree = id(new PhabricatorXHPASTViewParseTree())
+ ->setInput($source)
+ ->setReturnCode($err)
+ ->setStdout($stdout)
+ ->setStderr($stderr)
+ ->setAuthorPHID($viewer->getPHID())
+ ->save();
return id(new AphrontRedirectResponse())
->setURI('/xhpast/view/'.$storage_tree->getID().'/');
}
$form = id(new AphrontFormView())
->setUser($viewer)
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel(pht('Source'))
->setName('source')
->setValue("<?php\n\n")
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Parse')));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Generate XHP AST'))
->setForm($form);
return $this->buildApplicationPage(
$form_box,
array(
'title' => pht('XHPAST View'),
));
}
}
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php
index 3fe1046f10..f5cedf225a 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php
@@ -1,33 +1,39 @@
<?php
final class PhabricatorXHPASTViewStreamController
extends PhabricatorXHPASTViewPanelController {
public function handleRequest(AphrontRequest $request) {
$storage = $this->getStorageTree();
$input = $storage->getInput();
+ $err = $storage->getReturnCode();
$stdout = $storage->getStdout();
+ $stderr = $storage->getStderr();
- $tree = XHPASTTree::newFromDataAndResolvedExecFuture(
- $input,
- array(0, $stdout, ''));
+ try {
+ $tree = XHPASTTree::newFromDataAndResolvedExecFuture(
+ $input,
+ array($err, $stdout, $stderr));
+ } catch (XHPASTSyntaxErrorException $ex) {
+ return $this->buildXHPASTViewPanelResponse($ex->getMessage());
+ }
$tokens = array();
foreach ($tree->getRawTokenStream() as $id => $token) {
$seq = $id;
$name = $token->getTypeName();
$title = pht('Token %s: %s', $seq, $name);
$tokens[] = phutil_tag(
'span',
array(
'title' => $title,
'class' => 'token',
),
$token->getValue());
}
return $this->buildXHPASTViewPanelResponse(
phutil_implode_html('', $tokens));
}
}
diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
index 1b4eec6441..c15bdc2928 100644
--- a/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
+++ b/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php
@@ -1,49 +1,54 @@
<?php
final class PhabricatorXHPASTViewTreeController
extends PhabricatorXHPASTViewPanelController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$storage = $this->getStorageTree();
$input = $storage->getInput();
+ $err = $storage->getReturnCode();
$stdout = $storage->getStdout();
+ $stderr = $storage->getStderr();
- $tree = XHPASTTree::newFromDataAndResolvedExecFuture(
- $input,
- array(0, $stdout, ''));
+ try {
+ $tree = XHPASTTree::newFromDataAndResolvedExecFuture(
+ $input,
+ array($err, $stdout, $stderr));
+ } catch (XHPASTSyntaxErrorException $ex) {
+ return $this->buildXHPASTViewPanelResponse($ex->getMessage());
+ }
$tree = phutil_tag('ul', array(), $this->buildTree($tree->getRootNode()));
return $this->buildXHPASTViewPanelResponse($tree);
}
protected function buildTree($root) {
-
try {
$name = $root->getTypeName();
$title = $root->getDescription();
} catch (Exception $ex) {
$name = '???';
$title = '???';
}
$tree = array();
$tree[] = phutil_tag(
'li',
array(),
phutil_tag(
'span',
array(
'title' => $title,
),
$name));
foreach ($root->getChildren() as $child) {
$tree[] = phutil_tag('ul', array(), $this->buildTree($child));
}
return phutil_implode_html("\n", $tree);
}
}
diff --git a/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php b/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php
index fa9adb62a2..d4432af496 100644
--- a/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php
+++ b/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php
@@ -1,19 +1,22 @@
<?php
final class PhabricatorXHPASTViewParseTree extends PhabricatorXHPASTViewDAO {
protected $authorPHID;
-
protected $input;
+ protected $returnCode;
protected $stdout;
+ protected $stderr;
protected function getConfiguration() {
return array(
self::CONFIG_COLUMN_SCHEMA => array(
'authorPHID' => 'phid?',
'input' => 'text',
+ 'returnCode' => 'sint32',
'stdout' => 'text',
+ 'stderr' => 'text',
),
) + parent::getConfiguration();
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 16:11 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126347
Default Alt Text
(12 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment