Permalink
Browse files

Fix trailing whitespace and >80-column lines.

  • Loading branch information...
1 parent f96e740 commit f564cc45a1fff2434f35d3682024284b2440379e @technomancy committed Dec 24, 2012
Showing with 23 additions and 18 deletions.
  1. +2 −2 src/slam/hound/asplode.clj
  2. +4 −5 src/slam/hound/prettify.clj
  3. +15 −10 src/slam/hound/regrow.clj
  4. +2 −1 src/slam/hound/stitch.clj
@@ -1,5 +1,5 @@
(ns slam.hound.asplode
- (:import java.io.PushbackReader))
+ (:import (java.io PushbackReader)))
(defn- ns-to-map [ns-form]
(let [[_ ns-name maybe-doc & clauses] ns-form
@@ -14,7 +14,7 @@
(defn asplode [rdr]
(let [rdr (PushbackReader. rdr)
ns-map (ns-to-map (read rdr))
- stripped-ns (-> ns-map
+ stripped-ns (-> ns-map
(assoc :old ns-map)
(dissoc :use :require :import))
body (take-while #(not= ::done %)
@@ -1,8 +1,8 @@
(ns slam.hound.prettify
"Format a namespace declaration using pretty print with custom dispatch."
- (:use [clojure.pprint :only [code-dispatch pprint with-pprint-dispatch cl-format
- pprint-logical-block pprint-newline formatter-out
- write-out]]))
+ (:use [clojure.pprint :only [code-dispatch pprint with-pprint-dispatch
+ cl-format pprint-logical-block pprint-newline
+ formatter-out write-out]]))
(defn- brackets
"Figure out which kind of brackets to use"
@@ -48,7 +48,7 @@
(defn- pprint-ns
"The pretty print dispatch chunk for the ns macro"
[alis]
- (if (next alis)
+ (if (next alis)
(let [[ns-sym ns-name & stuff] alis
[doc-str stuff] (if (string? (first stuff))
[(first stuff) (next stuff)]
@@ -84,4 +84,3 @@
(with-out-str
(with-pprint-dispatch augmented-dispatch
(pprint ns-form))))
-
View
@@ -27,8 +27,10 @@
(when-let [sym (missing-sym-name msg)]
{:missing sym
:possible-types (cond (class-name? sym) [:import :require-refer]
- (re-find #"Unable to resolve var: \w+/" msg) [:require-as :require-refer]
- (re-find #"No such (var|namespace)" msg) [:require-as]
+ (re-find #"Unable to resolve var: \w+/" msg)
+ [:require-as :require-refer]
+ (re-find #"No such (var|namespace)" msg)
+ [:require-as]
:else [:require-refer :import])}))
(defn- check-for-failure [ns-map body]
@@ -62,10 +64,11 @@
:when (= missing (last (.split class-name "\\.")))]
(symbol class-name))
:require-as (for [n (all-ns)
- :let [syms-with-alias (get (ns-qualifed-syms body) missing)]
- :when (seq syms-with-alias)
- :when (every? (set (keys (ns-publics n)))
- syms-with-alias)]
+ :let [syms-with-alias (get (ns-qualifed-syms body)
+ missing)]
+ :when (and (seq syms-with-alias)
+ (every? (set (keys (ns-publics n)))
+ syms-with-alias))]
[(ns-name n) :as (symbol missing)])
:require-refer (for [n (all-ns)
[sym var] (ns-publics n)
@@ -89,21 +92,23 @@
(defn- new-type-to-old-types [new-type]
(case new-type
:require-as [:require]
- :require-refer [:require :use] ;; could've been require/refer or use/only
+ :require-refer [:require :use] ; could've been require/refer or use/only
[new-type]))
(defn- disambiguate [candidates missing ns-map type]
;; TODO: prefer things in src/classes to jars
(debug :disambiguating missing :in candidates)
(->> candidates
- (sort-by (juxt (complement (in-originals-pred (map #(get (:old ns-map) %)
- (new-type-to-old-types type))))
+ (sort-by (juxt (complement (in-originals-pred
+ (map #(get (:old ns-map) %)
+ (new-type-to-old-types type))))
(comp count str)))
(remove #(re-find disambiguator-blacklist (str %)))
first))
(defn- grow-step [missing type ns-map body]
- (if-let [addition (disambiguate (candidates type missing body) missing ns-map type)]
+ (if-let [addition (disambiguate (candidates type missing body)
+ missing ns-map type)]
(update-in ns-map [type] conj addition)
ns-map))
@@ -35,7 +35,8 @@
ns-map-clauses))
(defn ns-from-map [ns-map]
- (let [ns-map (assoc ns-map :require (concat (:require-as ns-map) (:require-refer ns-map)))]
+ (let [ns-map (assoc ns-map :require (concat (:require-as ns-map)
+ (:require-refer ns-map)))]
`(~'ns ~(:name ns-map)
~@(if-let [doco (:doc (:meta ns-map))] ; avoid inserting nil
[doco])

0 comments on commit f564cc4

Please sign in to comment.