|
36 | 36 | ;;; Code: |
37 | 37 | (require 'flymake) |
38 | 38 | (require 'phpstan) |
| 39 | +(eval-when-compile |
| 40 | + (require 'pcase)) |
39 | 41 |
|
40 | 42 | (defgroup flymake-phpstan nil |
41 | 43 | "Flymake backend for PHP using PHPStan." |
|
57 | 59 | :command command-args |
58 | 60 | :sentinel |
59 | 61 | (lambda (proc _event) |
60 | | - (case (process-status proc)) |
61 | | - ((exit) |
62 | | - (unwind-protect |
63 | | - (when (with-current-buffer source (eq proc flymake-phpstan--proc)) |
64 | | - (with-current-buffer (process-buffer proc) |
65 | | - (goto-char (point-min)) |
66 | | - (cl-loop |
67 | | - while (search-forward-regexp |
68 | | - (eval-when-compile |
69 | | - (rx line-start (1+ (not (any ":"))) ":" |
70 | | - (group-n 1 (one-or-more digit)) ":" |
71 | | - (group-n 2 (one-or-more not-newline)) line-end)) |
72 | | - nil t) |
73 | | - for msg = (match-string 2) |
74 | | - for (beg . end) = (flymake-diag-region |
75 | | - source |
76 | | - (string-to-number (match-string 1))) |
77 | | - for type = :warning |
78 | | - collect (flymake-make-diagnostic source beg end type msg) |
79 | | - into diags |
80 | | - finally (funcall report-fn diags))) |
81 | | - (flymake-log :warning "Canceling obsolete check %s" proc)) |
82 | | - (kill-buffer (process-buffer proc)))) |
83 | | - (user-error "PHPStan error"))))) |
| 62 | + (pcase (process-status proc) |
| 63 | + (`exit |
| 64 | + (unwind-protect |
| 65 | + (when (with-current-buffer source (eq proc flymake-phpstan--proc)) |
| 66 | + (with-current-buffer (process-buffer proc) |
| 67 | + (goto-char (point-min)) |
| 68 | + (cl-loop |
| 69 | + while (search-forward-regexp |
| 70 | + (eval-when-compile |
| 71 | + (rx line-start (1+ (not (any ":"))) ":" |
| 72 | + (group-n 1 (one-or-more digit)) ":" |
| 73 | + (group-n 2 (one-or-more not-newline)) line-end)) |
| 74 | + nil t) |
| 75 | + for msg = (match-string 2) |
| 76 | + for (beg . end) = (flymake-diag-region |
| 77 | + source |
| 78 | + (string-to-number (match-string 1))) |
| 79 | + for type = :warning |
| 80 | + collect (flymake-make-diagnostic source beg end type msg) |
| 81 | + into diags |
| 82 | + finally (funcall report-fn diags))) |
| 83 | + (flymake-log :warning "Canceling obsolete check %s" proc)) |
| 84 | + (kill-buffer (process-buffer proc)))) |
| 85 | + (code (user-error "PHPStan error (exit status: %d)" code))))))) |
84 | 86 |
|
85 | 87 | (defun flymake-phpstan (report-fn &rest _ignored-args) |
86 | 88 | "Flymake backend for PHPStan report using REPORT-FN." |
|
0 commit comments