|
14 | 14 | Position
|
15 | 15 | ReferenceContext
|
16 | 16 | ReferenceParams
|
17 |
| - TextDocumentIdentifier])) |
| 17 | + TextDocumentIdentifier |
| 18 | + WorkspaceSymbolParams] |
| 19 | + [org.eclipse.lsp4j.jsonrpc.messages Either])) |
18 | 20 |
|
19 | 21 | (set! *warn-on-reflection* true)
|
20 | 22 |
|
| 23 | +(defn project->ls-server-item ^LanguageServerItem |
| 24 | + [^Project project] |
| 25 | + (when-let [manager (LanguageServerManager/getInstance project)] |
| 26 | + @(.getLanguageServer manager "clojure-lsp"))) |
| 27 | + |
| 28 | +(defn ^:private project->ls-server ^ClojureLanguageServer [project] |
| 29 | + (when-let [item (project->ls-server-item project)] |
| 30 | + (.getServer item))) |
| 31 | + |
21 | 32 | (defn server-status [^Project project]
|
22 | 33 | (when-let [manager (LanguageServerManager/getInstance project)]
|
23 | 34 | (keyword (.toString (.getServerStatus manager "clojure-lsp")))))
|
24 | 35 |
|
25 | 36 | (defn server-info [^Project project]
|
26 | 37 | (when (identical? :started (lsp-client/server-status project))
|
27 |
| - (when-let [manager (LanguageServerManager/getInstance project)] |
28 |
| - (when-let [server (.getServer ^LanguageServerItem @(.getLanguageServer manager "clojure-lsp"))] |
29 |
| - (some->> (.serverInfo ^ClojureLanguageServer server) |
30 |
| - deref |
31 |
| - (into {}) |
32 |
| - walk/keywordize-keys))))) |
| 38 | + (when-let [server (project->ls-server project)] |
| 39 | + (some->> (.serverInfo ^ClojureLanguageServer server) |
| 40 | + deref |
| 41 | + (into {}) |
| 42 | + walk/keywordize-keys)))) |
33 | 43 |
|
34 | 44 | (defn dependency-contents [^String uri ^Project project]
|
35 |
| - (when-let [manager (LanguageServerManager/getInstance project)] |
36 |
| - (when-let [server (.getServer ^LanguageServerItem @(.getLanguageServer manager "clojure-lsp"))] |
37 |
| - (some->> (.dependencyContents ^ClojureLanguageServer server {"uri" uri}) |
38 |
| - deref)))) |
| 45 | + (when-let [server (project->ls-server project)] |
| 46 | + (some->> (.dependencyContents ^ClojureLanguageServer server {"uri" uri}) |
| 47 | + deref))) |
39 | 48 |
|
40 | 49 | (defn references [^String uri line character ^Project project]
|
41 |
| - (when-let [manager (LanguageServerManager/getInstance project)] |
42 |
| - (when-let [server (.getServer ^LanguageServerItem @(.getLanguageServer manager "clojure-lsp"))] |
43 |
| - (some-> (.getTextDocumentService ^ClojureLanguageServer server) |
44 |
| - (.references (ReferenceParams. (TextDocumentIdentifier. uri) |
45 |
| - (Position. line character) |
46 |
| - (ReferenceContext. false))) |
47 |
| - deref)))) |
| 50 | + (when-let [server (project->ls-server project)] |
| 51 | + (some-> (.getTextDocumentService ^ClojureLanguageServer server) |
| 52 | + (.references (ReferenceParams. (TextDocumentIdentifier. uri) |
| 53 | + (Position. line character) |
| 54 | + (ReferenceContext. false))) |
| 55 | + deref))) |
| 56 | + |
| 57 | +(defn symbols [^String query ^Project project] |
| 58 | + (when-let [server (project->ls-server project)] |
| 59 | + (some-> (.getWorkspaceService ^ClojureLanguageServer server) |
| 60 | + (.symbol (WorkspaceSymbolParams. query)) |
| 61 | + ^Either deref |
| 62 | + .get))) |
48 | 63 |
|
49 | 64 | (defn execute-command [^String name ^String text ^List args ^Project project]
|
50 | 65 | (try
|
|
54 | 69 | (.response)
|
55 | 70 | deref)
|
56 | 71 | (catch Exception e
|
57 |
| - (logger/error "Error appllying command" name (with-out-str (.printStackTrace e)))))) |
| 72 | + (logger/error (format "Error applying command '%s' with args '%s' for text '%s'" name args text) |
| 73 | + (with-out-str (.printStackTrace e)))))) |
0 commit comments