|
17 | 17 |
|
18 | 18 | (set! *warn-on-reflection* true) |
19 | 19 |
|
| 20 | +(defn dispatch-all-until |
| 21 | + [{:keys [project millis timeout] |
| 22 | + :or {millis 1000 |
| 23 | + timeout 10000}}] |
| 24 | + (let [start-time (System/currentTimeMillis)] |
| 25 | + (loop [] |
| 26 | + (let [current-time (System/currentTimeMillis) |
| 27 | + elapsed-time (- current-time start-time) |
| 28 | + _ (println "Elapsed time >> "elapsed-time) |
| 29 | + status (lsp-client/server-status project)] |
| 30 | + (cond |
| 31 | + (>= elapsed-time timeout) |
| 32 | + (throw (ex-info "LSP server failed to start within timeout" |
| 33 | + {:elapsed-time elapsed-time |
| 34 | + :final-status status})) |
| 35 | + |
| 36 | + (= status :started) |
| 37 | + true |
| 38 | + |
| 39 | + :else |
| 40 | + (do |
| 41 | + (clj4intellij.test/dispatch-all) |
| 42 | + (Thread/sleep millis) |
| 43 | + (recur))))))) |
| 44 | + |
20 | 45 |
|
21 | 46 | (defn get-status-bar-widget [project widget-id] |
22 | 47 | (let [status-bar (.. (WindowManager/getInstance) (getStatusBar project))] |
|
25 | 50 | (defn run-editor-action [action-id project] |
26 | 51 | (let [action (.getAction (ActionManager/getInstance) action-id) |
27 | 52 | context (.getDataContext (DataManager/getInstance))] |
28 | | - |
29 | | - |
30 | 53 | (println "Running action:" action-id) |
31 | 54 | (println "Action:" action) |
32 | 55 | (app-manager/write-command-action |
|
53 | 76 |
|
54 | 77 | ;; Para configurações persistentes via ServiceManager |
55 | 78 | (let [my-settings (ServiceManager/getService SettingsState)] ;; Substitua pela classe real |
56 | | - (.setServerPath my-settings "/tmp/clojure-lsp") ;; Atualiza o caminho do servidor |
| 79 | + #_(.setServerPath my-settings "/tmp/clojure-lsp") ;; Atualiza o caminho do servidor |
57 | 80 | (.loadState my-settings my-settings));; Atualiza estado |
58 | 81 | (println "LSP exists? >> ") |
59 | | - (println (.exists (io/as-file "/tmp/clojure-lsp"))) |
60 | | - (server/start! project) |
| 82 | + #_(println (.exists (io/as-file "/tmp/clojure-lsp"))) |
| 83 | + #_(server/start! project) |
61 | 84 |
|
62 | | - #_(clj4intellij.test/dispatch-all) |
| 85 | + (clj4intellij.test/dispatch-all) |
63 | 86 | (println "status LSP >> ") |
64 | 87 | (println (lsp-client/server-status project)) |
65 | 88 | (println (db/get-in project [:status])) |
66 | | - (Thread/sleep 10000) |
67 | | - #_(clj4intellij.test/dispatch-all-until |
68 | | - {:cond-fn (fn [] (= (db/get-in project [:status]) :started)) |
69 | | - :millis 3000}) |
| 89 | + #_(Thread/sleep 10000) |
| 90 | + (dispatch-all-until {:project project}) |
| 91 | + #_(dispatch-all-until |
| 92 | + {:cond-fn (fn [] |
| 93 | + (let [status (lsp-client/server-status project)] |
| 94 | + (println "Current status:" status) |
| 95 | + (= status :started))) |
| 96 | + :millis 1000}) |
70 | 97 | (println "status LSP >> ") |
71 | 98 | (println (lsp-client/server-status project)) |
72 | 99 | (println (db/get-in project [:status])) |
|
94 | 121 | (clj4intellij.test/dispatch-all) |
95 | 122 | (println (-> fixture .getEditor .getDocument .getText)) |
96 | 123 |
|
97 | | - @(app-manager/invoke-later! |
| 124 | + #_@(app-manager/invoke-later! |
98 | 125 | {:invoke-fn (fn [] |
99 | 126 | (let [widget (get-status-bar-widget project "ClojureLSPStatusBar")] |
100 | 127 | (println "Widget:" widget) |
101 | 128 | (is (some? widget))))}) |
102 | 129 |
|
103 | 130 | (.checkResultByFile fixture "foo_expected.clj") |
104 | | - |
105 | | - (is false))) |
| 131 | + (server/shutdown! project))) |
106 | 132 |
|
107 | 133 |
|
0 commit comments