Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Trying to get a flycheck checker that will be a callback from url-retrieve
(require 'flycheck)
(defun malabar-flycheck-command ( checker cback )
"Use flycheck to search the current buffer for compiler errrors."
(if (not (comint-check-proc "*groovy*"))
(funcall cback 'finished nil)
(let* ((pom (ede-find-project-root "pom.xml"))
(pom-path (format "%spom.xml" pom))
(script (if (buffer-modified-p) (buffer-file-name) (buffer-file-name))))
(malabar-parse-script-raw
(lambda (status)
(message "%s %s %s" status (current-buffer) url-http-end-of-headers)
;(condition-case err
(progn
(goto-char url-http-end-of-headers)
(let ((error-list (malabar-flycheck-error-parser (json-read) "hamster")))
(message "ERROR LIST:%s" error-list)
(funcall cback 'finished error-list))))
;(error (let ((msg (error-message-string err)))
; (message "flycheck error: %s" msg)
; (funcall cback 'errored msg)))))
pom-path script))))
(defun malabar-flycheck-error-new (checker error-info)
(flycheck-error-new
:buffer (current-buffer)
:checker checker
:filename (cdr (assq 'sourceLocator error-info))
:line (cdr (assq 'line error-info))
:column (cdr (assq 'startColumn error-info))
:message (cdr (assq 'message error-info))
:level 'error))
(defun malabar-flycheck-error-parser (output checker)
"Parse errors in OUTPUT which is a JSON array"
(let ((rtnval (mapcar (lambda (e)
(malabar-flycheck-error-new checker e))
output)))
rtnval))
(flycheck-define-generic-checker 'jvm-mode-malabar
"Integrate flycheck with the malabar JVM service."
:start #'malabar-flycheck-command
:modes '(java-mode groovy-mode)
)
(add-to-list 'flycheck-checkers 'jvm-mode-malabar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.