Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

References to parsley are explicit.

  • Loading branch information...
commit ee01cfc4b6ccf497664ed2d94fca27e8df27b9a9 1 parent fc71168
@tcrayford tcrayford authored
View
44 src/clojure_refactoring/destructuring.clj
@@ -1,63 +1,65 @@
(ns clojure-refactoring.destructuring
(:use clojure.walk
- [clojure-refactoring.support core parsley]
+ [clojure-refactoring.support core]
[clojure.contrib.seq-utils :only [find-first]]
- [clojure.contrib.str-utils :only [str-join]]))
+ [clojure.contrib.str-utils :only [str-join]]
+ [clojure-refactoring.support.parsley :only [defparsed-fn]])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn parsley-map-lookup? [ast]
- (let [content (relevant-content ast)]
- (and (tag= :list ast)
- (count= (filter parsley-keyword? content) 1)
+ (let [content (ast/relevant-content ast)]
+ (and (ast/tag= :list ast)
+ (count= (filter ast/parsley-keyword? content) 1)
(count= content 2))))
(defn parsley-key->sym [kw-node]
- (replace-content kw-node
+ (ast/replace-content kw-node
(list
(str-join ""
(drop 1 (first (:content kw-node)))))))
(defn parsley-find-lookups [node]
"Returns all the map lookups in a node as a set of parsley asts"
- (->> (parsley-sub-nodes node)
+ (->> (ast/parsley-sub-nodes node)
(filter parsley-map-lookup?)
set))
(defn- swap-first-with-last [ast]
- (let [[first-node last-node] (relevant-content ast)]
+ (let [[first-node last-node] (ast/relevant-content ast)]
(replace
{first-node last-node, last-node first-node}
(:content ast))))
(defn- parsley-swap-first-with-last [ast]
- (replace-content ast
+ (ast/replace-content ast
(swap-first-with-last ast)))
(defn parsley-lookup-to-canoninical-form [lookup-ast]
- (let [[maybe-keyword] (relevant-content lookup-ast)]
- (if (parsley-keyword? maybe-keyword)
+ (let [[maybe-keyword] (ast/relevant-content lookup-ast)]
+ (if (ast/parsley-keyword? maybe-keyword)
lookup-ast
(parsley-swap-first-with-last lookup-ast))))
(defn add-to-parsley-map [m key val]
"Adds key and value (which should be parsley nodes
to m, which represents a parsley map."
- (replace-content m
+ (ast/replace-content m
`("{"
~key
- ~parsley-whitespace
+ ~ast/parsley-whitespace
~val
- ~parsley-whitespace
+ ~ast/parsley-whitespace
~@(drop 1 (:content m)))))
(def relevant-content-from-canoninical-form
- (comp relevant-content parsley-lookup-to-canoninical-form))
+ (comp ast/relevant-content parsley-lookup-to-canoninical-form))
(defn- add-lookup-to-binding-map [binding-map lookup]
"Adds a lookup (a node of the form (:a a)) to a binding map."
(let [[key m] (relevant-content-from-canoninical-form lookup)]
(assoc binding-map m
(add-to-parsley-map
- (get binding-map m parsley-empty-map)
+ (get binding-map m ast/parsley-empty-map)
(parsley-key->sym key) key))))
(defn lookups-to-binding-map [lookups]
@@ -76,22 +78,22 @@
;;replacing stuff all over the place
(reduce
(fn [new-ast lookup]
- (parsley-tree-replace
+ (ast/parsley-tree-replace
lookup
- (parsley-key->sym (first (relevant-content (parsley-lookup-to-canoninical-form lookup))))
+ (parsley-key->sym (first (ast/relevant-content (parsley-lookup-to-canoninical-form lookup))))
new-ast))
ast
lookups))
(defn- add-destructured-maps-to-args [lookups root-ast]
- (let [args (parsley-fn-args root-ast)
+ (let [args (ast/parsley-fn-args root-ast)
new-args (destructured-binding-vec args lookups)]
- (parsley-tree-replace args new-args root-ast)))
+ (ast/parsley-tree-replace args new-args root-ast)))
(defparsed-fn destructure-map [root-ast]
"Destructures all calls to maps"
(let [lookups (parsley-find-lookups root-ast)]
- (parsley-to-string
+ (ast/parsley-to-string
(replace-lookups-with-destructured-symbols
lookups
(add-destructured-maps-to-args lookups root-ast)))))
View
26 src/clojure_refactoring/extract_method.clj
@@ -1,19 +1,21 @@
(ns clojure-refactoring.extract-method
(:use [clojure-refactoring.support core formatter
- find-bindings-above-node parsley]
+ find-bindings-above-node]
+ [clojure-refactoring.support.parsley :only [defparsed-fn]]
clojure.set
- [clojure.contrib.seq-utils :only [find-first]]))
+ [clojure.contrib.seq-utils :only [find-first]])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn- find-occurences [args node]
"Looks for any occurence of each element of args in the node"
- (seq (intersection (set args) (set (parsley-sub-nodes node)))))
+ (seq (intersection (set args) (set (ast/parsley-sub-nodes node)))))
(defn fn-name [fn-node]
- (second (relevant-content fn-node)))
+ (second (ast/relevant-content fn-node)))
(defn fn-call [fn-node]
"Uses the arguments of a function node to return a call to it."
- (parsley-list `(~(fn-name fn-node) ~@(parsley-bindings fn-node))))
+ (ast/parsley-list `(~(fn-name fn-node) ~@(ast/parsley-bindings fn-node))))
(defn- arg-occurences [f-node extracted-node]
"Finds the bindings from f-node that are also in the extracted node."
@@ -23,23 +25,23 @@
(defn- make-fn-node [name args body]
"Creates an ast representing the new function"
(format-ast
- (list-without-whitespace
- (ast-symbol 'defn)
+ (ast/list-without-whitespace
+ (ast/ast-symbol 'defn)
name
- (parsley-vector args)
- (strip-whitespace body))))
+ (ast/parsley-vector args)
+ (ast/strip-whitespace body))))
(defn call-extracted [body toplevel extracted]
- (parsley-tree-replace
+ (ast/parsley-tree-replace
body
(fn-call extracted)
toplevel))
(defn- nodes-to-string [extract-node fn-node new-fun]
"Formats the output for extract-method to print"
- (str (parsley-to-string new-fun)
+ (str (ast/parsley-to-string new-fun)
"\n\n"
- (parsley-to-string
+ (ast/parsley-to-string
(call-extracted extract-node fn-node new-fun))))
(defparsed-fn extract-method [function-node extract-node new-name]
View
34 src/clojure_refactoring/local_binding.clj
@@ -1,27 +1,29 @@
(ns clojure-refactoring.local-binding
(:use clojure.walk
[clojure-refactoring.support core parsley formatter]
- [clojure.contrib.seq-utils :only (find-first)]))
+ [clojure.contrib.seq-utils :only (find-first)]
+ [clojure-refactoring.support.parsley :only [defparsed-fn]])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn- get-function-definition [defn-ast]
- (find-first (tag= :list) (:content defn-ast)))
+ (find-first (ast/tag= :list) (:content defn-ast)))
(defn- add-to-binding [{content :content :as binding-node}
value var-name]
- (replace-content binding-node
+ (ast/replace-content binding-node
`(~(first content)
~@(butlast (drop 1 content))
- ~parsley-whitespace
+ ~ast/parsley-whitespace
~var-name
- ~parsley-whitespace
+ ~ast/parsley-whitespace
~value
~(last content))))
(defn is-node-the-binding-form [top-level ast]
- (= ast (parsley-fn-args top-level)))
+ (= ast (ast/parsley-fn-args top-level)))
(defn- modify-existing-let-block [form value var-name]
- (parsley-walk
+ (ast/parsley-walk
(fn [ast]
(if (is-node-the-binding-form form ast)
(add-to-binding ast value var-name)
@@ -29,26 +31,26 @@
form))
(defn let-wrap [form value var-name]
- (if (parsley-binding-node? form)
+ (if (ast/parsley-binding-node? form)
(modify-existing-let-block form value var-name)
- (list-without-whitespace
- (ast-symbol 'let)
- parsley-whitespace
- (parsley-vector
+ (ast/list-without-whitespace
+ (ast/ast-symbol 'let)
+ ast/parsley-whitespace
+ (ast/parsley-vector
[var-name value])
- parsley-whitespace
+ ast/parsley-whitespace
form)))
(defn- wrap-function-body-with-let [defn-form value var-name]
(let [fn-def (get-function-definition defn-form)]
- (parsley-tree-replace
+ (ast/parsley-tree-replace
fn-def (let-wrap fn-def value var-name)
defn-form)))
(defparsed-fn local-wrap [top value var-name]
"Extracts a value as a local variable inside top"
(-> (wrap-function-body-with-let
- (parsley-tree-replace
+ (ast/parsley-tree-replace
value var-name top)
value var-name)
- parsley-to-string))
+ ast/parsley-to-string))
View
13 src/clojure_refactoring/rename.clj
@@ -1,14 +1,15 @@
(ns clojure-refactoring.rename
- (:use [clojure-refactoring.support replace parsley]
+ (:use [clojure-refactoring.support replace]
clojure.walk)
- (:require [clojure-refactoring.support.parser :as parser]))
+ (:require [clojure-refactoring.support.parser :as parser])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn rename [node old-name new-name]
(let [ast (parser/parse node)
old (symbol old-name)
new (symbol new-name)]
- (parsley-to-string
- (replace-symbol-in-ast-node
+ (ast/parsley-to-string
+ (ast/replace-symbol-in-ast-node
old
new
ast))))
@@ -16,14 +17,12 @@
(defn renaming-fn [old-var new-sym]
"Returns a function for renaming nodes"
(fn [node]
- (replace-symbol-in-ast-node
+ (ast/replace-symbol-in-ast-node
(.sym old-var)
new-sym
node)))
(defn global-rename [ns old-name new-name]
"Sends a list of alists to emacs for processing as renames"
- #_{:pre [(do (find-ns ns)
- (ns-resolve ns old-name))]}
(let [old-var (ns-resolve ns old-name)]
(replace-callers old-var (renaming-fn old-var new-name))))
View
19 src/clojure_refactoring/support/find_bindings_above_node.clj
@@ -1,25 +1,24 @@
(ns clojure-refactoring.support.find-bindings-above-node
- (:use [clojure-refactoring.support core parsley]))
-
-
+ (:use [clojure-refactoring.support core])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn extract-binding-syms [ast]
(if (#{"defmacro" "fn" "defn"}
(first (:content (second (:content ast)))))
- (relevant-content (first-vector ast))
- (evens (relevant-content (first-vector ast)))))
+ (ast/relevant-content (ast/first-vector ast))
+ (evens (ast/relevant-content (ast/first-vector ast)))))
(defn extract-symbols-from-binding-node [ast]
(->> (extract-binding-syms ast)
- parsley-sub-nodes
- (filter parsley-symbol?)))
+ ast/parsley-sub-nodes
+ (filter ast/parsley-symbol?)))
(defn binding-node-that-contains? [node expr]
- (and (parsley-binding-node? node)
- (parsley-tree-contains node expr)))
+ (and (ast/parsley-binding-node? node)
+ (ast/parsley-tree-contains node expr)))
(defn find-bindings-above-node [node expr]
- (->> (parsley-sub-nodes node)
+ (->> (ast/parsley-sub-nodes node)
(filter #(binding-node-that-contains? % expr))
(mapcat extract-symbols-from-binding-node)
distinct))
View
33 src/clojure_refactoring/support/formatter.clj
@@ -1,41 +1,42 @@
(ns clojure-refactoring.support.formatter
- (:use [clojure-refactoring.support parsley core]))
+ (:use [clojure-refactoring.support core])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn replace-content-by [f {content :content :as ast}]
- (if (composite-tag? (:tag ast))
- (replace-content ast
+ (if (ast/composite-tag? (:tag ast))
+ (ast/replace-content ast
`(~(first content)
- ~@(f (drop-first-and-last content))
+ ~@(f (ast/drop-first-and-last content))
~(last content)))
ast))
(defn add-whitespace-to-lists [ast]
- (parsley-walk
- #(replace-content-by add-whitespace %)
+ (ast/parsley-walk
+ #(replace-content-by ast/add-whitespace %)
ast))
(defn not-replaced-in-threading? [node]
- (or (some #{(first-content node)} ["->>" "->"])
- (tag= :whitespace node)
+ (or (some #{(ast/first-content node)} ["->>" "->"])
+ (ast/tag= :whitespace node)
(string? node)))
(defn replace-this-when-threading [ast toplevel]
(not (or (not-replaced-in-threading? ast)
- (= ast (last (relevant-content toplevel))))))
+ (= ast (last (ast/relevant-content toplevel))))))
(def threading-spacing
- [parsley-newline parsley-whitespace parsley-whitespace])
+ [ast/parsley-newline ast/parsley-whitespace ast/parsley-whitespace])
(defn format-threaded [ast]
(let [with-whitespace
(add-whitespace-to-lists ast)]
- (replace-content
+ (ast/replace-content
with-whitespace
(after-each #(replace-this-when-threading % with-whitespace)
threading-spacing
(:content with-whitespace)))))
-(defmulti format-ast first-symbol)
+(defmulti format-ast ast/first-symbol)
(defmethod format-ast "->" [ast]
(format-threaded ast))
@@ -44,16 +45,16 @@
(format-threaded ast))
(defmethod format-ast "defn" [ast]
- (replace-content
+ (ast/replace-content
ast
- (after-each #(= % (parsley-fn-args ast))
+ (after-each #(= % (ast/parsley-fn-args ast))
(drop-last threading-spacing)
(:content (add-whitespace-to-lists ast)))))
(defn format-sub-nodes [ast]
- (replace-content-by #(add-whitespace (map format-ast %)) ast))
+ (replace-content-by #(ast/add-whitespace (map format-ast %)) ast))
(defmethod format-ast :default [ast]
- (if (some composite-tag? (relevant-content ast))
+ (if (some ast/composite-tag? (ast/relevant-content ast))
(format-sub-nodes ast)
(add-whitespace-to-lists ast)))
View
7 src/clojure_refactoring/support/replace.clj
@@ -1,8 +1,7 @@
(ns clojure-refactoring.support.replace
(:use [clojure-refactoring.support
- source core paths]
- [clojure-refactoring.support.parsley
- :only [parsley-to-string]]))
+ source core paths])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(defn map-to-alist [m]
"Converts a clojure map to an alist suitable for emacs"
@@ -16,7 +15,7 @@
(if (= (parsley-from-cache ns) replacement)
nil
{:file (filename-from-ns ns)
- :new-source (parsley-to-string
+ :new-source (ast/parsley-to-string
replacement)})))
(defn replace-namespaces [namespaces f]
View
2  src/clojure_refactoring/support/source.clj
@@ -1,6 +1,6 @@
(ns clojure-refactoring.support.source
(:use [clojure.contrib.find-namespaces :only [find-namespaces-in-dir]]
- [clojure-refactoring.support core paths parsley])
+ [clojure-refactoring.support core paths])
(:import java.io.File)
(require [clojure-refactoring.support.parser :as parser]))
View
37 src/clojure_refactoring/thread_expression.clj
@@ -1,8 +1,9 @@
(ns clojure-refactoring.thread-expression
- (:use [clojure-refactoring.support core parsley]
+ (:use [clojure-refactoring.support core]
[clojure.walk :only [postwalk]]
clojure-refactoring.support.formatter)
- (:require [clojure-refactoring.support.parser :as parser]))
+ (:require [clojure-refactoring.support.parser :as parser])
+ (:require [clojure-refactoring.support.parsley :as ast]))
(def expression-threaders '#{->> -> clojure.core/->> clojure.core/->})
@@ -33,45 +34,45 @@
(defn threading-fns-from-type [type]
"Returns functions to be used by thread-with-type
based on what type of threading is going to be"
- ({'-> {:position-f (comp second relevant-content)
- :all-but-position-f (comp but-second relevant-content)}
- '->> {:position-f (comp last relevant-content)
- :all-but-position-f (comp butlast relevant-content)}} type))
+ ({'-> {:position-f (comp second ast/relevant-content)
+ :all-but-position-f (comp but-second ast/relevant-content)}
+ '->> {:position-f (comp last ast/relevant-content)
+ :all-but-position-f (comp butlast ast/relevant-content)}} type))
(defn not-last-threading-node? [ast position-f]
- (and (tag= :list (position-f ast))
- (tag= :list (position-f (position-f ast)))))
+ (and (ast/tag= :list (position-f ast))
+ (ast/tag= :list (position-f (position-f ast)))))
(defn finish-threading [{content :content :as node}
new-ast thread-type]
(let [{:keys [position-f all-but-position-f]}
(threading-fns-from-type thread-type)
- useful-content (relevant-content node)]
- (content-conj
+ useful-content (ast/relevant-content node)]
+ (ast/content-conj
new-ast
(position-f node)
- (apply list-without-whitespace (all-but-position-f node)))))
+ (apply ast/list-without-whitespace (all-but-position-f node)))))
(defn thread-with-type [thread-type ast]
(let [{:keys [position-f all-but-position-f]}
(threading-fns-from-type thread-type)]
- (loop [node ast new-node empty-parsley-list]
+ (loop [node ast new-node ast/empty-parsley-list]
(if (not-last-threading-node? node position-f)
(recur (position-f node)
- (content-conj new-node (all-but-position-f node)))
+ (ast/content-conj new-node (all-but-position-f node)))
(finish-threading node new-node thread-type)))))
(defn thread-ast [thread-type ast]
- (apply list-without-whitespace
- `(~(ast-symbol thread-type)
+ (apply ast/list-without-whitespace
+ `(~(ast/ast-symbol thread-type)
~@(->> (thread-with-type thread-type ast)
- relevant-content))))
+ ast/relevant-content))))
(defn- construct-threaded [thread-type code]
- (->> (strip-whitespace (parser/parse1 code))
+ (->> (ast/strip-whitespace (parser/parse1 code))
(thread-ast thread-type)
format-ast
- parsley-to-string))
+ ast/parsley-to-string))
(defn thread-last [code]
(construct-threaded '->> code))
View
13 test/clojure_refactoring/destructuring_test.clj
@@ -1,13 +1,14 @@
(ns clojure-refactoring.destructuring-test
(:use clojure-refactoring.destructuring :reload)
- (:use clojure-refactoring.support.parsley
- clojure.test)
+ (:use clojure.test)
+ (:use [clojure-refactoring.support.parsley :only [defparsed-fn]])
+ (:require [clojure-refactoring.support.parsley :as ast])
(:require [clojure-refactoring.support.parser :as parser]))
(use-fixtures :once #(time (%)))
(deftest removing-whitespace
- (is (empty? (remove ignored-node?
+ (is (empty? (remove ast/ignored-node?
(parser/parse " ")))))
(deftest parsley_map_lookup
@@ -27,17 +28,17 @@
'{:tag :atom :content ("a")})))
(deftest parsley_find_map_lookups
- (is (= (map parsley-to-string
+ (is (= (map ast/parsley-to-string
(parsley-find-lookups (parser/parse "(defn a [b] (:a b))")))
'("(:a b)"))))
(deftest parsley_lookup_to_proper_form
- (is (= (parsley-to-string (parsley-lookup-to-canoninical-form
+ (is (= (ast/parsley-to-string (parsley-lookup-to-canoninical-form
(first (parser/parse "(a :a)"))))
"(:a a)")))
(deftest add_to_parsley_map
- (is (= (parsley-to-string
+ (is (= (ast/parsley-to-string
(add-to-parsley-map '{:tag :map :content ("{" "}")}
'{:tag :atom :content ("a")}
'{:tag :atom :content ("b")})))))
View
10 test/clojure_refactoring/extract_method_test.clj
@@ -1,17 +1,17 @@
(ns clojure-refactoring.extract-method-test
(:use clojure-refactoring.extract-method :reload)
(:use clojure.test
- [clojure-refactoring.support find-bindings-above-node
- parsley])
+ clojure-refactoring.support.find-bindings-above-node)
+ (:require [clojure-refactoring.support.parsley :as ast])
(:require [clojure-refactoring.support.parser :as parser]))
(use-fixtures :once #(time (%)))
(defn fn-call-sexp [sexp]
- (read-string (parsley-to-string (fn-call (sexp->parsley sexp)))))
+ (read-string (ast/parsley-to-string (fn-call (ast/sexp->parsley sexp)))))
(defn fn-name-sexp [sexp]
- (symbol (first (:content (fn-name (sexp->parsley sexp))))))
+ (symbol (first (:content (fn-name (ast/sexp->parsley sexp))))))
(deftest fn_name
(is (= (fn-name-sexp '(defn a [c] c)) 'a)))
@@ -20,7 +20,7 @@
(is (= (fn-call-sexp '(defn a [b] (+ 1 2))) '(a b))))
(defn remove-extracted-function-sexp [extracted toplevel new-fn]
- (parsley-to-string
+ (ast/parsley-to-string
(call-extracted
(parser/parse1 extracted)
(parser/parse1 toplevel)
View
1  test/clojure_refactoring/local_binding_test.clj
@@ -1,6 +1,5 @@
(ns clojure-refactoring.local-binding-test
(:use clojure.test)
- (:use clojure-refactoring.support.parsley)
(:use clojure-refactoring.local-binding :reload))
(use-fixtures :once #(time (%)))
View
4 test/clojure_refactoring/rename_test.clj
@@ -1,7 +1,7 @@
(ns clojure-refactoring.rename-test
(:use clojure.test
clojure.contrib.mock)
- (:require [clojure-refactoring.support.parsley :as parsley])
+ (:require [clojure-refactoring.support.parsley :as ast])
(:require [clojure-refactoring.support.parser :as parser])
(:use clojure-refactoring.rename :reload))
@@ -21,7 +21,7 @@
(deftest renaming_fn
(testing "it replaces occurences of the var name"
- (is (= (parsley/parsley-to-string
+ (is (= (ast/parsley-to-string
((renaming-fn #'a 'z)
(parser/parse
"(defn b [c] (a 1 2))")))
View
8 test/clojure_refactoring/support/find_bindings_above_node_test.clj
@@ -1,14 +1,14 @@
(ns clojure-refactoring.support.find-bindings-above-node-test
(:use clojure-refactoring.support.find-bindings-above-node :reload)
- (:use clojure-refactoring.support.parsley
- clojure.test))
+ (:require [clojure-refactoring.support.parsley :as ast])
+ (:use clojure.test))
(use-fixtures :once #(time (%)))
(defn find-bindings-above-sexp [node expr]
(->> (find-bindings-above-node
- (sexp->parsley node)
- (sexp->parsley expr))
+ (ast/sexp->parsley node)
+ (ast/sexp->parsley expr))
(map (comp symbol first :content))
vec))
View
12 test/clojure_refactoring/support/formatter_test.clj
@@ -1,18 +1,18 @@
(ns clojure-refactoring.support.formatter-test
(:use clojure-refactoring.support.formatter :reload)
(:use clojure.test)
- (:use clojure-refactoring.support.parsley)
+ (:require [clojure-refactoring.support.parsley :as ast])
(:use clojure-refactoring.test-helpers))
(defn format-from-sexp [s]
- (->> (sexp->parsley s)
- strip-whitespace
+ (->> (ast/sexp->parsley s)
+ ast/strip-whitespace
format-ast
- parsley-to-string))
+ ast/parsley-to-string))
(deftest strip-whitespace-test
- (is (= (parsley-to-string
- (strip-whitespace (sexp->parsley '(+ 1 2))))
+ (is (= (ast/parsley-to-string
+ (ast/strip-whitespace (ast/sexp->parsley '(+ 1 2))))
"(+12)")))
(deftest it-adds-whitespace-to-a-one-line-sexp
View
30 test/clojure_refactoring/support/parsley_test.clj
@@ -1,5 +1,5 @@
(ns clojure-refactoring.support.parsley-test
- (:use clojure-refactoring.support.parsley :reload)
+ (:require [clojure-refactoring.support.parsley :as ast] :reload)
(:use clojure-refactoring.test-helpers
clojure.test
[clojure-refactoring.support core source paths])
@@ -8,23 +8,23 @@
(use-fixtures :once #(time (%)))
(deftest parlsey_keyword
- (is (parsley-keyword? (first (parser/parse ":a")))))
+ (is (ast/parsley-keyword? (first (parser/parse ":a")))))
(deftest parsley_to_string
(prop "parsley to string composed with parse is identity"
[s random-sexp-from-core]
- (is (= (parsley-to-string (parser/parse s))
+ (is (= (ast/parsley-to-string (parser/parse s))
s)))
(testing "parsley to string for each file in this project"
(doseq [file (map filename-from-ns (find-ns-in-user-dir))]
(let [slurped (memo-slurp file)]
- (is (= (parsley-to-string (parser/parse slurped))
+ (is (= (ast/parsley-to-string (parser/parse slurped))
slurped))))))
(defn parsley-rec-contains [obj ast]
"Works out if a parsley-ast contains a sexp object"
- (-> (parsley-to-string ast)
+ (-> (ast/parsley-to-string ast)
read-string
(tree-contains? obj)))
@@ -37,14 +37,14 @@
old (first (read-string s))]
(is (not
(->>
- (replace-symbol-in-ast-node old new parsed)
+ (ast/replace-symbol-in-ast-node old new parsed)
(parsley-rec-contains old))))))
(prop "replacing a symbol with itself is identity on an ast"
[s random-sexp-from-core]
(let [parsed (parser/parse s)
sym (first (read-string s))]
- (is (= (replace-symbol-in-ast-node sym sym parsed)
+ (is (= (ast/replace-symbol-in-ast-node sym sym parsed)
parsed))))
(prop "replacing a symbol with another one, then replacing the new one with the original produces the same node"
@@ -53,12 +53,12 @@
(let [parsed (parser/parse s)
old (first (read-string s))]
(is (= (->> parsed
- (replace-symbol-in-ast-node old new)
- (replace-symbol-in-ast-node new old))
+ (ast/replace-symbol-in-ast-node old new)
+ (ast/replace-symbol-in-ast-node new old))
parsed))))
- (is (= (parsley-to-string
- (replace-symbol-in-ast-node 'a 'z
+ (is (= (ast/parsley-to-string
+ (ast/replace-symbol-in-ast-node 'a 'z
(parser/parse "(defn b [c] (a 1 2))")))
"(defn b [c] (z 1 2))")))
@@ -66,17 +66,17 @@
(prop "parsley-walk with identity returns the same ast it was passe"
[s random-sexp-from-core]
(let [parsed (parser/parse s)]
- (is (= (parsley-walk identity parsed)
+ (is (= (ast/parsley-walk identity parsed)
parsed)))))
(deftest parsley_list
- (is (= (parsley-list [1 2 3])
+ (is (= (ast/parsley-list [1 2 3])
'{:tag :list, :content ("(" 1 {:tag :whitespace, :content (" ")} 2 {:tag :whitespace, :content (" ")} 3 ")")})))
(deftest parsley_vector
- (is (= (parsley-vector [1 2 3])
+ (is (= (ast/parsley-vector [1 2 3])
'{:tag :vector, :content ("[" 1 {:tag :whitespace, :content (" ")} 2 {:tag :whitespace, :content (" ")} 3 "]")})))
(deftest parsley_binding_node?
- (is (parsley-binding-node? (first (parser/parse "(let [a 1] a)")))))
+ (is (ast/parsley-binding-node? (parser/parse1 "(let [a 1] a)"))))
View
3  test/clojure_refactoring/support/replace_test.clj
@@ -1,7 +1,6 @@
(ns clojure-refactoring.support.replace-test
(:use clojure-refactoring.support.replace :reload)
- (:use [clojure-refactoring.support source parsley
- paths]
+ (:use [clojure-refactoring.support source paths]
clojure.test
clojure-refactoring.test-helpers
clojure.contrib.mock)
View
2  test/clojure_refactoring/thread_expression_test.clj
@@ -1,6 +1,6 @@
(ns clojure-refactoring.thread-expression-test
(:use clojure-refactoring.thread-expression :reload)
- (:use [clojure-refactoring.support core parsley formatter]
+ (:use [clojure-refactoring.support core formatter]
clojure.test clojure.contrib.str-utils))
(use-fixtures :once #(time (%)))
Please sign in to comment.
Something went wrong with that request. Please try again.