Changeset View
Changeset View
Standalone View
Standalone View
src/lint/renderer/ArcanistCheckstyleXMLLintRenderer.php
| <?php | <?php | ||||
| /** | |||||
| * Shows lint messages to the user. | |||||
| */ | |||||
| final class ArcanistCheckstyleXMLLintRenderer extends ArcanistLintRenderer { | final class ArcanistCheckstyleXMLLintRenderer extends ArcanistLintRenderer { | ||||
| const RENDERERKEY = 'xml'; | |||||
| private $writer; | private $writer; | ||||
| public function __construct() { | public function __construct() { | ||||
| $this->writer = new XMLWriter(); | $this->writer = new XMLWriter(); | ||||
| $this->writer->openMemory(); | $this->writer->openMemory(); | ||||
| $this->writer->setIndent(true); | $this->writer->setIndent(true); | ||||
| $this->writer->setIndentString(' '); | $this->writer->setIndentString(' '); | ||||
| } | } | ||||
| public function renderPreamble() { | public function willRenderResults() { | ||||
| $this->writer->startDocument('1.0', 'UTF-8'); | $this->writer->startDocument('1.0', 'UTF-8'); | ||||
| $this->writer->startElement('checkstyle'); | $this->writer->startElement('checkstyle'); | ||||
| $this->writer->writeAttribute('version', '4.3'); | $this->writer->writeAttribute('version', '4.3'); | ||||
| return $this->writer->flush(); | $this->writeOut($this->writer->flush()); | ||||
| } | } | ||||
| public function renderLintResult(ArcanistLintResult $result) { | public function renderLintResult(ArcanistLintResult $result) { | ||||
| $this->writer->startElement('file'); | $this->writer->startElement('file'); | ||||
| $this->writer->writeAttribute('name', $result->getPath()); | $this->writer->writeAttribute('name', $result->getPath()); | ||||
| foreach ($result->getMessages() as $message) { | foreach ($result->getMessages() as $message) { | ||||
| $this->writer->startElement('error'); | $this->writer->startElement('error'); | ||||
| $this->writer->writeAttribute('line', $message->getLine()); | $this->writer->writeAttribute('line', $message->getLine()); | ||||
| $this->writer->writeAttribute('column', $message->getChar()); | $this->writer->writeAttribute('column', $message->getChar()); | ||||
| $this->writer->writeAttribute('severity', | $this->writer->writeAttribute('severity', | ||||
| $this->getStringForSeverity($message->getSeverity())); | $this->getStringForSeverity($message->getSeverity())); | ||||
| $this->writer->writeAttribute('message', $message->getDescription()); | $this->writer->writeAttribute('message', $message->getDescription()); | ||||
| $this->writer->writeAttribute('source', $message->getCode()); | $this->writer->writeAttribute('source', $message->getCode()); | ||||
| $this->writer->endElement(); | $this->writer->endElement(); | ||||
| } | } | ||||
| $this->writer->endElement(); | $this->writer->endElement(); | ||||
| return $this->writer->flush(); | $this->writeOut($this->writer->flush()); | ||||
| } | |||||
| public function renderOkayResult() { | |||||
| return ''; | |||||
| } | } | ||||
| public function renderPostamble() { | public function didRenderResults() { | ||||
| $this->writer->endElement(); | $this->writer->endElement(); | ||||
| $this->writer->endDocument(); | $this->writer->endDocument(); | ||||
| return $this->writer->flush(); | $this->writeOut($this->writer->flush()); | ||||
| } | } | ||||
| private function getStringForSeverity($severity) { | private function getStringForSeverity($severity) { | ||||
| switch ($severity) { | switch ($severity) { | ||||
| case ArcanistLintSeverity::SEVERITY_ADVICE: | case ArcanistLintSeverity::SEVERITY_ADVICE: | ||||
| return 'info'; | return 'info'; | ||||
| case ArcanistLintSeverity::SEVERITY_AUTOFIX: | case ArcanistLintSeverity::SEVERITY_AUTOFIX: | ||||
| return 'info'; | return 'info'; | ||||
| Show All 10 Lines | |||||