Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Complete on static class members

  • Loading branch information...
commit 02658e61d953290b994891ae0723df6c38f2f73e 1 parent a2c788b
@juergenhoetzel juergenhoetzel authored committed
Showing with 13 additions and 2 deletions.
  1. +4 −2 src/swank/commands/completion.clj
  2. +9 −0 src/swank/util/java.clj
View
6 src/swank/commands/completion.clj
@@ -44,9 +44,11 @@
(map #(str "." %) (set (map method-name (mapcat instance-methods (vals (ns-imports ns))))))))
(defn potential-static
- "Returns a list of potential static methods for a given namespace"
+ "Returns a list of potential static members for a given namespace"
([#^Class class]
- (map method-name (static-methods class))))
+ (concat (map method-name (static-methods class))
+ (map field-name (static-fields class)))))
+
(defn potiential-classes-on-path
"Returns a list of Java class and Clojure package names found on the current
View
9 src/swank/util/java.clj
@@ -3,11 +3,20 @@
(defn method-name [#^java.lang.reflect.Method method]
(.getName method))
+(defn field-name [#^java.lang.reflect.Field field]
+ (.getName field))
+
(defn method-static? [#^java.lang.reflect.Method method]
(java.lang.reflect.Modifier/isStatic (.getModifiers method)))
+(defn field-static? [#^java.lang.reflect.Field field]
+ (java.lang.reflect.Modifier/isStatic (.getModifiers field)))
+
(defn static-methods [#^Class class]
(filter method-static? (.getMethods class)))
+(defn static-fields [#^Class class]
+ (filter field-static? (.getDeclaredFields class)))
+
(defn instance-methods [#^Class class]
(remove method-static? (.getMethods class)))
Please sign in to comment.
Something went wrong with that request. Please try again.