1
- (ns com.github.clojure-lsp.intellij.test-utils
1
+ (ns com.github.clojure-lsp.intellij.test-utils
2
2
(:require
3
3
[com.github.clojure-lsp.intellij.client :as lsp-client]
4
4
[com.github.clojure-lsp.intellij.server :as server]
5
5
[com.github.ericdallo.clj4intellij.app-manager :as app-manager]
6
- [com.github.ericdallo.clj4intellij.test :as clj4intellij.test]
7
- [com.github.clojure-lsp.intellij.db :as db])
6
+ [com.github.ericdallo.clj4intellij.test :as clj4intellij.test])
8
7
(:import
9
8
[com.github.clojure_lsp.intellij.extension SettingsState]
10
9
[com.intellij.ide DataManager]
11
10
[com.intellij.openapi.actionSystem ActionManager]
12
- [com.intellij.openapi.components ServiceManager]))
11
+ [com.intellij.openapi.components ServiceManager]
12
+ [com.intellij.testFramework.fixtures CodeInsightTestFixture]))
13
13
14
14
(set! *warn-on-reflection* true )
15
15
16
16
(defn get-editor-text
17
17
" Returns the text content of the editor's document."
18
- [fixture]
18
+ [^CodeInsightTestFixture fixture]
19
19
(-> fixture .getEditor .getDocument .getText))
20
20
21
21
(defn open-file-in-editor
22
22
" Opens a file in the editor and returns the editor instance."
23
- [fixture file]
23
+ [^CodeInsightTestFixture fixture file]
24
24
(let [project (.getProject fixture)]
25
25
(app-manager/write-command-action
26
26
project
40
40
action
41
41
(com.intellij.openapi.actionSystem.AnActionEvent/createFromDataContext action-id nil context))))))
42
42
43
- (defn dispatch-all-until
43
+ (defn wait-lsp-start
44
44
" Dispatches all events until the LSP server is started or the timeout is reached."
45
45
[{:keys [project millis timeout]
46
46
:or {millis 1000
49
49
(loop []
50
50
(let [current-time (System/currentTimeMillis )
51
51
elapsed-time (- current-time start-time)
52
- _ (println " Elapsed time >> " elapsed-time)
53
52
status (lsp-client/server-status project)]
54
53
(cond
55
54
(>= elapsed-time timeout)
91
90
(let [my-settings (ServiceManager/getService SettingsState)]
92
91
(.loadState my-settings my-settings)
93
92
(clj4intellij.test/dispatch-all )
94
- (dispatch-all-until {:project project})
95
- (println " status LSP >> " (db/get-in project [:status ]))))
93
+ (wait-lsp-start {:project project})))
0 commit comments