1- (ns com.github.clojure-lsp.intellij.test-utils
1+ (ns com.github.clojure-lsp.intellij.test-utils
22 (:require
33 [com.github.clojure-lsp.intellij.client :as lsp-client]
44 [com.github.clojure-lsp.intellij.server :as server]
55 [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])
87 (:import
98 [com.github.clojure_lsp.intellij.extension SettingsState]
109 [com.intellij.ide DataManager]
1110 [com.intellij.openapi.actionSystem ActionManager]
12- [com.intellij.openapi.components ServiceManager]))
11+ [com.intellij.openapi.components ServiceManager]
12+ [com.intellij.testFramework.fixtures CodeInsightTestFixture]))
1313
1414(set! *warn-on-reflection* true )
1515
1616(defn get-editor-text
1717 " Returns the text content of the editor's document."
18- [fixture]
18+ [^CodeInsightTestFixture fixture]
1919 (-> fixture .getEditor .getDocument .getText))
2020
2121(defn open-file-in-editor
2222 " Opens a file in the editor and returns the editor instance."
23- [fixture file]
23+ [^CodeInsightTestFixture fixture file]
2424 (let [project (.getProject fixture)]
2525 (app-manager/write-command-action
2626 project
4040 action
4141 (com.intellij.openapi.actionSystem.AnActionEvent/createFromDataContext action-id nil context))))))
4242
43- (defn dispatch-all-until
43+ (defn wait-lsp-start
4444 " Dispatches all events until the LSP server is started or the timeout is reached."
4545 [{:keys [project millis timeout]
4646 :or {millis 1000
4949 (loop []
5050 (let [current-time (System/currentTimeMillis )
5151 elapsed-time (- current-time start-time)
52- _ (println " Elapsed time >> " elapsed-time)
5352 status (lsp-client/server-status project)]
5453 (cond
5554 (>= elapsed-time timeout)
9190 (let [my-settings (ServiceManager/getService SettingsState)]
9291 (.loadState my-settings my-settings)
9392 (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