Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-14 00:21:04 +01:00
|
|
|
final class PhabricatorJavelinLinter extends ArcanistLinter {
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
|
|
|
|
private $symbols = array();
|
|
|
|
|
2013-02-26 01:24:59 +01:00
|
|
|
private $symbolsBinary;
|
2011-05-11 14:11:59 +02:00
|
|
|
private $haveWarnedAboutBinary;
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
const LINT_PRIVATE_ACCESS = 1;
|
|
|
|
const LINT_MISSING_DEPENDENCY = 2;
|
|
|
|
const LINT_UNNECESSARY_DEPENDENCY = 3;
|
|
|
|
const LINT_UNKNOWN_DEPENDENCY = 4;
|
2011-05-11 14:11:59 +02:00
|
|
|
const LINT_MISSING_BINARY = 5;
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
|
2014-05-12 15:01:30 +02:00
|
|
|
public function getInfoName() {
|
|
|
|
return 'Javelin Linter';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getInfoDescription() {
|
|
|
|
return pht(
|
|
|
|
'This linter is intended for use with the Javelin JS library and '.
|
|
|
|
'extensions. Use `javelinsymbols` to run Javelin rules on Javascript '.
|
|
|
|
'source files.');
|
|
|
|
}
|
|
|
|
|
2013-02-26 01:24:59 +01:00
|
|
|
private function getBinaryPath() {
|
|
|
|
if ($this->symbolsBinary === null) {
|
|
|
|
list($err, $stdout) = exec_manual('which javelinsymbols');
|
|
|
|
$this->symbolsBinary = ($err ? false : rtrim($stdout));
|
|
|
|
}
|
|
|
|
return $this->symbolsBinary;
|
|
|
|
}
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
public function willLintPaths(array $paths) {
|
2013-02-26 01:24:59 +01:00
|
|
|
if (!$this->getBinaryPath()) {
|
|
|
|
return;
|
|
|
|
}
|
2011-05-11 14:11:59 +02:00
|
|
|
|
2012-06-14 00:00:24 +02:00
|
|
|
$root = dirname(phutil_get_library_root('phabricator'));
|
|
|
|
require_once $root.'/scripts/__init_script__.php';
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
$futures = array();
|
|
|
|
foreach ($paths as $path) {
|
2013-01-22 19:32:26 +01:00
|
|
|
if ($this->shouldIgnorePath($path)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
$future = $this->newSymbolsFuture($path);
|
|
|
|
$futures[$path] = $future;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (Futures($futures)->limit(8) as $path => $future) {
|
|
|
|
$this->symbols[$path] = $future->resolvex();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLinterName() {
|
|
|
|
return 'JAVELIN';
|
|
|
|
}
|
|
|
|
|
2014-05-12 13:47:24 +02:00
|
|
|
public function getLinterConfigurationName() {
|
|
|
|
return 'javelin';
|
|
|
|
}
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
public function getLintSeverityMap() {
|
2011-05-11 14:11:59 +02:00
|
|
|
return array(
|
|
|
|
self::LINT_MISSING_BINARY => ArcanistLintSeverity::SEVERITY_WARNING,
|
|
|
|
);
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getLintNameMap() {
|
|
|
|
return array(
|
|
|
|
self::LINT_PRIVATE_ACCESS => 'Private Method/Member Access',
|
|
|
|
self::LINT_MISSING_DEPENDENCY => 'Missing Javelin Dependency',
|
|
|
|
self::LINT_UNNECESSARY_DEPENDENCY => 'Unnecessary Javelin Dependency',
|
|
|
|
self::LINT_UNKNOWN_DEPENDENCY => 'Unknown Javelin Dependency',
|
2013-01-22 19:32:26 +01:00
|
|
|
self::LINT_MISSING_BINARY => '`javelinsymbols` Not In Path',
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-02-26 01:24:59 +01:00
|
|
|
public function getCacheGranularity() {
|
|
|
|
return ArcanistLinter::GRANULARITY_REPOSITORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheVersion() {
|
|
|
|
$version = '0';
|
|
|
|
$binary_path = $this->getBinaryPath();
|
|
|
|
if ($binary_path) {
|
|
|
|
$version .= '-'.md5_file($binary_path);
|
|
|
|
}
|
|
|
|
return $version;
|
|
|
|
}
|
|
|
|
|
2013-01-22 19:32:26 +01:00
|
|
|
private function shouldIgnorePath($path) {
|
2013-05-19 02:04:22 +02:00
|
|
|
return preg_match('@/__tests__/|externals/javelin/docs/@', $path);
|
2013-01-22 19:32:26 +01:00
|
|
|
}
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
public function lintPath($path) {
|
2013-01-22 19:32:26 +01:00
|
|
|
if ($this->shouldIgnorePath($path)) {
|
|
|
|
return;
|
|
|
|
}
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
|
2013-02-26 01:24:59 +01:00
|
|
|
if (!$this->symbolsBinary) {
|
2011-05-11 14:11:59 +02:00
|
|
|
if (!$this->haveWarnedAboutBinary) {
|
|
|
|
$this->haveWarnedAboutBinary = true;
|
|
|
|
// TODO: Write build documentation for the Javelin binaries and point
|
|
|
|
// the user at it.
|
|
|
|
$this->raiseLintAtLine(
|
Add "Undo" for editing Differential inline comments
Summary:
When a user hits 'cancel' on a 'new', 'edit', or 'reply' operation, add a little
"Changes discarded. __Undo__" insert so they can get their change back. No undo
for delete since there's an explicit prompt. Once this lands we can make
'escape' work again to close dialogs.
This change started feeling really good when I was merging all the duplicate
code and making things more consistent, but by the time I started writing client
rendering it felt gross. I'm not really thrilled with it but I guess it's a step
forward? The feature seems pretty OK in practice. Let me know how much barfing
this causes and I can try to remedy the most acute concerns.
This also fixes a bug where replies always (?) appear on the 'new' side of the
diff (I think?).
Test Plan:
Applied 'new', 'edit', 'delete' and 'reply' operations, pressed 'cancel' and
'okay' in each case, with and without changing text where relevant. All
behaviors seem to conform with expectations, except that canceling out of 'edit'
without changing the text gives you an option to undo when it shouldn't really.
There's no super easy way to get at the original text right now.
Reviewed By: aran
Reviewers: aran, jungejason, tuomaspelkonen
CC: simpkins, aran, epriestley
Differential Revision: 406
2011-06-08 01:11:10 +02:00
|
|
|
1,
|
2011-05-11 14:11:59 +02:00
|
|
|
0,
|
|
|
|
self::LINT_MISSING_BINARY,
|
2013-01-22 19:32:26 +01:00
|
|
|
"The 'javelinsymbols' binary in the Javelin project is not ".
|
|
|
|
"available in \$PATH, so the Javelin linter can't run. This ".
|
|
|
|
"isn't a big concern, but means some Javelin problems can't be ".
|
|
|
|
"automatically detected.");
|
2011-05-11 14:11:59 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
list($uses, $installs) = $this->getUsedAndInstalledSymbolsForPath($path);
|
|
|
|
foreach ($uses as $symbol => $line) {
|
|
|
|
$parts = explode('.', $symbol);
|
|
|
|
foreach ($parts as $part) {
|
|
|
|
if ($part[0] == '_' && $part[1] != '_') {
|
|
|
|
$base = implode('.', array_slice($parts, 0, 2));
|
|
|
|
if (!array_key_exists($base, $installs)) {
|
|
|
|
$this->raiseLintAtLine(
|
|
|
|
$line,
|
|
|
|
0,
|
|
|
|
self::LINT_PRIVATE_ACCESS,
|
|
|
|
"This file accesses private symbol '{$symbol}' across file ".
|
|
|
|
"boundaries. You may only access private members and methods ".
|
|
|
|
"from the file where they are defined.");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->getEngine()->getCommitHookMode()) {
|
|
|
|
// Don't do the dependency checks in commit-hook mode because we won't
|
|
|
|
// have an available working copy.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$external_classes = array();
|
|
|
|
foreach ($uses as $symbol => $line) {
|
|
|
|
$parts = explode('.', $symbol);
|
|
|
|
$class = implode('.', array_slice($parts, 0, 2));
|
|
|
|
if (!array_key_exists($class, $external_classes) &&
|
|
|
|
!array_key_exists($class, $installs)) {
|
|
|
|
$external_classes[$class] = $line;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-01 16:46:18 +01:00
|
|
|
$celerity = CelerityResourceMap::getNamedInstance('phabricator');
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
|
2011-05-09 19:11:17 +02:00
|
|
|
$path = preg_replace(
|
2013-01-22 19:32:26 +01:00
|
|
|
'@^externals/javelinjs/src/@',
|
2011-05-09 19:11:17 +02:00
|
|
|
'webroot/rsrc/js/javelin/',
|
|
|
|
$path);
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
$need = $external_classes;
|
|
|
|
|
2014-01-13 21:23:20 +01:00
|
|
|
$resource_name = substr($path, strlen('webroot/'));
|
2014-01-01 03:02:56 +01:00
|
|
|
$requires = $celerity->getRequiredSymbolsForName($resource_name);
|
|
|
|
if (!$requires) {
|
|
|
|
$requires = array();
|
2012-02-22 00:10:24 +01:00
|
|
|
}
|
|
|
|
|
2014-01-01 03:03:09 +01:00
|
|
|
foreach ($requires as $key => $requires_symbol) {
|
|
|
|
$requires_name = $celerity->getResourceNameForSymbol($requires_symbol);
|
|
|
|
if ($requires_name === null) {
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
$this->raiseLintAtLine(
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
self::LINT_UNKNOWN_DEPENDENCY,
|
2014-01-01 03:03:09 +01:00
|
|
|
"This file @requires component '{$requires_symbol}', but it does ".
|
|
|
|
"not exist. You may need to rebuild the Celerity map.");
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
unset($requires[$key]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-01-01 03:03:09 +01:00
|
|
|
if (preg_match('/\\.css$/', $requires_name)) {
|
2013-05-19 02:04:22 +02:00
|
|
|
// If JS requires CSS, just assume everything is fine.
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
unset($requires[$key]);
|
2013-05-19 02:04:22 +02:00
|
|
|
} else {
|
2014-01-13 21:23:20 +01:00
|
|
|
$symbol_path = 'webroot/'.$requires_name;
|
2013-05-19 02:04:22 +02:00
|
|
|
list($ignored, $req_install) = $this->getUsedAndInstalledSymbolsForPath(
|
|
|
|
$symbol_path);
|
|
|
|
if (array_intersect_key($req_install, $external_classes)) {
|
|
|
|
$need = array_diff_key($need, $req_install);
|
|
|
|
unset($requires[$key]);
|
|
|
|
}
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($need as $class => $line) {
|
|
|
|
$this->raiseLintAtLine(
|
|
|
|
$line,
|
|
|
|
0,
|
|
|
|
self::LINT_MISSING_DEPENDENCY,
|
|
|
|
"This file uses '{$class}' but does not @requires the component ".
|
|
|
|
"which installs it. You may need to rebuild the Celerity map.");
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($requires as $component) {
|
|
|
|
$this->raiseLintAtLine(
|
2011-05-09 19:11:17 +02:00
|
|
|
0,
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
0,
|
|
|
|
self::LINT_UNNECESSARY_DEPENDENCY,
|
|
|
|
"This file @requires component '{$component}' but does not use ".
|
|
|
|
"anything it provides.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadSymbols($path) {
|
|
|
|
if (empty($this->symbols[$path])) {
|
|
|
|
$this->symbols[$path] = $this->newSymbolsFuture($path)->resolvex();
|
|
|
|
}
|
|
|
|
return $this->symbols[$path];
|
|
|
|
}
|
|
|
|
|
|
|
|
private function newSymbolsFuture($path) {
|
2013-02-02 22:27:42 +01:00
|
|
|
$future = new ExecFuture('javelinsymbols # %s', $path);
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
$future->write($this->getData($path));
|
|
|
|
return $future;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getUsedAndInstalledSymbolsForPath($path) {
|
|
|
|
list($symbols) = $this->loadSymbols($path);
|
2012-02-22 00:10:24 +01:00
|
|
|
$symbols = trim($symbols);
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
|
|
|
|
$uses = array();
|
|
|
|
$installs = array();
|
2012-02-22 00:10:24 +01:00
|
|
|
if (empty($symbols)) {
|
|
|
|
// This file has no symbols.
|
|
|
|
return array($uses, $installs);
|
|
|
|
}
|
|
|
|
|
|
|
|
$symbols = explode("\n", trim($symbols));
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
foreach ($symbols as $line) {
|
|
|
|
$matches = null;
|
2012-03-27 01:09:55 +02:00
|
|
|
if (!preg_match('/^([?+\*])([^:]*):(\d+)$/', $line, $matches)) {
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
throw new Exception(
|
2014-06-09 20:36:49 +02:00
|
|
|
'Received malformed output from `javelinsymbols`.');
|
Bring Javelin into Phabricator via git submodule, not copy-and-paste
Summary:
Javelin is currently embedded in Phabricator via copy-and-paste of prebuilt
packages. This is not so great.
Pull it in as a submodule instead and make all the Phabriator resources declare
proper dependency trees. Add Javelin linting.
Test Plan:
I tried to run through pretty much all the JS functionality on the site. This is
still a high-risk change, but I did a pretty thorough test
Differential: inline comments, revealing diffs, list tokenizers, comment
preview, editing/deleting comments, add review action.
Maniphest: list tokenizer, comment actions
Herald: rule editing, tokenizers, add/remove rows
Reviewed By: tomo
Reviewers: aran, tomo, mroch, jungejason, tuomaspelkonen
CC: aran, tomo, epriestley
Differential Revision: 223
2011-05-04 00:11:55 +02:00
|
|
|
}
|
|
|
|
$type = $matches[1];
|
|
|
|
$symbol = $matches[2];
|
|
|
|
$line = $matches[3];
|
|
|
|
|
|
|
|
switch ($type) {
|
|
|
|
case '?':
|
|
|
|
$uses[$symbol] = $line;
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
$installs['JX.'.$symbol] = $line;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$contents = $this->getData($path);
|
|
|
|
|
|
|
|
$matches = null;
|
|
|
|
$count = preg_match_all(
|
|
|
|
'/@javelin-installs\W+(\S+)/',
|
|
|
|
$contents,
|
|
|
|
$matches,
|
|
|
|
PREG_PATTERN_ORDER);
|
|
|
|
|
|
|
|
if ($count) {
|
|
|
|
foreach ($matches[1] as $symbol) {
|
|
|
|
$installs[$symbol] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array($uses, $installs);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|