                                   [org.objectweb.asm.Opcodes/ASM4]
                                   (visitAnnotation [desc visible]
                                     annotation-visitor))
-        class-visitor      (proxy [org.objectweb.asm.ClassVisitor] ; classes & interfaces
-                                  [org.objectweb.asm.Opcodes/ASM4] ; constructor params
-                                  ; Overridden functions
-                                  (visit [version access class-name signature super-name interfaces]
-                                    (swap! result visit version access class-name signature super-name interfaces))
-                                  (visitField [access field-name desc signature value]
-                                    (swap! result visit-field access field-name desc signature value)
+        method-visitor     (proxy [org.objectweb.asm.MethodVisitor]
+                                  [org.objectweb.asm.Opcodes/ASM4]
+                                  (visitLocalVariable [local-variable-name desc signature start end index]
+                                    (swap! result visit-local-variable local-variable-name desc signature start end index)))
+        class-visitor      (proxy [org.objectweb.asm.ClassVisitor]
+                                  [org.objectweb.asm.Opcodes/ASM4]
+                                  (visit [version access-bitmask class-name signature super-name interfaces]
+                                    (swap! result visit version access-bitmask class-name signature super-name interfaces))
+                                  (visitField [access-bitmask field-name desc signature value]
+                                    (swap! result visit-field access-bitmask field-name desc signature value)
                                     field-visitor)
-                                  (visitMethod [access name desc signature exceptions]
-                                    (swap! result visit-method access name desc signature exceptions)
-                                    ;method-visitor)
-                                    nil)
-                                  (visitInnerClass [name outer-name inner-name access]
-                                    (swap! result visit-inner-class name outer-name inner-name access))
+                                  (visitMethod [access-bitmask method-name desc signature exceptions]
+                                    (swap! result visit-method access-bitmask method-name desc signature exceptions)
+                                    method-visitor)
+;                                  (visitInnerClass [inner-class-name outer-name inner-name access-bitmask]
+;                                    (swap! result visit-inner-class inner-class-name outer-name inner-name access-bitmask))
                            )]
     (.accept class-reader class-visitor 0)
     @result))

             :dependencies (add-dependency (add-dependencies (add-dependencies existing-dependencies fixed-exception-names :uses) argument-types :uses) return-type :uses)
           })))

(defn- visit-inner-class
  [class-info name outer-name inner-name access]
  (merge class-info
         {
           ;####TODO!!!!
         }))

(defn class-info
  "Takes an input stream of class bytes and returns the dependencies it contains as a map with this shape:

                                 })

(defn- fix-type-name
  [^String type-name]
  (.replaceAll (.replaceAll type-name "/" ".") "\\[\\]" ""))

(defn- fix-descriptor
  [^String desc]
  (fix-type-name (.getClassName (org.objectweb.asm.Type/getType desc))))

(defn- add-dependency
  [dependencies dependency dependency-type]
  (if (contains? dependencies dependency)
    (let [existing-dependency-types (dependencies dependency)
          new-dependency-types      (conj existing-dependency-types dependency-type)]
      (merge dependencies {dependency new-dependency-types}))
    (merge dependencies {dependency #{dependency-type}})))

(defn- add-dependencies
  [dependencies new-dependencies dependency-type]
  (if (or (empty? new-dependencies) (nil? new-dependencies))
    dependencies
    (loop [result                 dependencies
           current-dependency     (first new-dependencies)
           remaining-dependencies (rest  new-dependencies)]
      (if (empty? remaining-dependencies)
        (add-dependency result current-dependency dependency-type)
        (recur (add-dependency result current-dependency dependency-type) (first remaining-dependencies) (rest remaining-dependencies))))))

(defn- typeof
  [access-bitmask]
  (cond
    (not= 0 (bit-and access-bitmask org.objectweb.asm.Opcodes/ACC_INTERFACE))  :interface
    (not= 0 (bit-and access-bitmask org.objectweb.asm.Opcodes/ACC_ENUM))       :enum
    (not= 0 (bit-and access-bitmask org.objectweb.asm.Opcodes/ACC_ANNOTATION)) :annotation
    :else                                                              :class))

(defn- visit
  [class-info version access-bitmask class-name signature super-name interfaces]
  (let [fixed-class-name      (fix-type-name class-name)
        fixed-super-name      (fix-type-name super-name)
        fixed-interface-names (vec (map fix-type-name interfaces))
        existing-dependencies (:dependencies class-info)]
    (merge class-info
           { :name              fixed-class-name
             :type              (typeof access-bitmask)
             :class-version     version
             :class-version-str (version-name-map version)
             :dependencies      (add-dependency (add-dependencies existing-dependencies fixed-interface-names :implements)
                                                fixed-super-name :extends) } )))

(defn- visit-field
  [class-info access-bitmask field-name desc signature value]
  (let [existing-dependencies (:dependencies class-info)
        fixed-field-name      (fix-descriptor desc)]
    (merge class-info
           {
             :dependencies (add-dependency existing-dependencies fixed-field-name :uses)
           })))

(defn- visit-annotation
  [class-info annotation-name desc]
  (let [existing-dependencies (:dependencies class-info)
        fixed-annotation-type (fix-descriptor desc)]
    (merge class-info
           {
             :dependencies (add-dependency existing-dependencies fixed-annotation-type :inner-class)  ; Not sure this is correct
           })))

(defn- visit-method
  [class-info access-bitmask method-name ^String desc signature exceptions]
  (let [fixed-exception-names (vec (map fix-type-name exceptions))
        existing-dependencies (:dependencies class-info)
        argument-types        (vec (map #(fix-type-name (.getClassName %)) (org.objectweb.asm.Type/getArgumentTypes desc)))
