~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to src/lint/renderer/ArcanistCheckstyleXMLLintRenderer.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-11-01 23:20:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141101232006-mvlnp0cil67tsboe
Tags: upstream-0~git20141101/arcanist
Import upstream version 0~git20141101, component arcanist

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Shows lint messages to the user.
 
5
 */
 
6
final class ArcanistCheckstyleXMLLintRenderer extends ArcanistLintRenderer {
 
7
 
 
8
  private $writer;
 
9
 
 
10
  public function __construct() {
 
11
    $this->writer = new XMLWriter();
 
12
    $this->writer->openMemory();
 
13
    $this->writer->setIndent(true);
 
14
    $this->writer->setIndentString('  ');
 
15
  }
 
16
 
 
17
  public function renderPreamble() {
 
18
    $this->writer->startDocument('1.0', 'UTF-8');
 
19
    $this->writer->startElement('checkstyle');
 
20
    $this->writer->writeAttribute('version', '4.3');
 
21
    return $this->writer->flush();
 
22
  }
 
23
 
 
24
  public function renderLintResult(ArcanistLintResult $result) {
 
25
    $this->writer->startElement('file');
 
26
    $this->writer->writeAttribute('name', $result->getPath());
 
27
 
 
28
    foreach ($result->getMessages() as $message) {
 
29
      $this->writer->startElement('error');
 
30
 
 
31
      $this->writer->writeAttribute('line', $message->getLine());
 
32
      $this->writer->writeAttribute('column', $message->getChar());
 
33
      $this->writer->writeAttribute('severity',
 
34
        ArcanistLintSeverity::getStringForSeverity($message->getSeverity()));
 
35
      $this->writer->writeAttribute('message', $message->getDescription());
 
36
      $this->writer->writeAttribute('source', $message->getCode());
 
37
 
 
38
      $this->writer->endElement();
 
39
    }
 
40
 
 
41
    $this->writer->endElement();
 
42
    return $this->writer->flush();
 
43
  }
 
44
 
 
45
  public function renderOkayResult() {
 
46
    return '';
 
47
  }
 
48
 
 
49
  public function renderPostamble() {
 
50
    $this->writer->endElement();
 
51
    $this->writer->endDocument();
 
52
    return $this->writer->flush();
 
53
  }
 
54
 
 
55
}