Make a mage task to generate resolve-as XML from clj-kondo lint-as data (#70342)

This commit is contained in:
Ben Grabow
2026-03-03 15:33:17 -06:00
committed by GitHub
parent d4a888c2ec
commit 693ac2a9ce
2 changed files with 29 additions and 1 deletions

10
bb.edn
View File

@@ -247,6 +247,14 @@
:requires [[mage.util :as u]]
:task (task! (u/print-tasks parsed))}
generate-cursive-resolve-as
{:doc "Generate XML configuration for Cursive's symbol resolution based on the current clj-kondo lint-as configuration."
:examples [["./bin/mage generate-cursive-resolve-as" "Generate resolve-as XML configuration"]
["./bin/mage generate-cursive-resolve-as > /Users/bgrabow/Library/Application\\ Support/JetBrains/IntelliJIdea2025.3/options/ClojureResolveSettings.xml"
"Generate resolve-as XML configuration and install it in your global editor configuration"]]
:requires [[mage.cursive-resolve-as :as cursive-resolve-as]]
:task (task! (cursive-resolve-as/do-it))}
analytics:setup
{:doc "Set up usage analytics development mode"
:examples [["./bin/mage analytics:setup" "Enable usage analytics dev mode and import content"]]
@@ -302,7 +310,7 @@
"If you see 'gh: command not found' or auth errors, run: gh auth login"))
:requires [[mage.ci-report :as ci-report]]
:task (task! (ci-report/generate-report! parsed))}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Private Tasks:
;; These tasks are more for internal tooling, e.g. for use from git hooks etc.

View File

@@ -0,0 +1,20 @@
(ns mage.cursive-resolve-as
(:require [clojure.edn :as edn]
[clojure.string :as str]))
(defn clj-kondo-lint-as->cursive-resolve-as
[lint-as]
(str/join \newline
(reduce concat
[]
[["<application>" " <component name=\"ClojureResolveSettings\">"]
(for [[left right] lint-as]
(format " <item key=\"%s\" resolves-as=\"%s\" />" left right))
[" </component>" "</application>"]])))
(defn do-it
[]
(println (clj-kondo-lint-as->cursive-resolve-as
(:lint-as (edn/read-string (slurp ".clj-kondo/config.edn"))))))