Browse files

Complete on static class members

  • Loading branch information...
1 parent a2c788b commit 02658e61d953290b994891ae0723df6c38f2f73e @juergenhoetzel juergenhoetzel committed with Mar 3, 2010
Showing with 13 additions and 2 deletions.
  1. +4 −2 src/swank/commands/completion.clj
  2. +9 −0 src/swank/util/java.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
@@ -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)))

0 comments on commit 02658e6

Please sign in to comment.