|
131 | 131 | (into {} (map (fn [[k v]] [(f k) v]) m)))
|
132 | 132 |
|
133 | 133 | (defn- convert-to-clojure
|
134 |
| - [class-name] |
| 134 | + [class-name method-name] |
135 | 135 | (let [[namespace-name & raw-function-ids] (str/split class-name #"\$")
|
136 | 136 | ;; Clojure adds __1234 unique ids to the ends of things, remove those.
|
137 |
| - function-ids (map #(str/replace % #"__\d+" "") raw-function-ids)] |
| 137 | + function-ids (map #(str/replace % #"__\d+" "") raw-function-ids) |
| 138 | + ;; In a degenerate case, a protocol method could be called "invoke" or "doInvoke"; we're ignoring |
| 139 | + ;; that possibility here and assuming it's the IFn.invoke() or doInvoke(). |
| 140 | + all-ids (if (contains? #{"invoke" "doInvoke"} method-name) |
| 141 | + function-ids |
| 142 | + (-> function-ids vec (conj method-name)))] |
138 | 143 | ;; The assumption is that no real namespace or function name will contain underscores (the underscores
|
139 | 144 | ;; are name-mangled dashes).
|
140 |
| - (->> (cons namespace-name function-ids) (map demangle)))) |
| 145 | + (->> |
| 146 | + (cons namespace-name all-ids) |
| 147 | + (map demangle)))) |
141 | 148 |
|
142 | 149 | (defn- expand-stack-trace-element
|
143 | 150 | [^StackTraceElement element]
|
144 | 151 | (let [class-name (.getClassName element)
|
145 | 152 | method-name (.getMethodName element)
|
146 | 153 | dotx (.lastIndexOf class-name ".")
|
147 | 154 | file-name (or (.getFileName element) "")
|
148 |
| - is-clojure? (and (.endsWith file-name ".clj") |
149 |
| - (contains? #{"invoke" "doInvoke"} method-name)) |
150 |
| - names (if is-clojure? (convert-to-clojure class-name) []) |
| 155 | + is-clojure? (.endsWith file-name ".clj") |
| 156 | + names (if is-clojure? (convert-to-clojure class-name method-name) []) |
151 | 157 | name (str/join "/" names)
|
152 | 158 | line (-> element .getLineNumber)]
|
153 |
| - {:file file-name |
154 |
| - :line (if (pos? line) line) |
155 |
| - :class class-name |
156 |
| - :package (if (pos? dotx) (.substring class-name 0 dotx)) |
| 159 | + {:file file-name |
| 160 | + :line (if (pos? line) line) |
| 161 | + :class class-name |
| 162 | + :package (if (pos? dotx) (.substring class-name 0 dotx)) |
157 | 163 | :simple-class (if (pos? dotx)
|
158 | 164 | (.substring class-name (inc dotx))
|
159 | 165 | class-name)
|
160 |
| - :method method-name |
| 166 | + :method method-name |
161 | 167 | ;; Used to calculate column width
|
162 |
| - :name name |
| 168 | + :name name |
163 | 169 | ;; Used to present compound name with last term highlighted
|
164 |
| - :names names})) |
| 170 | + :names names})) |
165 | 171 |
|
166 | 172 | (def ^:private empty-stack-trace-warning
|
167 | 173 | "Stack trace of root exception is empty; this is likely due to a JVM optimization that can be disabled with -XX:-OmitStackTraceInFastThrow.")
|
|
0 commit comments