From 69585d4aeb0297992b70c0e4a4ed98cd1d65b1b4 Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Mon, 14 May 2018 18:30:00 +0200 Subject: [PATCH 1/2] Flycheck: Add predicate function Prevents calling checker when FSharp.AutoComplete process is not ready to handle requests. Refs #167 --- flycheck-fsharp.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flycheck-fsharp.el b/flycheck-fsharp.el index 59a634f..ec18626 100644 --- a/flycheck-fsharp.el +++ b/flycheck-fsharp.el @@ -48,6 +48,7 @@ CALLBACK is the status callback passed by Flycheck." "A syntax checker for F# using FSharp.AutoComplete. See URL `https://github.com/fsharp/FsAutoComplete'." :start #'flycheck-fsharp-fsautocomplete-lint-start + :predicate (lambda () (fsharp-ac-can-make-request t)) :modes '(fsharp-mode)) (defvar flycheck-fsharp--error-callback-info nil) @@ -63,6 +64,7 @@ CALLBACK is the status callback passed by Flycheck." See URL `https://github.com/fsharp/FsAutoComplete'." :start #'flycheck-fsharp-fsautocomplete-start :modes '(fsharp-mode) + :predicate (lambda () (fsharp-ac-can-make-request t)) :next-checkers '((info . fsharp-fsautocomplete-lint))) (defun flycheck-fsharp-handle-lint (data) From 4820cf5ff02d96d5aff6ea9abb3941da652f8d5c Mon Sep 17 00:00:00 2001 From: Juergen Hoetzel Date: Tue, 15 May 2018 08:24:24 +0200 Subject: [PATCH 2/2] Use flycheck-fsharp--can-make-request-p instead of lambda expression This allows flet mocking in tests. Refs #167 --- flycheck-fsharp.el | 7 +++++-- test/test-common.el | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/flycheck-fsharp.el b/flycheck-fsharp.el index ec18626..de069d5 100644 --- a/flycheck-fsharp.el +++ b/flycheck-fsharp.el @@ -34,6 +34,9 @@ (defvar flycheck-fsharp--lint-callback-info nil) +(defun flycheck-fsharp--can-make-request-p () + (fsharp-ac-can-make-request t)) + (defun flycheck-fsharp-fsautocomplete-lint-start (checker callback) "Start a F# syntax check with CHECKER. CALLBACK is the status callback passed by Flycheck." @@ -48,7 +51,7 @@ CALLBACK is the status callback passed by Flycheck." "A syntax checker for F# using FSharp.AutoComplete. See URL `https://github.com/fsharp/FsAutoComplete'." :start #'flycheck-fsharp-fsautocomplete-lint-start - :predicate (lambda () (fsharp-ac-can-make-request t)) + :predicate #'flycheck-fsharp--can-make-request-p :modes '(fsharp-mode)) (defvar flycheck-fsharp--error-callback-info nil) @@ -64,7 +67,7 @@ CALLBACK is the status callback passed by Flycheck." See URL `https://github.com/fsharp/FsAutoComplete'." :start #'flycheck-fsharp-fsautocomplete-start :modes '(fsharp-mode) - :predicate (lambda () (fsharp-ac-can-make-request t)) + :predicate #'flycheck-fsharp--can-make-request-p :next-checkers '((info . fsharp-fsautocomplete-lint))) (defun flycheck-fsharp-handle-lint (data) diff --git a/test/test-common.el b/test/test-common.el index 56d4928..ef079f9 100644 --- a/test/test-common.el +++ b/test/test-common.el @@ -29,6 +29,7 @@ (defmacro stubbing-process-functions (&rest body) `(noflet ((process-live-p (p) t) (fsharp-ac--process-live-p (host) t) + (flycheck-fsharp--can-make-request-p () t) (start-process (&rest args)) (set-process-filter (&rest args)) (set-process-query-on-exit-flag (&rest args))