mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-01 19:22:42 +01:00
xhpastview
This commit is contained in:
parent
9630123d6a
commit
aa0ff43999
25 changed files with 669 additions and 5 deletions
9
resources/sql/patches/021.xhpastview.sql
Normal file
9
resources/sql/patches/021.xhpastview.sql
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
CREATE DATABASE phabricator_xhpastview;
|
||||||
|
CREATE TABLE phabricator_xhpastview.xhpastview_parsetree (
|
||||||
|
id int unsigned not null auto_increment primary key,
|
||||||
|
authorPHID varchar(64) binary,
|
||||||
|
input longblob not null,
|
||||||
|
stdout longblob not null,
|
||||||
|
dateCreated int unsigned not null,
|
||||||
|
dateModified int unsigned not null
|
||||||
|
);
|
|
@ -423,6 +423,16 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/task',
|
'PhabricatorWorkerTask' => 'infrastructure/daemon/workers/storage/task',
|
||||||
'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/taskdata',
|
'PhabricatorWorkerTaskData' => 'infrastructure/daemon/workers/storage/taskdata',
|
||||||
'PhabricatorWorkerTaskDetailController' => 'applications/daemon/controller/workertaskdetail',
|
'PhabricatorWorkerTaskDetailController' => 'applications/daemon/controller/workertaskdetail',
|
||||||
|
'PhabricatorXHPASTViewController' => 'applications/xhpastview/controller/base',
|
||||||
|
'PhabricatorXHPASTViewDAO' => 'applications/xhpastview/storage/base',
|
||||||
|
'PhabricatorXHPASTViewFrameController' => 'applications/xhpastview/controller/viewframe',
|
||||||
|
'PhabricatorXHPASTViewFramesetController' => 'applications/xhpastview/controller/viewframeset',
|
||||||
|
'PhabricatorXHPASTViewInputController' => 'applications/xhpastview/controller/viewinput',
|
||||||
|
'PhabricatorXHPASTViewPanelController' => 'applications/xhpastview/controller/viewpanel',
|
||||||
|
'PhabricatorXHPASTViewParseTree' => 'applications/xhpastview/storage/parsetree',
|
||||||
|
'PhabricatorXHPASTViewRunController' => 'applications/xhpastview/controller/run',
|
||||||
|
'PhabricatorXHPASTViewStreamController' => 'applications/xhpastview/controller/viewstream',
|
||||||
|
'PhabricatorXHPASTViewTreeController' => 'applications/xhpastview/controller/viewtree',
|
||||||
'PhabricatorXHProfController' => 'applications/xhprof/controller/base',
|
'PhabricatorXHProfController' => 'applications/xhprof/controller/base',
|
||||||
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
'PhabricatorXHProfProfileController' => 'applications/xhprof/controller/profile',
|
||||||
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
'PhabricatorXHProfProfileSymbolView' => 'applications/xhprof/view/symbol',
|
||||||
|
@ -776,6 +786,16 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO',
|
'PhabricatorWorkerTask' => 'PhabricatorWorkerDAO',
|
||||||
'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO',
|
'PhabricatorWorkerTaskData' => 'PhabricatorWorkerDAO',
|
||||||
'PhabricatorWorkerTaskDetailController' => 'PhabricatorDaemonController',
|
'PhabricatorWorkerTaskDetailController' => 'PhabricatorDaemonController',
|
||||||
|
'PhabricatorXHPASTViewController' => 'PhabricatorController',
|
||||||
|
'PhabricatorXHPASTViewDAO' => 'PhabricatorLiskDAO',
|
||||||
|
'PhabricatorXHPASTViewFrameController' => 'PhabricatorXHPASTViewController',
|
||||||
|
'PhabricatorXHPASTViewFramesetController' => 'PhabricatorXHPASTViewController',
|
||||||
|
'PhabricatorXHPASTViewInputController' => 'PhabricatorXHPASTViewPanelController',
|
||||||
|
'PhabricatorXHPASTViewPanelController' => 'PhabricatorXHPASTViewController',
|
||||||
|
'PhabricatorXHPASTViewParseTree' => 'PhabricatorXHPASTViewDAO',
|
||||||
|
'PhabricatorXHPASTViewRunController' => 'PhabricatorXHPASTViewController',
|
||||||
|
'PhabricatorXHPASTViewStreamController' => 'PhabricatorXHPASTViewPanelController',
|
||||||
|
'PhabricatorXHPASTViewTreeController' => 'PhabricatorXHPASTViewPanelController',
|
||||||
'PhabricatorXHProfController' => 'PhabricatorController',
|
'PhabricatorXHProfController' => 'PhabricatorController',
|
||||||
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
'PhabricatorXHProfProfileController' => 'PhabricatorXHProfController',
|
||||||
'PhabricatorXHProfProfileSymbolView' => 'AphrontView',
|
'PhabricatorXHProfProfileSymbolView' => 'AphrontView',
|
||||||
|
|
|
@ -268,6 +268,20 @@ class AphrontDefaultApplicationConfiguration
|
||||||
'delete/(?P<id>\d+)/$' => 'PhabricatorOwnersDeleteController',
|
'delete/(?P<id>\d+)/$' => 'PhabricatorOwnersDeleteController',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
'/xhpast/' => array(
|
||||||
|
'$' => 'PhabricatorXHPASTViewRunController',
|
||||||
|
'view/(?P<id>\d+)/$'
|
||||||
|
=> 'PhabricatorXHPASTViewFrameController',
|
||||||
|
'frameset/(?P<id>\d+)/$'
|
||||||
|
=> 'PhabricatorXHPASTViewFramesetController',
|
||||||
|
'input/(?P<id>\d+)/$'
|
||||||
|
=> 'PhabricatorXHPASTViewInputController',
|
||||||
|
'tree/(?P<id>\d+)/$'
|
||||||
|
=> 'PhabricatorXHPASTViewTreeController',
|
||||||
|
'stream/(?P<id>\d+)/$'
|
||||||
|
=> 'PhabricatorXHPASTViewStreamController',
|
||||||
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,21 +22,30 @@
|
||||||
class AphrontWebpageResponse extends AphrontResponse {
|
class AphrontWebpageResponse extends AphrontResponse {
|
||||||
|
|
||||||
private $content;
|
private $content;
|
||||||
|
private $frameable;
|
||||||
|
|
||||||
public function setContent($content) {
|
public function setContent($content) {
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setFrameable($frameable) {
|
||||||
|
$this->frameable = $frameable;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function buildResponseString() {
|
public function buildResponseString() {
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeaders() {
|
public function getHeaders() {
|
||||||
return array(
|
$headers = array(
|
||||||
array('Content-Type', 'text/html; charset=UTF-8'),
|
array('Content-Type', 'text/html; charset=UTF-8'),
|
||||||
array('X-Frame-Options', 'Deny'),
|
|
||||||
);
|
);
|
||||||
|
if (!$this->frameable) {
|
||||||
|
$headers[] = array('X-Frame-Options', 'Deny');
|
||||||
|
}
|
||||||
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/applications/xhpastview/controller/base/__init__.php
Normal file
15
src/applications/xhpastview/controller/base/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/webpage');
|
||||||
|
phutil_require_module('phabricator', 'applications/base/controller/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewController.php');
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewRunController
|
||||||
|
extends PhabricatorXHPASTViewController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
if ($request->isFormPost()) {
|
||||||
|
$source = $request->getStr('source');
|
||||||
|
|
||||||
|
$future = xhpast_get_parser_future($source);
|
||||||
|
$resolved = $future->resolve();
|
||||||
|
|
||||||
|
// This is just to let it throw exceptions if stuff is broken.
|
||||||
|
$parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture(
|
||||||
|
$source,
|
||||||
|
$resolved);
|
||||||
|
|
||||||
|
list($err, $stdout, $stderr) = $resolved;
|
||||||
|
|
||||||
|
$storage_tree = new PhabricatorXHPASTViewParseTree();
|
||||||
|
$storage_tree->setInput($source);
|
||||||
|
$storage_tree->setStdout($stdout);
|
||||||
|
$storage_tree->setAuthorPHID($user->getPHID());
|
||||||
|
$storage_tree->save();
|
||||||
|
|
||||||
|
return id(new AphrontRedirectResponse())
|
||||||
|
->setURI('/xhpast/view/'.$storage_tree->getID().'/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = id(new AphrontFormView())
|
||||||
|
->setUser($user)
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormTextAreaControl())
|
||||||
|
->setLabel('Source')
|
||||||
|
->setName('source')
|
||||||
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
|
||||||
|
->appendChild(
|
||||||
|
id(new AphrontFormSubmitControl())
|
||||||
|
->setValue('Parse'));
|
||||||
|
|
||||||
|
$panel = new AphrontPanelView();
|
||||||
|
$panel->setHeader('Generate XHP AST');
|
||||||
|
$panel->setWidth(AphrontPanelView::WIDTH_WIDE);
|
||||||
|
$panel->appendChild($form);
|
||||||
|
|
||||||
|
return $this->buildStandardPageResponse(
|
||||||
|
$panel,
|
||||||
|
array(
|
||||||
|
'title' => 'XHPAST View',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
src/applications/xhpastview/controller/run/__init__.php
Normal file
21
src/applications/xhpastview/controller/run/__init__.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/redirect');
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/storage/parsetree');
|
||||||
|
phutil_require_module('phabricator', 'view/form/base');
|
||||||
|
phutil_require_module('phabricator', 'view/form/control/submit');
|
||||||
|
phutil_require_module('phabricator', 'view/layout/panel');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'parser/xhpast/api/tree');
|
||||||
|
phutil_require_module('phutil', 'parser/xhpast/bin');
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewRunController.php');
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewFrameController
|
||||||
|
extends PhabricatorXHPASTViewController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$id = $this->id;
|
||||||
|
|
||||||
|
return $this->buildStandardPageResponse(
|
||||||
|
phutil_render_tag(
|
||||||
|
'iframe',
|
||||||
|
array(
|
||||||
|
'src' => '/xhpast/frameset/'.$id.'/',
|
||||||
|
'frameborder' => '0',
|
||||||
|
'style' => 'width: 100%; height: 800px;',
|
||||||
|
'')),
|
||||||
|
array(
|
||||||
|
'title' => 'XHPAST View',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/base');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewFrameController.php');
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewFramesetController
|
||||||
|
extends PhabricatorXHPASTViewController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$id = $this->id;
|
||||||
|
|
||||||
|
$response = new AphrontWebpageResponse();
|
||||||
|
$response->setFrameable(true);
|
||||||
|
$response->setContent(
|
||||||
|
'<frameset cols="33%, 34%, 33%">'.
|
||||||
|
'<frame src="/xhpast/input/'.$id.'/" />'.
|
||||||
|
'<frame src="/xhpast/tree/'.$id.'/" />'.
|
||||||
|
'<frame src="/xhpast/stream/'.$id.'/" />'.
|
||||||
|
'</frameset>');
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/webpage');
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/base');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewFramesetController.php');
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewInputController
|
||||||
|
extends PhabricatorXHPASTViewPanelController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$input = $this->getStorageTree()->getInput();
|
||||||
|
return $this->buildXHPASTViewPanelResponse(
|
||||||
|
phutil_escape_html($input));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/viewpanel');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewInputController.php');
|
|
@ -0,0 +1,87 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class PhabricatorXHPASTViewPanelController
|
||||||
|
extends PhabricatorXHPASTViewController {
|
||||||
|
|
||||||
|
private $id;
|
||||||
|
private $tree;
|
||||||
|
|
||||||
|
public function willProcessRequest(array $data) {
|
||||||
|
$this->id = $data['id'];
|
||||||
|
$this->storageTree = id(new PhabricatorXHPASTViewParseTree())
|
||||||
|
->load($this->id);
|
||||||
|
if (!$this->storageTree) {
|
||||||
|
throw new Exception("No such AST!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getStorageTree() {
|
||||||
|
return $this->storageTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildXHPASTViewPanelResponse($content) {
|
||||||
|
$content =
|
||||||
|
'<!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>'.
|
||||||
|
$content.
|
||||||
|
'</body>'.
|
||||||
|
'</html>';
|
||||||
|
|
||||||
|
$response = new AphrontWebpageResponse();
|
||||||
|
$response->setFrameable(true);
|
||||||
|
$response->setContent($content);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'aphront/response/webpage');
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/storage/parsetree');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewPanelController.php');
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewStreamController
|
||||||
|
extends PhabricatorXHPASTViewPanelController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$storage = $this->getStorageTree();
|
||||||
|
$input = $storage->getInput();
|
||||||
|
$stdout = $storage->getStdout();
|
||||||
|
|
||||||
|
$tree = XHPASTTree::newFromDataAndResolvedExecFuture(
|
||||||
|
$input,
|
||||||
|
array(0, $stdout, ''));
|
||||||
|
|
||||||
|
$tokens = array();
|
||||||
|
foreach ($tree->getRawTokenStream() as $id => $token) {
|
||||||
|
$seq = $id;
|
||||||
|
$name = $token->getTypeName();
|
||||||
|
$title = "Token {$seq}: {$name}";
|
||||||
|
|
||||||
|
$tokens[] = phutil_render_tag(
|
||||||
|
'span',
|
||||||
|
array(
|
||||||
|
'title' => $title,
|
||||||
|
'class' => 'token',
|
||||||
|
),
|
||||||
|
phutil_escape_html($token->getValue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->buildXHPASTViewPanelResponse(implode('', $tokens));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/viewpanel');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'parser/xhpast/api/tree');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewStreamController.php');
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewTreeController
|
||||||
|
extends PhabricatorXHPASTViewPanelController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$storage = $this->getStorageTree();
|
||||||
|
$input = $storage->getInput();
|
||||||
|
$stdout = $storage->getStdout();
|
||||||
|
|
||||||
|
$tree = XHPASTTree::newFromDataAndResolvedExecFuture(
|
||||||
|
$input,
|
||||||
|
array(0, $stdout, ''));
|
||||||
|
|
||||||
|
$tree = '<ul>'.$this->buildTree($tree->getRootNode()).'</ul>';
|
||||||
|
return $this->buildXHPASTViewPanelResponse($tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildTree($root) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
$name = $root->getTypeName();
|
||||||
|
$title = $root->getDescription();
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
$name = '???';
|
||||||
|
$title = '???';
|
||||||
|
}
|
||||||
|
|
||||||
|
$tree = array();
|
||||||
|
$tree[] =
|
||||||
|
'<li>'.
|
||||||
|
phutil_render_tag(
|
||||||
|
'span',
|
||||||
|
array(
|
||||||
|
'title' => $title,
|
||||||
|
),
|
||||||
|
phutil_escape_html($name)).
|
||||||
|
'</li>';
|
||||||
|
foreach ($root->getChildren() as $child) {
|
||||||
|
$tree[] = '<ul>'.$this->buildTree($child).'</ul>';
|
||||||
|
}
|
||||||
|
return implode("\n", $tree);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/applications/xhpastview/controller/viewtree/__init__.php
Normal file
15
src/applications/xhpastview/controller/viewtree/__init__.php
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/controller/viewpanel');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'markup');
|
||||||
|
phutil_require_module('phutil', 'parser/xhpast/api/tree');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewTreeController.php');
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class PhabricatorXHPASTViewDAO extends PhabricatorLiskDAO {
|
||||||
|
|
||||||
|
public function getApplicationName() {
|
||||||
|
return 'xhpastview';
|
||||||
|
}
|
||||||
|
}
|
12
src/applications/xhpastview/storage/base/__init__.php
Normal file
12
src/applications/xhpastview/storage/base/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/base/storage/lisk');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewDAO.php');
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2011 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class PhabricatorXHPASTViewParseTree extends PhabricatorXHPASTViewDAO {
|
||||||
|
|
||||||
|
protected $authorPHID;
|
||||||
|
|
||||||
|
protected $input;
|
||||||
|
protected $stdout;
|
||||||
|
}
|
12
src/applications/xhpastview/storage/parsetree/__init__.php
Normal file
12
src/applications/xhpastview/storage/parsetree/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/xhpastview/storage/base');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('PhabricatorXHPASTViewParseTree.php');
|
|
@ -59,9 +59,9 @@ try {
|
||||||
|
|
||||||
phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
|
phutil_require_module('phabricator', 'aphront/console/plugin/errorlog/api');
|
||||||
set_error_handler(
|
set_error_handler(
|
||||||
array('DarkConsoleErrorLogPluginAPI', 'handleError'));
|
array('PhutilErrorHandler', 'handleError'));
|
||||||
set_exception_handler(
|
set_exception_handler(
|
||||||
array('DarkConsoleErrorLogPluginAPI', 'handleException'));
|
array('PhutilErrorHandler', 'handleException'));
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
phabricator_fatal_config_error(
|
phabricator_fatal_config_error(
|
||||||
"[Exception] ".$ex->getMessage());
|
"[Exception] ".$ex->getMessage());
|
||||||
|
|
Loading…
Reference in a new issue