Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14868716
D11691.id28133.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D11691.id28133.diff
View Options
diff --git a/src/lint/engine/ArcanistLintEngine.php b/src/lint/engine/ArcanistLintEngine.php
--- a/src/lint/engine/ArcanistLintEngine.php
+++ b/src/lint/engine/ArcanistLintEngine.php
@@ -46,6 +46,7 @@
protected $workingCopy;
protected $paths = array();
protected $fileData = array();
+ protected $renderer = null;
protected $charToLine = array();
protected $lineToFirstChar = array();
@@ -88,6 +89,15 @@
return $this->workingCopy;
}
+ final public function setRenderer(ArcanistLintRenderer $renderer) {
+ $this->renderer = $renderer;
+ return $this;
+ }
+
+ final public function getRenderer() {
+ return $this->renderer;
+ }
+
final public function setPaths($paths) {
$this->paths = $paths;
return $this;
diff --git a/src/lint/linter/ArcanistLinter.php b/src/lint/linter/ArcanistLinter.php
--- a/src/lint/linter/ArcanistLinter.php
+++ b/src/lint/linter/ArcanistLinter.php
@@ -259,6 +259,10 @@
->setOriginalText($original)
->setReplacementText($replacement);
+ if ($this->getEngine()->getRenderer()) {
+ echo $this->getEngine()->getRenderer()->renderLintMessage($message);
+ }
+
return $this->addLintMessage($message);
}
diff --git a/src/lint/renderer/ArcanistJSONLintRenderer.php b/src/lint/renderer/ArcanistJSONLintRenderer.php
--- a/src/lint/renderer/ArcanistJSONLintRenderer.php
+++ b/src/lint/renderer/ArcanistJSONLintRenderer.php
@@ -32,4 +32,8 @@
return '';
}
+ public function renderLintMessage(ArcanistLintMessage $message) {
+ return "##arc-lint## ".json_encode($message->toDictionary())."\n";
+ }
+
}
diff --git a/src/lint/renderer/ArcanistLintRenderer.php b/src/lint/renderer/ArcanistLintRenderer.php
--- a/src/lint/renderer/ArcanistLintRenderer.php
+++ b/src/lint/renderer/ArcanistLintRenderer.php
@@ -16,4 +16,8 @@
return '';
}
+ public function renderLintMessage(ArcanistLintMessage $message) {
+ return '';
+ }
+
}
diff --git a/src/workflow/ArcanistLintWorkflow.php b/src/workflow/ArcanistLintWorkflow.php
--- a/src/workflow/ArcanistLintWorkflow.php
+++ b/src/workflow/ArcanistLintWorkflow.php
@@ -93,6 +93,9 @@
'help' =>
"With 'summary', show lint warnings in a more compact format. ".
"With 'json', show lint warnings in machine-readable JSON format. ".
+ "With 'json-realtime', show lint warnings in JSON format as ".
+ "lint results occur (JSON entries separated by newlines ".
+ "and prefixed with '##arc-lint## '). ".
"With 'none', show no lint warnings. ".
"With 'compiler', show lint warnings in suitable for your editor. ".
"With 'xml', show lint warnings in the Checkstyle XML format.",
@@ -315,6 +318,13 @@
));
}
+ // We only set the renderer on the engine if it's the realtime JSON
+ // renderer.
+ if ($this->getArgument('output') === 'json-realtime') {
+ $engine->setRenderer(new ArcanistJSONLintRenderer());
+ $console->disableOut();
+ }
+
$failed = null;
try {
$engine->run();
@@ -432,6 +442,7 @@
$renderer = new ArcanistSummaryLintRenderer();
break;
case 'none':
+ case 'json-realtime':
$prompt_patches = false;
$apply_patches = $this->getArgument('apply-patches');
$renderer = new ArcanistNoneLintRenderer();
@@ -622,6 +633,10 @@
}
}
+ if ($this->getArgument('output') === 'json-realtime') {
+ $console->enableOut();
+ }
+
return $result_code;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Feb 9, 2:27 AM (4 h, 15 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7104167
Default Alt Text
D11691.id28133.diff (3 KB)
Attached To
Mode
D11691: Allow lint results to be outputted as JSON in realtime
Attached
Detach File
Event Timeline
Log In to Comment