summaryrefslogtreecommitdiff
path: root/tools/php-sqllint/src/phpsqllint/Renderer/Emacs.php
blob: 3a667c7f6e738423aa0ea1b77ae70a57fb996a77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/**
 * Part of php-sqllint
 *
 * PHP version 5
 *
 * @category Tools
 * @package  PHP-SQLlint
 * @author   Christian Weiske <cweiske@cweiske.de>
 * @license  http://www.gnu.org/licenses/agpl.html GNU AGPL v3
 * @link     http://cweiske.de/php-sqllint.htm
 */
namespace phpsqllint;

/**
 * Output for emacs' compilation mode
 *
 * @category Tools
 * @package  PHP-SQLlint
 * @author   Christian Weiske <cweiske@cweiske.de>
 * @license  http://www.gnu.org/licenses/agpl.html GNU AGPL v3
 * @link     http://www.emacswiki.org/emacs/CreatingYourOwnCompileErrorRegexp
 */
class Renderer_Emacs implements Renderer
{
    protected $filename;

    /**
     * Begin syntax check output rendering
     *
     * @param string $filename Path to the SQL file
     *
     * @return void
     */
    public function startRendering($filename)
    {
        $this->filename = $filename;
    }

    /**
     * Output errors in GNU style; see emacs compilation.txt
     *
     * @param string  $msg   Error message
     * @param string  $token Character which caused the error
     * @param integer $line  Line at which the error occured
     * @param integer $col   Column at which the error occured
     *
     * @return void
     */
    public function displayError($msg, $token, $line, $col)
    {
        echo $this->filename
            . ':' . $line
            . '.' . $col
            . ':Error:'
            . ' '. $msg
            . "\n";
    }

    /**
     * Finish syntax check output rendering; no syntax errors found
     *
     * @return void
     */
    public function finishOk()
    {
        //do nothing
    }
}
?>