Created
February 5, 2017 20:45
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
______________________________________ | |
user> ERROR: Unhandled REPL handler exception processing message {:file (ns cursive.repl.runtime | |
(:import [java.lang.reflect Method Field Constructor]) | |
(:require [clojure.reflect :as reflect] | |
[clojure.set :as set])) | |
(def mappings {:macro identity | |
:ns (comp name ns-name) | |
:name name | |
:arglists #(mapv str %) | |
:doc identity | |
:line identity | |
:file identity | |
:private identity}) | |
(defn mapped-metadata [v] | |
(let [metadata (meta v)] | |
(into {} (for [[key mapping] mappings] | |
(if (contains? metadata key) | |
[key (mapping (get metadata key))]))))) | |
(defn symbol-details [sym] | |
(if-let [var (resolve sym)] | |
(mapped-metadata var))) | |
(defn ns-symbols-by-name [ns-name] | |
(if-let [the-ns (find-ns ns-name)] | |
(->> (vals (ns-interns the-ns)) | |
(filter var?) | |
(mapv mapped-metadata)))) | |
(defn completions [ns] | |
(if-let [ns (find-ns ns)] | |
{:imports (into {} (for [[sym ^Class class] (ns-imports ns)] | |
[(name sym) (.getName class)])) | |
:symbols (into {} (for [[k v] (ns-map ns) :when (var? v)] | |
[(name k) (mapped-metadata v)])) | |
:namespaces (set (map (comp name ns-name) (all-ns))) | |
:aliases (into {} (for [[alias fqn] (ns-aliases ns)] | |
[(str alias) (str fqn)]))} | |
{})) | |
(defn class-exists? [fqn] | |
(try | |
(Class/forName fqn false (.getContextClassLoader (Thread/currentThread))) | |
true | |
(catch Throwable _ | |
false))) | |
; Code from clojure.reflect modified to return strings instead of symbols, | |
; and to use getFields/Methods/Constructors instead of getDeclared forms | |
(def parse-flags #'reflect/parse-flags) | |
(defn constructor->map [^Constructor constructor] | |
{:name (.getName constructor) | |
:declaring-class (reflect/typename (.getDeclaringClass constructor)) | |
:parameter-types (mapv reflect/typename (.getParameterTypes constructor)) | |
:exception-types (mapv reflect/typename (.getExceptionTypes constructor)) | |
:flags (parse-flags (.getModifiers constructor) :constructor)}) | |
(defn method->map [^Method method] | |
{:name (.getName method) | |
:return-type (reflect/typename (.getReturnType method)) | |
:declaring-class (reflect/typename (.getDeclaringClass method)) | |
:parameter-types (mapv reflect/typename (.getParameterTypes method)) | |
:exception-types (mapv reflect/typename (.getExceptionTypes method)) | |
:flags (parse-flags (.getModifiers method) :method)}) | |
(defn field->map [^Field field] | |
{:name (.getName field) | |
:type (reflect/typename (.getType field)) | |
:declaring-class (reflect/typename (.getDeclaringClass field)) | |
:flags (parse-flags (.getModifiers field) :field)}) | |
(defn class-defs [fqns] | |
(into {} (for [fqn fqns] | |
(try | |
[fqn (let [cls (Class/forName fqn)] | |
{:bases (not-empty (set (map #'reflect/typename (bases cls)))) | |
:flags (parse-flags (.getModifiers cls) :class) | |
:members (set/union (set (map field->map (.getFields cls))) | |
(set (map method->map (.getMethods cls))) | |
(set (map constructor->map (.getConstructors cls))))})] | |
(catch Throwable _ | |
nil))))) | |
, :file-name runtime.clj, :file-path /Users/kboguta/Library/Application Support/IdeaIC2016.3.Twitter/clojure-plugin/lib/runtime-1.4.0-eap1-2016.2.jar!/cursive/repl/runtime.clj, :id 1dcd5c44-905e-43be-a48e-f439b0be3630, :op load-file, :session 792ecd8e-ac8f-49a9-9dd0-d4a5c1457cc4} | |
java.lang.NullPointerException | |
at clojure.lang.Reflector.boxArg(Reflector.java:448) | |
at clojure.lang.Reflector.boxArgs(Reflector.java:460) | |
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:58) | |
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28) | |
at arcadia.nrepl$extract_prompt_ns.invokeStatic(nrepl.clj:32) | |
at arcadia.nrepl$extract_prompt_ns.invoke(nrepl.clj:29) | |
at arcadia.nrepl$prepare_response.invokeStatic(nrepl.clj:38) | |
at arcadia.nrepl$prepare_response.invoke(nrepl.clj:34) | |
at arcadia.nrepl$arcadia_eval.invokeStatic(nrepl.clj:52) | |
at arcadia.nrepl$arcadia_eval.invoke(nrepl.clj:46) | |
at arcadia.nrepl$wrap_arcadia_repl$fn__995.invoke(nrepl.clj:61) | |
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__457.invoke(middleware.clj:22) | |
at clojure.tools.nrepl.middleware.session$session$fn__792.invoke(session.clj:192) | |
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__457.invoke(middleware.clj:22) | |
at clojure.tools.nrepl.middleware.pr_values$pr_values$fn__644.invoke(pr_values.clj:22) | |
at clojure.tools.nrepl.middleware$wrap_conj_descriptor$fn__457.invoke(middleware.clj:22) | |
at clojure.tools.nrepl.server$handle_STAR_.invokeStatic(server.clj:19) | |
at clojure.tools.nrepl.server$handle_STAR_.invoke(server.clj:16) | |
at clojure.tools.nrepl.server$handle$fn__863.invoke(server.clj:28) | |
at clojure.core$binding_conveyor_fn$fn__4676.invoke(core.clj:1938) | |
at clojure.lang.AFn.call(AFn.java:18) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:266) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) | |
at java.lang.Thread.run(Thread.java:745) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment