Previously external-ns? only included clojure.* and java.* namespaces, missing project dependencies like tui.events. This prevented cross-repo go-to-definition from working. Changes: - external-ns? now considers any non-internal namespace as external - collect-external-symbols creates symbol entries even without runtime docs - This enables hover and go-to-definition for dependency symbols Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
+16
-13
@@ -206,13 +206,11 @@
|
||||
:special-form true}))
|
||||
|
||||
(defn external-ns?
|
||||
"Check if a namespace is external (standard library or dependency)."
|
||||
"Check if a namespace is external (not defined in this project).
|
||||
Any namespace not in internal-namespaces is considered external,
|
||||
enabling cross-repo navigation to dependencies."
|
||||
[ns-sym internal-namespaces]
|
||||
(let [ns-str (str ns-sym)]
|
||||
(and (not (contains? internal-namespaces ns-sym))
|
||||
(or (str/starts-with? ns-str "clojure.")
|
||||
(str/starts-with? ns-str "java.")
|
||||
(contains? external-ns-prefixes ns-str)))))
|
||||
(not (contains? internal-namespaces ns-sym)))
|
||||
|
||||
(defn get-var-doc
|
||||
"Get documentation for a var. Returns a map with :doc, :arglists, :macro.
|
||||
@@ -236,7 +234,8 @@
|
||||
(catch Exception _ nil))))
|
||||
|
||||
(defn external-symbol->symbol-info
|
||||
"Create SCIP SymbolInformation for an external symbol with documentation."
|
||||
"Create SCIP SymbolInformation for an external symbol.
|
||||
Works with or without documentation - symbol entry is essential for cross-repo nav."
|
||||
[{:keys [ns name doc arglists macro special-form]}]
|
||||
(let [builder (Scip$SymbolInformation/newBuilder)
|
||||
sig (str (cond special-form "special form "
|
||||
@@ -246,25 +245,29 @@
|
||||
(.setSymbol builder (make-symbol ns name))
|
||||
;; Add signature as first doc line
|
||||
(.addDocumentation builder (str "```clojure\n" sig "\n```"))
|
||||
;; Add arglists
|
||||
;; Add arglists if available
|
||||
(when (seq arglists)
|
||||
(.addDocumentation builder (str "```clojure\n" (format-arglists arglists) "\n```")))
|
||||
;; Add docstring
|
||||
;; Add docstring if available
|
||||
(when doc
|
||||
(.addDocumentation builder doc))
|
||||
(.build builder)))
|
||||
|
||||
(defn collect-external-symbols
|
||||
"Collect all unique external symbol references from analysis."
|
||||
"Collect all unique external symbol references from analysis.
|
||||
Returns symbol info for all external symbols, with docs when available.
|
||||
Essential for cross-repo navigation to dependencies."
|
||||
[analysis internal-namespaces]
|
||||
(->> (vals analysis)
|
||||
(mapcat :var-usages)
|
||||
(filter #(external-ns? (:to %) internal-namespaces))
|
||||
(map (fn [{:keys [to name]}] [to name]))
|
||||
(filter (fn [[ns-sym _]] ns-sym)) ; Filter out nil namespaces
|
||||
(distinct)
|
||||
(keep (fn [[ns-sym var-name]]
|
||||
(get-var-doc ns-sym var-name)))
|
||||
(filter :doc))) ; Only include symbols with documentation
|
||||
(map (fn [[ns-sym var-name]]
|
||||
;; Try to get docs, but always return at minimum ns/name
|
||||
(or (get-var-doc ns-sym var-name)
|
||||
{:ns ns-sym :name var-name})))))
|
||||
|
||||
(defn uri->relative-path
|
||||
"Convert file:// URI to relative path from project root."
|
||||
|
||||
Reference in New Issue
Block a user